Browse Source

refactor: 处理冲突

antshop
root 5 years ago
parent
commit
51d71b3993
  1. 1
      .gitignore
  2. 18
      backend/config/main.php
  3. 149
      backend/controllers/CategoryController.php
  4. 0
      backend/controllers/ConfigController.php
  5. 149
      backend/controllers/GoodsController.php
  6. 0
      backend/controllers/OrderController.php
  7. 149
      backend/controllers/ShopCategoryController.php
  8. 0
      backend/controllers/SiteController.php
  9. 122
      backend/logic/file/FileManager.php
  10. 47
      backend/views/brand/_search.php
  11. 38
      backend/views/category/_form.php
  12. 98
      backend/views/category/test.php
  13. 0
      backend/views/config/index.php
  14. 82
      backend/views/goods/_form.php
  15. 0
      backend/views/layouts/base.php
  16. 0
      backend/views/layouts/breadcrumb.php
  17. 0
      backend/views/layouts/footer.php
  18. 0
      backend/views/layouts/header.php
  19. 0
      backend/views/layouts/main.php
  20. 16
      backend/views/layouts/sidebar.php
  21. 0
      backend/views/order/_form.php
  22. 0
      backend/views/order/_search.php
  23. 0
      backend/views/order/create.php
  24. 0
      backend/views/order/index.php
  25. 0
      backend/views/order/update.php
  26. 0
      backend/views/order/view.php
  27. 44
      backend/views/shop-category/_form.php
  28. 0
      backend/views/site/error.php
  29. 0
      backend/views/site/index.php
  30. 0
      backend/views/site/login.php
  31. 0
      backend/views/site/test.php
  32. 47
      backend/views/supplier/_search.php
  33. BIN
      backend/web/uploads/xls/15738696921690.jpg
  34. 2
      common/models/ars/Address.php
  35. 2
      common/models/ars/AfterSale.php
  36. 1
      common/models/ars/Area.php
  37. 2
      common/models/ars/Cart.php
  38. 1
      common/models/ars/City.php
  39. 2
      common/models/ars/Collection.php
  40. 2
      common/models/ars/Comment.php
  41. 0
      common/models/ars/Config.php
  42. 2
      common/models/ars/Delivery.php
  43. 2
      common/models/ars/ExpressTemplate.php
  44. 8
      common/models/ars/File.php
  45. 2
      common/models/ars/Order.php
  46. 2
      common/models/ars/OrderGoods.php
  47. 1
      common/models/ars/PaymentLog.php
  48. 1
      common/models/ars/Province.php
  49. 1
      common/models/ars/RefundLog.php
  50. 2
      common/models/ars/SearchHistory.php
  51. 2
      common/models/ars/TakingSite.php
  52. 2
      common/models/ars/TemFile.php
  53. 0
      common/models/searchs/OrderSearch.php
  54. 5
      composer.json
  55. 2
      console/controllers/InitController.php
  56. 0
      console/migrations/m130524_201442_init.php
  57. 0
      console/migrations/m140506_102106_rbac_init.php
  58. 0
      console/migrations/m170907_052038_rbac_add_index_on_auth_assignment_user_id.php
  59. 0
      console/migrations/m180523_151638_rbac_updates_indexes_without_prefix.php
  60. 0
      console/migrations/m190124_110200_add_verification_token_column_to_user_table.php
  61. 0
      console/migrations/m190802_072830_add_category.php
  62. 0
      console/migrations/m191111_101658_create_table_area.php
  63. 0
      console/migrations/m191111_102644_create_table_province.php
  64. 0
      console/migrations/m191111_102730_create_table_city.php
  65. 8
      console/migrations/m191111_102925_create_table_cart.php
  66. 8
      console/migrations/m191111_112559_create_table_address.php
  67. 6
      console/migrations/m191111_113455_create_table_after_sale.php
  68. 2
      console/migrations/m191112_005106_create_table_search_history.php
  69. 4
      console/migrations/m191112_005545_create_table_collection.php
  70. 2
      console/migrations/m191112_005702_create_table_comment.php
  71. 2
      console/migrations/m191112_010421_create_table_order.php
  72. 4
      console/migrations/m191112_011517_create_table_order_goods.php
  73. 2
      console/migrations/m191112_012449_create_table_taking_site.php
  74. 2
      console/migrations/m191112_014508_create_table_express_template.php
  75. 2
      console/migrations/m191112_015939_create_table_delivery.php
  76. 0
      console/migrations/m191112_020830_create_table_payment_log.php
  77. 0
      console/migrations/m191112_021528_create_table_refund_log.php
  78. 0
      console/migrations/m191112_022131_create_table_file.php
  79. 0
      console/migrations/m191112_022532_create_table_tem_file.php
  80. 0
      console/migrations/schema-mysql.sql
  81. 0
      console/migrations/sql/add_category.sql
  82. 0
      console/migrations/sql/area.sql
  83. 0
      console/migrations/sql/city.sql
  84. 0
      console/migrations/sql/province.sql
  85. 8
      environments/skeleton/backend/config/main-local.php
  86. 0
      environments/skeleton/backend/config/params-local.php
  87. 14
      vendor/antgoods/goods/AutoloadExample.php
  88. 31
      vendor/antgoods/goods/README.md
  89. 21
      vendor/antgoods/goods/composer.json
  90. 28
      vendor/antgoods/goods/src/Module.php
  91. 10
      vendor/antgoods/goods/src/controllers/AttributeController.php
  92. 6
      vendor/antgoods/goods/src/controllers/BrandController.php
  93. 276
      vendor/antgoods/goods/src/controllers/CategoryController.php
  94. 282
      vendor/antgoods/goods/src/controllers/GoodsController.php
  95. 273
      vendor/antgoods/goods/src/controllers/ShopcategoryController.php
  96. 6
      vendor/antgoods/goods/src/controllers/SupplierController.php
  97. 51
      vendor/antgoods/goods/src/logic/goods/GoodsManager.php
  98. 14
      vendor/antgoods/goods/src/migrations/m191119_021851_create_table_shop_category.php
  99. 18
      vendor/antgoods/goods/src/migrations/m191119_022641_create_table_category.php
  100. 14
      vendor/antgoods/goods/src/migrations/m191119_022939_create_table_attribute.php

1
.gitignore

@ -38,3 +38,4 @@ vendor.zip
/vagrant /vagrant
/backend/web/uploads /backend/web/uploads
dump.rdb dump.rdb
/console/runtime

18
backend/config/main.php

@ -9,7 +9,11 @@ return [
'basePath' => dirname(__DIR__), 'basePath' => dirname(__DIR__),
'controllerNamespace' => 'backend\controllers', 'controllerNamespace' => 'backend\controllers',
'bootstrap' => ['log'], 'bootstrap' => ['log'],
'modules' => [],
'modules' => [
'antgoods' => [
'class' => 'antgoods\goods\Module',
],
],
'components' => [ 'components' => [
'request' => [ 'request' => [
'csrfParam' => '_csrf-backend', 'csrfParam' => '_csrf-backend',
@ -30,6 +34,16 @@ return [
'class' => 'yii\log\FileTarget', 'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'], 'levels' => ['error', 'warning'],
], ],
[
'class' => 'yii\log\FileTarget',
'levels' => ['info', 'error'],
'categories' => ['imagetest'],
'logFile' => '@app/runtime/logs/imagetest.log',
'logVars' => [],
'exportInterval' => 1,
'prefix' => function ($message) {
}
],
], ],
], ],
'errorHandler' => [ 'errorHandler' => [
@ -41,6 +55,8 @@ return [
'rules' => [ 'rules' => [
], ],
], ],
'file' => ['class' => 'backend\logic\file\FileManager'],
'goods' => ['class' => 'antgoods\goods\logic\goods\GoodsManager'],
], ],
'params' => $params, 'params' => $params,
]; ];

149
backend/controllers/CategoryController.php

@ -1,149 +0,0 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\ars\Category;
use common\models\searchs\CategorySearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* CategoryController implements the CRUD actions for Category model.
*/
class CategoryController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all Category models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new CategorySearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'columns' => $searchModel->columns()
]);
}
/**
* Displays a single Category model.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Category model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Category();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect('index');
}
return $this->render('create', [
'model' => $model,
]);
}
/**
* Updates an existing Category model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect('index');
}
return $this->render('update', [
'model' => $model,
]);
}
/**
* Deletes an existing Category model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
/**
* Finds the Category model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Category the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Category::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
/**
* @author iron
* 文件导出
*/
public function actionExport()
{
$searchModel = new CategorySearch();
$params = Yii::$app->request->queryParams;
if ($params['page-type'] == 'all') {
$dataProvider = $searchModel->allData($params);
} else {
$dataProvider = $searchModel->search($params);
}
\iron\widget\Excel::export([
'models' => $dataProvider->getModels(),
'format' => 'Xlsx',
'asAttachment' => true,
'fileName' =>'Categories'. "-" .date('Y-m-d H/i/s', time()),
'columns' => $searchModel->columns()
]);
}
}

0
backend/controllers/ConfigController.php

149
backend/controllers/GoodsController.php

@ -1,149 +0,0 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\ars\Goods;
use common\models\searchs\GoodsSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* GoodsController implements the CRUD actions for Goods model.
*/
class GoodsController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all Goods models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new GoodsSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'columns' => $searchModel->columns()
]);
}
/**
* Displays a single Goods model.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Goods model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Goods();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect('index');
}
return $this->render('create', [
'model' => $model,
]);
}
/**
* Updates an existing Goods model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect('index');
}
return $this->render('update', [
'model' => $model,
]);
}
/**
* Deletes an existing Goods model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
/**
* Finds the Goods model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Goods the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Goods::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
/**
* @author iron
* 文件导出
*/
public function actionExport()
{
$searchModel = new GoodsSearch();
$params = Yii::$app->request->queryParams;
if ($params['page-type'] == 'all') {
$dataProvider = $searchModel->allData($params);
} else {
$dataProvider = $searchModel->search($params);
}
\iron\widget\Excel::export([
'models' => $dataProvider->getModels(),
'format' => 'Xlsx',
'asAttachment' => true,
'fileName' =>'Goods'. "-" .date('Y-m-d H/i/s', time()),
'columns' => $searchModel->columns()
]);
}
}

0
backend/controllers/OrderController.php

149
backend/controllers/ShopCategoryController.php

@ -1,149 +0,0 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\ars\ShopCategory;
use common\models\searchs\ShopCategorySearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* ShopCategoryController implements the CRUD actions for ShopCategory model.
*/
class ShopCategoryController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all ShopCategory models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new ShopCategorySearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'columns' => $searchModel->columns()
]);
}
/**
* Displays a single ShopCategory model.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new ShopCategory model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new ShopCategory();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect('index');
}
return $this->render('create', [
'model' => $model,
]);
}
/**
* Updates an existing ShopCategory model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect('index');
}
return $this->render('update', [
'model' => $model,
]);
}
/**
* Deletes an existing ShopCategory model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
/**
* Finds the ShopCategory model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return ShopCategory the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = ShopCategory::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
/**
* @author iron
* 文件导出
*/
public function actionExport()
{
$searchModel = new ShopCategorySearch();
$params = Yii::$app->request->queryParams;
if ($params['page-type'] == 'all') {
$dataProvider = $searchModel->allData($params);
} else {
$dataProvider = $searchModel->search($params);
}
\iron\widget\Excel::export([
'models' => $dataProvider->getModels(),
'format' => 'Xlsx',
'asAttachment' => true,
'fileName' =>'Shop Categories'. "-" .date('Y-m-d H/i/s', time()),
'columns' => $searchModel->columns()
]);
}
}

0
backend/controllers/SiteController.php

122
backend/logic/file/FileManager.php

@ -0,0 +1,122 @@
<?php
namespace backend\logic\file;
use common\models\ars\File;
use common\models\ars\TemFile;
class FileManager
{
//数据表ats_file和ats_tem_file的类型字段type
const TYPE_IMAGE = 1;//图片
const TYPE_VIDEO = 2;//影视
const TYPE_EXCEL = 3;//excel表单
const TYPE_WORD = 4;//word文本
const TYPE_TXT = 5;//txt文本
public static $extension = [
self::TYPE_IMAGE => ['jpg', 'png', 'jpeg'],
self::TYPE_VIDEO => ['mp4'],
self::TYPE_EXCEL => [],
self::TYPE_WORD => ['docx'],
self::TYPE_TXT => ['txt'],
];
/**
* @param $array
* @param $keyword
* @return bool|int|string
* 根据文件拓展名在$extension中查找对应的文件类型,若不存在则返回false
*/
public function searchType($array, $keyword)
{
foreach($array as $key => $value){
foreach ($value as $k => $v) {
if($v == $keyword){
return ['status' => true, 'info' => '操作成功', 'type' => $key];
}
}
}
return ['status' => false, 'info' => '操作失败'];
}
/**
* @param $imgIdStr
* @param $ownId
* @param $ownType
* @return array
* 根据临时文件id(字符串)将临时文件保存在文件中
*/
public function saveTemFileToFile($temFIleIdArr, $ownId, $ownType)
{
if(!$temFIleIdArr || !$ownId) {
return ['status' => false, 'info' => '参数错误'];
}
$i = 1;
$first_file_id = 0;
foreach ($temFIleIdArr as $key => $value) {
$tem_file = TemFile::findOne($value);
if(!$tem_file) {
return ['status' => false, 'info' => '存在查找不到的文件'];
}
$res = self::saveNewFile($tem_file, $ownId, $ownType);
if(!$res['status']) {
return ['status' => false, 'info' => '存在文件保存失败'];
}
if($i == 1) {
$first_file_id = $res['file_id'];
}
$i++;
}
return ['status' => true, 'info' => '保存成功', 'first_file_id' => $first_file_id];
}
/**
* @param $temFile
* @param $ownId
* @param $ownType
* @return bool
* 创建新的文件
*/
private function saveNewFile($temFile, $ownId, $ownType)
{
$new_file = new File();
$new_file->name = $temFile->name;
$new_file->type = $temFile->type;
$new_file->own_id = $ownId;
$new_file->own_type = $ownType;
$new_file->alias = $temFile->alias;
$new_file->path = $temFile->path;
if($new_file->save()) {
return ['status' => true, 'info' => '操作成功', 'file_id' => $new_file->id];
} else {
return ['status' => false, 'info' => '操作失败'];
}
}
/**
* @param $fileIdArr
* 删除file表中的文件
*/
public function deleteFile($fileIdArr)
{
if($fileIdArr){
foreach ($fileIdArr as $key => $value) {
$file_model = File::findOne($value);
if($file_model){
$file_model->is_delete = File::IS_DELETE_YES;
if($file_model->save()){
return ['status' => false, 'info' => '操作失败'];
}
}
}
}
return ['status' => true, 'info' => '操作成功'];
}
}

47
backend/views/brand/_search.php

@ -1,47 +0,0 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use \blobt\widgets\DateRangePicker;
/* @var $this yii\web\View */
/* @var $model common\models\searchs\BrandSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
'validateOnType' => true,
]);
?>
<div class="col-sm-12">
<div class="dataTables_filter">
<?= $form->field($model, 'id', [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "检索ID",
"class" => "form-control",
],
"errorOptions" => [
"class" => "error-tips"
]
])
?>
<?= $form->field($model, "created_at_range", [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "创建时间",
],
"errorOptions" => [
"class" => "error-tips"
]
])->widget(DateRangePicker::className());
?>
<div class="form-group">
<?= Html::submitButton('<i class="fa fa-filter"></i>', ['class' => 'btn btn-default']) ?>
<?= Html::resetButton('<i class="fa fa-eraser"></i>', ['class' => 'btn btn-default']) ?>
</div>
</div>
</div>
<?php ActiveForm::end(); ?>

38
backend/views/category/_form.php

@ -1,38 +0,0 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\ars\Category */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="category-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'pid')->textInput() ?>
<?= $form->field($model, 'goods_count')->textInput() ?>
<?= $form->field($model, 'sort_order')->textInput() ?>
<?= $form->field($model, 'icon_type')->textInput() ?>
<?= $form->field($model, 'icon')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'is_show')->textInput() ?>
<?= $form->field($model, 'is_delete')->textInput() ?>
<div class="form-group">
<?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>
<?= Html::a('返回', ['index'], ['class' => 'btn btn-info']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

98
backend/views/category/test.php

@ -1,98 +0,0 @@
<?php
/*
* The MIT License
*
* Copyright 2019 Blobt.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
?>
<header>
<link href="http://hayageek.github.io/jQuery-Upload-File/4.0.11/uploadfile.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://hayageek.github.io/jQuery-Upload-File/4.0.11/jquery.uploadfile.min.js"></script>
</header>
<body>
<div id="showoldupload">
<div class="ajax-upload-dragdrop" style="vertical-align: top; width: 600px;">
<div class="ajax-file-upload" style="position: relative; overflow: hidden; cursor: default;">Upload
<form method="POST" action="upload.php" enctype="multipart/form-data" style="margin: 0px; padding: 0px;">
<input type="file" id="ajax-upload-id-1573635462220" name="myfile[]" accept="*" multiple=""
style="position: absolute; cursor: pointer; top: 0px; width: 100%; height: 100%; left: 0px; z-index: 100; opacity: 0;">
</form>
</div>
<span><b>Drag &amp; Drop Files</b></span></div>
<div></div>
</div>
<div class="ajax-file-upload-container"></div>
</body>
<script>
$("#showoldupload").uploadFile(
{
url: "upload",
dragDrop: true,
fileName: "file",
returnType: "json",
showDelete: true,
showDownload: false,
statusBarWidth: 300,
dragdropWidth: 300,
maxFileSize: 200 * 1024,
dragDropStr: "<span><b>拖动上传</b></span>",
sizeErrorStr: "图片超过最大尺寸限制",
uploadErrorStr: "上传失败",
showPreview: true,
previewHeight: "60px",
previewWidth: "60px",
onSuccess: function (files, data) {
$.ajax({
url: "save-database",
dataType: "json",
data: {data: data, fileName: files},
});
},
onLoad: function (obj) {
$.ajax({
cache: false,
url: "previews",
dataType: "json",
success: function (data) {
for (var i = 0; i < data.length; i++) {
obj.createProgress(data[i]["name"], data[i]["path"], data[i]["size"]);
}
}
});
},
deleteCallback: function (data, pd) {
for (var i = 0; i < data.length; i++) {
// alertify.confirm('系统提示', "确定执行批量 '"+act+"' 操作?", function() {
$.post("image-del", {op: "delete", name: data[i]},
function (resp, textStatus, jqXHR) {
//Show Message
alert("File Deleted");
});
// },function(){
// });
}
pd.statusbar.hide(); //You choice.
},
});
</script>

0
backend/views/config/index.php

82
backend/views/goods/_form.php

@ -1,82 +0,0 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\ars\Goods */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="goods-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'pid')->textInput() ?>
<?= $form->field($model, 'cat_id')->textInput() ?>
<?= $form->field($model, 'brand_id')->textInput() ?>
<?= $form->field($model, 'shop_cat_id')->textInput() ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'sn')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'code')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'supplier_id')->textInput() ?>
<?= $form->field($model, 'weight')->textInput() ?>
<?= $form->field($model, 'length')->textInput() ?>
<?= $form->field($model, 'width')->textInput() ?>
<?= $form->field($model, 'height')->textInput() ?>
<?= $form->field($model, 'diameter')->textInput() ?>
<?= $form->field($model, 'unit')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'sold_count')->textInput() ?>
<?= $form->field($model, 'limit_count')->textInput() ?>
<?= $form->field($model, 'stock')->textInput() ?>
<?= $form->field($model, 'stock_warn')->textInput() ?>
<?= $form->field($model, 'market_price')->textInput() ?>
<?= $form->field($model, 'price')->textInput() ?>
<?= $form->field($model, 'brief')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'description')->textarea(['rows' => 6]) ?>
<?= $form->field($model, 'image')->textInput() ?>
<?= $form->field($model, 'model_id')->textInput() ?>
<?= $form->field($model, 'is_sale')->textInput() ?>
<?= $form->field($model, 'sort_order')->textInput() ?>
<?= $form->field($model, 'bouns_points')->textInput() ?>
<?= $form->field($model, 'experience_points')->textInput() ?>
<?= $form->field($model, 'is_delete')->textInput() ?>
<?= $form->field($model, 'express_template')->textInput() ?>
<div class="form-group">
<?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>
<?= Html::a('返回', ['index'], ['class' => 'btn btn-info']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

0
backend/views/layouts/base.php

0
backend/views/layouts/breadcrumb.php

0
backend/views/layouts/footer.php

0
backend/views/layouts/header.php

0
backend/views/layouts/main.php

16
backend/views/layouts/sidebar.php

@ -20,14 +20,18 @@ use iron\widgets\Menu;
['label' => '基础配置', 'url' => ['config/index']], ['label' => '基础配置', 'url' => ['config/index']],
] ]
], ],
['label' => '商品管理', 'url' => '#', 'icon' => 'fa-archive', 'items' => [
['label' => '商品分类', 'url' => ['/category']],
['label' => '商品列表', 'url' => ['/goods']],
['label' => '属性管理', 'url' => ['/attribute']],
['label' => '商品管理', 'url' => '#', 'icon' => 'far fa-archive', 'items' => [
['label' => '规格管理', 'url' => ['/antgoods/attribute/index']],
['label' => '商品列表', 'url' => ['/antgoods/goods/index']],
['label' => '后台商品分类', 'url' => ['/antgoods/category/index']],
['label' => '前端商品分类', 'url' => ['/antgoods/shopcategory/index']],
['label' => '品牌管理', 'url' => ['/antgoods/brand/index']],
['label' => '供应商管理', 'url' => ['/antgoods/supplier/index']],
] ]
], ],
['label' => '订单管理', 'url' => '#', 'icon' => 'fa-list-alt', 'items' => [
['label' => '订单列表', 'url' => ['order/index']],
['label' => '订单管理', 'url' => '#', 'icon' => 'far fa-list-alt', 'items' => [
['label' => '订单列表', 'url' => ['/order/index', 'tag' => 'new']],
] ]
], ],
] ]

0
backend/views/order/_form.php

0
backend/views/order/_search.php

0
backend/views/order/create.php

0
backend/views/order/index.php

0
backend/views/order/update.php

0
backend/views/order/view.php

44
backend/views/shop-category/_form.php

@ -1,44 +0,0 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\ars\ShopCategory */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="shop-category-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'pid')->textInput() ?>
<?= $form->field($model, 'goods_count')->textInput() ?>
<?= $form->field($model, 'keywords')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'desc')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'sort_order')->textInput() ?>
<?= $form->field($model, 'icon_type')->textInput() ?>
<?= $form->field($model, 'icon')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'filter_attr')->textarea(['rows' => 6]) ?>
<?= $form->field($model, 'is_show')->textInput() ?>
<?= $form->field($model, 'is_delete')->textInput() ?>
<div class="form-group">
<?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>
<?= Html::a('返回', ['index'], ['class' => 'btn btn-info']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

0
backend/views/site/error.php

0
backend/views/site/index.php

0
backend/views/site/login.php

0
backend/views/site/test.php

47
backend/views/supplier/_search.php

@ -1,47 +0,0 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use \blobt\widgets\DateRangePicker;
/* @var $this yii\web\View */
/* @var $model common\models\searchs\SupplierSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
'validateOnType' => true,
]);
?>
<div class="col-sm-12">
<div class="dataTables_filter">
<?= $form->field($model, 'id', [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "检索ID",
"class" => "form-control",
],
"errorOptions" => [
"class" => "error-tips"
]
])
?>
<?= $form->field($model, "created_at_range", [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "创建时间",
],
"errorOptions" => [
"class" => "error-tips"
]
])->widget(DateRangePicker::className());
?>
<div class="form-group">
<?= Html::submitButton('<i class="fa fa-filter"></i>', ['class' => 'btn btn-default']) ?>
<?= Html::resetButton('<i class="fa fa-eraser"></i>', ['class' => 'btn btn-default']) ?>
</div>
</div>
</div>
<?php ActiveForm::end(); ?>

BIN
backend/web/uploads/xls/15738696921690.jpg

Before

Width: 1024  |  Height: 759  |  Size: 159 KiB

2
common/models/ars/Address.php

@ -36,6 +36,7 @@ class Address extends \yii\db\ActiveRecord
public function rules() public function rules()
{ {
return [ return [
[['user_id', 'consignee', 'phone', 'address'], 'required'],
[['user_id', 'status'], 'integer'], [['user_id', 'status'], 'integer'],
[['address'], 'string'], [['address'], 'string'],
[['consignee', 'phone'], 'string', 'max' => 20], [['consignee', 'phone'], 'string', 'max' => 20],
@ -63,6 +64,7 @@ class Address extends \yii\db\ActiveRecord
]; ];
} }
/** /**
* @author linyao * @author linyao
* @email 602604991@qq.com * @email 602604991@qq.com

2
common/models/ars/AfterSale.php

@ -42,6 +42,7 @@ class AfterSale extends \yii\db\ActiveRecord
public function rules() public function rules()
{ {
return [ return [
[['operator_id', 'user_id', 'amount'], 'required'],
[['operator_id', 'user_id', 'order_goods_id', 'count', 'amount', 'type', 'reason', 'applyed_at', 'dealed_at', 'finished_at'], 'integer'], [['operator_id', 'user_id', 'order_goods_id', 'count', 'amount', 'type', 'reason', 'applyed_at', 'dealed_at', 'finished_at'], 'integer'],
[['description', 'remarks'], 'string'], [['description', 'remarks'], 'string'],
[['wx_refund_id', 'after_sale_sn'], 'string', 'max' => 64], [['wx_refund_id', 'after_sale_sn'], 'string', 'max' => 64],
@ -75,4 +76,5 @@ class AfterSale extends \yii\db\ActiveRecord
]; ];
} }
} }

1
common/models/ars/Area.php

@ -47,4 +47,5 @@ class Area extends \yii\db\ActiveRecord
]; ];
} }
} }

2
common/models/ars/Cart.php

@ -35,6 +35,7 @@ class Cart extends \yii\db\ActiveRecord
public function rules() public function rules()
{ {
return [ return [
[['user_id', 'goods_id', 'goods_name', 'sku_id'], 'required'],
[['user_id', 'goods_id', 'goods_img', 'goods_price', 'sku_id', 'goods_count'], 'integer'], [['user_id', 'goods_id', 'goods_img', 'goods_price', 'sku_id', 'goods_count'], 'integer'],
[['goods_name'], 'string', 'max' => 120], [['goods_name'], 'string', 'max' => 120],
]; ];
@ -59,6 +60,7 @@ class Cart extends \yii\db\ActiveRecord
]; ];
} }
/** /**
* @author linyao * @author linyao
* @email 602604991@qq.com * @email 602604991@qq.com

1
common/models/ars/City.php

@ -47,4 +47,5 @@ class City extends \yii\db\ActiveRecord
]; ];
} }
} }

2
common/models/ars/Collection.php

@ -30,6 +30,7 @@ class Collection extends \yii\db\ActiveRecord
public function rules() public function rules()
{ {
return [ return [
[['user_id', 'goods_id'], 'required'],
[['user_id', 'goods_id'], 'integer'], [['user_id', 'goods_id'], 'integer'],
]; ];
} }
@ -48,6 +49,7 @@ class Collection extends \yii\db\ActiveRecord
]; ];
} }
/** /**
* @author linyao * @author linyao
* @email 602604991@qq.com * @email 602604991@qq.com

2
common/models/ars/Comment.php

@ -33,6 +33,7 @@ class Comment extends \yii\db\ActiveRecord
public function rules() public function rules()
{ {
return [ return [
[['user_id'], 'required'],
[['user_id', 'order_goods_id', 'star', 'status'], 'integer'], [['user_id', 'order_goods_id', 'star', 'status'], 'integer'],
[['content'], 'string'], [['content'], 'string'],
]; ];
@ -55,6 +56,7 @@ class Comment extends \yii\db\ActiveRecord
]; ];
} }
/** /**
* @author linyao * @author linyao
* @email 602604991@qq.com * @email 602604991@qq.com

0
common/models/ars/Config.php

2
common/models/ars/Delivery.php

@ -36,6 +36,7 @@ class Delivery extends \yii\db\ActiveRecord
{ {
return [ return [
[['order_id', 'type', 'status'], 'integer'], [['order_id', 'type', 'status'], 'integer'],
[['shipping_id'], 'required'],
[['goods', 'decription'], 'string'], [['goods', 'decription'], 'string'],
[['shipping_name'], 'string', 'max' => 50], [['shipping_name'], 'string', 'max' => 50],
[['shipping_id'], 'string', 'max' => 10], [['shipping_id'], 'string', 'max' => 10],
@ -61,6 +62,7 @@ class Delivery extends \yii\db\ActiveRecord
]; ];
} }
/** /**
* @author linyao * @author linyao
* @email 602604991@qq.com * @email 602604991@qq.com

2
common/models/ars/ExpressTemplate.php

@ -40,6 +40,7 @@ class ExpressTemplate extends \yii\db\ActiveRecord
public function rules() public function rules()
{ {
return [ return [
[['name'], 'required'],
[['province', 'city', 'area', 'taking_site'], 'string'], [['province', 'city', 'area', 'taking_site'], 'string'],
[['billing_type', 'extra_weight_type', 'exemption_type', 'basic_price', 'extra_price', 'exemption_amount', 'support_taking'], 'integer'], [['billing_type', 'extra_weight_type', 'exemption_type', 'basic_price', 'extra_price', 'exemption_amount', 'support_taking'], 'integer'],
[['name'], 'string', 'max' => 255], [['name'], 'string', 'max' => 255],
@ -70,6 +71,7 @@ class ExpressTemplate extends \yii\db\ActiveRecord
]; ];
} }
/** /**
* @author linyao * @author linyao
* @email 602604991@qq.com * @email 602604991@qq.com

8
common/models/ars/File.php

@ -22,6 +22,13 @@ use yii\behaviors\TimestampBehavior;
*/ */
class File extends \yii\db\ActiveRecord class File extends \yii\db\ActiveRecord
{ {
//own_type
const OWN_TYPE_GOODS_INDEX = 1;//商品首页
const OWN_TYPE_GOODS_DETAILS = 2;//商品详情
const OWN_TYPE_CATEGORY_ICON = 3;//类目图标
//is_delete
const IS_DELETE_YES = 1;//已删除
const IS_DELETE_NO = 0;//未删除
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -62,6 +69,7 @@ class File extends \yii\db\ActiveRecord
]; ];
} }
/** /**
* @author linyao * @author linyao
* @email 602604991@qq.com * @email 602604991@qq.com

2
common/models/ars/Order.php

@ -51,6 +51,7 @@ class Order extends \yii\db\ActiveRecord
public function rules() public function rules()
{ {
return [ return [
[['user_id'], 'required'],
[['user_id', 'status', 'type', 'goods_count', 'goods_amount', 'shipping_amount', 'shipping_type', 'taking_site', 'pay_type', 'pay_at', 'payment_amount', 'receivables', 'discount_amount'], 'integer'], [['user_id', 'status', 'type', 'goods_count', 'goods_amount', 'shipping_amount', 'shipping_type', 'taking_site', 'pay_type', 'pay_at', 'payment_amount', 'receivables', 'discount_amount'], 'integer'],
[['discount_decription'], 'string'], [['discount_decription'], 'string'],
[['order_sn', 'invoice_id'], 'string', 'max' => 64], [['order_sn', 'invoice_id'], 'string', 'max' => 64],
@ -96,6 +97,7 @@ class Order extends \yii\db\ActiveRecord
]; ];
} }
/** /**
* @author linyao * @author linyao
* @email 602604991@qq.com * @email 602604991@qq.com

2
common/models/ars/OrderGoods.php

@ -36,6 +36,7 @@ class OrderGoods extends \yii\db\ActiveRecord
public function rules() public function rules()
{ {
return [ return [
[['order_id', 'goods_id'], 'required'],
[['order_id', 'goods_id', 'goods_img', 'goods_count', 'price', 'market_price'], 'integer'], [['order_id', 'goods_id', 'goods_img', 'goods_count', 'price', 'market_price'], 'integer'],
[['goods_name', 'sku_value'], 'string', 'max' => 120], [['goods_name', 'sku_value'], 'string', 'max' => 120],
]; ];
@ -61,6 +62,7 @@ class OrderGoods extends \yii\db\ActiveRecord
]; ];
} }
/** /**
* @author linyao * @author linyao
* @email 602604991@qq.com * @email 602604991@qq.com

1
common/models/ars/PaymentLog.php

@ -61,6 +61,7 @@ class PaymentLog extends \yii\db\ActiveRecord
]; ];
} }
/** /**
* @author linyao * @author linyao
* @email 602604991@qq.com * @email 602604991@qq.com

1
common/models/ars/Province.php

@ -45,4 +45,5 @@ class Province extends \yii\db\ActiveRecord
]; ];
} }
} }

1
common/models/ars/RefundLog.php

@ -67,4 +67,5 @@ class RefundLog extends \yii\db\ActiveRecord
]; ];
} }
} }

2
common/models/ars/SearchHistory.php

@ -33,6 +33,7 @@ class SearchHistory extends \yii\db\ActiveRecord
public function rules() public function rules()
{ {
return [ return [
[['user_id'], 'required'],
[['user_id', 'count', 'status', 'type'], 'integer'], [['user_id', 'count', 'status', 'type'], 'integer'],
[['keyword'], 'string', 'max' => 255], [['keyword'], 'string', 'max' => 255],
]; ];
@ -55,6 +56,7 @@ class SearchHistory extends \yii\db\ActiveRecord
]; ];
} }
/** /**
* @author linyao * @author linyao
* @email 602604991@qq.com * @email 602604991@qq.com

2
common/models/ars/TakingSite.php

@ -34,6 +34,7 @@ class TakingSite extends \yii\db\ActiveRecord
public function rules() public function rules()
{ {
return [ return [
[['name'], 'required'],
[['address'], 'string'], [['address'], 'string'],
[['is_default'], 'integer'], [['is_default'], 'integer'],
[['name'], 'string', 'max' => 120], [['name'], 'string', 'max' => 120],
@ -59,6 +60,7 @@ class TakingSite extends \yii\db\ActiveRecord
]; ];
} }
/** /**
* @author linyao * @author linyao
* @email 602604991@qq.com * @email 602604991@qq.com

2
common/models/ars/TemFile.php

@ -19,6 +19,7 @@ use yii\behaviors\TimestampBehavior;
*/ */
class TemFile extends \yii\db\ActiveRecord class TemFile extends \yii\db\ActiveRecord
{ {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -56,6 +57,7 @@ class TemFile extends \yii\db\ActiveRecord
]; ];
} }
/** /**
* @author linyao * @author linyao
* @email 602604991@qq.com * @email 602604991@qq.com

0
common/models/searchs/OrderSearch.php

5
composer.json

@ -35,5 +35,10 @@
"yiisoft/yii2-debug": "^2.0@dev", "yiisoft/yii2-debug": "^2.0@dev",
"kint-php/kint": "dev-master", "kint-php/kint": "dev-master",
"yiisoft/yii2-gii": "^2.0@dev" "yiisoft/yii2-gii": "^2.0@dev"
},
"autoload": {
"psr-4": {
"antgoods\\goods\\": "vendor/antgoods/goods/src"
}
} }
} }

2
console/controllers/InitController.php

@ -63,7 +63,7 @@ class InitController extends Controller {
* TODO没有完善 * TODO没有完善
* 清空数据库 * 清空数据库
*/ */
public function clearDb() {
public function actionClearDb() {
Yii::$app->db->createCommand("SET FOREIGN_KEY_CHECKS = 0;")->execute(); Yii::$app->db->createCommand("SET FOREIGN_KEY_CHECKS = 0;")->execute();
$dbname = explode('=', explode(';', Yii::$app->db->dsn)[1])[1]; $dbname = explode('=', explode(';', Yii::$app->db->dsn)[1])[1];
$sql = "SELECT CONCAT('drop table ',table_name,';') FROM information_schema.`TABLES` WHERE table_schema='{$dbname}';"; $sql = "SELECT CONCAT('drop table ',table_name,';') FROM information_schema.`TABLES` WHERE table_schema='{$dbname}';";

0
console/migrations/m130524_201442_init.php

0
console/migrations/m140506_102106_rbac_init.php

0
console/migrations/m170907_052038_rbac_add_index_on_auth_assignment_user_id.php

0
console/migrations/m180523_151638_rbac_updates_indexes_without_prefix.php

0
console/migrations/m190124_110200_add_verification_token_column_to_user_table.php

0
console/migrations/m190802_072830_add_category.php

0
console/migrations/m191111_101658_create_table_area.php

0
console/migrations/m191111_102644_create_table_province.php

0
console/migrations/m191111_102730_create_table_city.php

8
console/migrations/m191111_102925_create_table_cart.php

@ -15,12 +15,12 @@ class m191111_102925_create_table_cart extends Migration
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="购物车表"'; $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="购物车表"';
$this->createTable('ats_cart', [ $this->createTable('ats_cart', [
'id' => $this->primaryKey(), 'id' => $this->primaryKey(),
'user_id'=>$this->integer(11)->defaultValue(null)->comment('用户id'),
'goods_id'=>$this->integer(11)->defaultValue(null)->comment('商品id'),
'goods_name'=>$this->string(120)->defaultValue(null)->comment('商品名称'),
'user_id'=>$this->integer(11)->notNull()->comment('用户id'),
'goods_id'=>$this->integer(11)->notNull()->comment('商品id'),
'goods_name'=>$this->string(120)->notNull()->comment('商品名称'),
'goods_img'=>$this->integer(11)->defaultValue(null)->comment('商品图片'), 'goods_img'=>$this->integer(11)->defaultValue(null)->comment('商品图片'),
'goods_price'=>$this->integer(20)->defaultValue(null)->comment('商品售价'), 'goods_price'=>$this->integer(20)->defaultValue(null)->comment('商品售价'),
'sku_id'=>$this->integer(11)->defaultValue(null)->comment('商品sku的id'),
'sku_id'=>$this->integer(11)->notNull()->comment('商品sku的id'),
'goods_count'=>$this->integer(11)->defaultValue(null)->comment('商品数量'), 'goods_count'=>$this->integer(11)->defaultValue(null)->comment('商品数量'),
'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'), 'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'),
'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'), 'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'),

8
console/migrations/m191111_112559_create_table_address.php

@ -15,13 +15,13 @@ class m191111_112559_create_table_address extends Migration
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="地址表"'; $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="地址表"';
$this->createTable('ats_address', [ $this->createTable('ats_address', [
'id' => $this->primaryKey(), 'id' => $this->primaryKey(),
'user_id'=>$this->integer(11)->defaultValue(null)->comment('用户id'),
'consignee'=>$this->string(20)->defaultValue(null)->comment('收件人'),
'phone'=>$this->string(20)->defaultValue(null)->comment('电话'),
'user_id'=>$this->integer(11)->notNull()->comment('用户id'),
'consignee'=>$this->string(20)->notNull()->comment('收件人'),
'phone'=>$this->string(20)->notNull()->comment('电话'),
'province'=>$this->string(10)->defaultValue(null)->comment('省份'), 'province'=>$this->string(10)->defaultValue(null)->comment('省份'),
'city'=>$this->string(10)->defaultValue(null)->comment('城市'), 'city'=>$this->string(10)->defaultValue(null)->comment('城市'),
'area'=>$this->string(10)->defaultValue(null)->comment('区域'), 'area'=>$this->string(10)->defaultValue(null)->comment('区域'),
'address'=>$this->text()->comment('详细地址'),
'address'=>$this->text()->notNull()->comment('详细地址'),
'status'=>$this->tinyInteger(1)->defaultValue(0)->comment('状态,0-默认值 1-默认地址'), 'status'=>$this->tinyInteger(1)->defaultValue(0)->comment('状态,0-默认值 1-默认地址'),
'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'), 'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'),
'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'), 'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'),

6
console/migrations/m191111_113455_create_table_after_sale.php

@ -15,13 +15,13 @@ class m191111_113455_create_table_after_sale extends Migration
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="售后表"'; $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="售后表"';
$this->createTable('ats_after_sale', [ $this->createTable('ats_after_sale', [
'id' => $this->primaryKey(), 'id' => $this->primaryKey(),
'operator_id'=>$this->integer(11)->defaultValue(null)->comment('操作者'),
'user_id'=>$this->integer(11)->defaultValue(null)->comment('用户id'),
'operator_id'=>$this->integer(11)->notNull()->comment('操作者'),
'user_id'=>$this->integer(11)->notNull()->comment('用户id'),
'wx_refund_id'=>$this->string(64)->defaultValue(null)->comment('微信退款单号'), 'wx_refund_id'=>$this->string(64)->defaultValue(null)->comment('微信退款单号'),
'after_sale_sn'=>$this->string(64)->defaultValue(null)->comment('售后单号'), 'after_sale_sn'=>$this->string(64)->defaultValue(null)->comment('售后单号'),
'order_goods_id'=>$this->integer(11)->defaultValue(null)->comment('订单商品id'), 'order_goods_id'=>$this->integer(11)->defaultValue(null)->comment('订单商品id'),
'count'=>$this->integer(11)->defaultValue(null)->comment('退换货的商品数量'), 'count'=>$this->integer(11)->defaultValue(null)->comment('退换货的商品数量'),
'amount'=>$this->integer(20)->defaultValue(null)->comment('退货时实际退的金额'),
'amount'=>$this->integer(20)->notNull()->comment('退货时实际退的金额'),
'type'=>$this->tinyInteger(1)->defaultValue(0)->comment('类型'), 'type'=>$this->tinyInteger(1)->defaultValue(0)->comment('类型'),
'reason'=>$this->smallInteger(2)->defaultValue(0)->comment('退换货理由'), 'reason'=>$this->smallInteger(2)->defaultValue(0)->comment('退换货理由'),
'description'=>$this->text()->comment('描述'), 'description'=>$this->text()->comment('描述'),

2
console/migrations/m191112_005106_create_table_search_history.php

@ -15,7 +15,7 @@ class m191112_005106_create_table_search_history extends Migration
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="搜索记录表"'; $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="搜索记录表"';
$this->createTable('ats_search_history', [ $this->createTable('ats_search_history', [
'id' => $this->primaryKey(), 'id' => $this->primaryKey(),
'user_id'=>$this->integer(11)->defaultValue(null)->comment('用户id'),
'user_id'=>$this->integer(11)->notNull()->comment('用户id'),
'keyword'=>$this->string(255)->defaultValue(null)->comment('关键字'), 'keyword'=>$this->string(255)->defaultValue(null)->comment('关键字'),
'count'=>$this->integer(10)->defaultValue(null)->comment('次数'), 'count'=>$this->integer(10)->defaultValue(null)->comment('次数'),
'status'=>$this->tinyInteger(1)->defaultValue(0)->comment('状态'), 'status'=>$this->tinyInteger(1)->defaultValue(0)->comment('状态'),

4
console/migrations/m191112_005545_create_table_collection.php

@ -15,8 +15,8 @@ class m191112_005545_create_table_collection extends Migration
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="收藏表"'; $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="收藏表"';
$this->createTable('ats_collection', [ $this->createTable('ats_collection', [
'id' => $this->primaryKey(), 'id' => $this->primaryKey(),
'user_id'=>$this->integer(11)->defaultValue(null)->comment('用户id'),
'goods_id'=>$this->integer(11)->defaultValue(null)->comment('商品id'),
'user_id'=>$this->integer(11)->notNull()->comment('用户id'),
'goods_id'=>$this->integer(11)->notNull()->comment('商品id'),
'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'), 'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'),
'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'), 'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'),
],$tableOptions); ],$tableOptions);

2
console/migrations/m191112_005702_create_table_comment.php

@ -15,7 +15,7 @@ class m191112_005702_create_table_comment extends Migration
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="评论记录表"'; $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="评论记录表"';
$this->createTable('ats_comment', [ $this->createTable('ats_comment', [
'id' => $this->primaryKey(), 'id' => $this->primaryKey(),
'user_id'=>$this->integer(11)->defaultValue(null)->comment('用户id'),
'user_id'=>$this->integer(11)->notNull()->comment('用户id'),
'order_goods_id'=>$this->integer(11)->defaultValue(null)->comment('订单详情商品id'), 'order_goods_id'=>$this->integer(11)->defaultValue(null)->comment('订单详情商品id'),
'star'=>$this->integer(11)->defaultValue(null)->comment('星级'), 'star'=>$this->integer(11)->defaultValue(null)->comment('星级'),
'content'=>$this->text()->comment('评论内容'), 'content'=>$this->text()->comment('评论内容'),

2
console/migrations/m191112_010421_create_table_order.php

@ -15,7 +15,7 @@ class m191112_010421_create_table_order extends Migration
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="订单表"'; $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="订单表"';
$this->createTable('ats_order', [ $this->createTable('ats_order', [
'id' => $this->primaryKey(), 'id' => $this->primaryKey(),
'user_id'=>$this->integer(11)->defaultValue(null)->comment('用户id'),
'user_id'=>$this->integer(11)->notNull()->comment('用户id'),
'order_sn'=>$this->string(64)->defaultValue(null)->comment('订单号'), 'order_sn'=>$this->string(64)->defaultValue(null)->comment('订单号'),
'invoice_id'=>$this->string(64)->defaultValue(null)->comment('发票单号'), 'invoice_id'=>$this->string(64)->defaultValue(null)->comment('发票单号'),
'status'=>$this->tinyInteger(2)->defaultValue(0)->comment('状态'), 'status'=>$this->tinyInteger(2)->defaultValue(0)->comment('状态'),

4
console/migrations/m191112_011517_create_table_order_goods.php

@ -15,8 +15,8 @@ class m191112_011517_create_table_order_goods extends Migration
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="订单商品表"'; $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="订单商品表"';
$this->createTable('ats_order_goods', [ $this->createTable('ats_order_goods', [
'id' => $this->primaryKey(), 'id' => $this->primaryKey(),
'order_id'=>$this->integer(11)->defaultValue(null)->comment('订单id'),
'goods_id'=>$this->integer(11)->defaultValue(null)->comment('商品id'),
'order_id'=>$this->integer(11)->notNull()->comment('订单id'),
'goods_id'=>$this->integer(11)->notNull()->comment('商品id'),
'goods_img'=>$this->integer(11)->defaultValue(null)->comment('商品图片'), 'goods_img'=>$this->integer(11)->defaultValue(null)->comment('商品图片'),
'goods_name'=>$this->string(120)->defaultValue(null)->comment('商品名称'), 'goods_name'=>$this->string(120)->defaultValue(null)->comment('商品名称'),
'goods_count'=>$this->integer(11)->defaultValue(null)->comment('商品数量'), 'goods_count'=>$this->integer(11)->defaultValue(null)->comment('商品数量'),

2
console/migrations/m191112_012449_create_table_taking_site.php

@ -15,7 +15,7 @@ class m191112_012449_create_table_taking_site extends Migration
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="自提地点表"'; $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="自提地点表"';
$this->createTable('ats_taking_site', [ $this->createTable('ats_taking_site', [
'id' => $this->primaryKey(), 'id' => $this->primaryKey(),
'name'=>$this->string(120)->defaultValue(null)->comment('名称'),
'name'=>$this->string(120)->notNull()->comment('名称'),
'province'=>$this->string(10)->defaultValue(null)->comment('省份'), 'province'=>$this->string(10)->defaultValue(null)->comment('省份'),
'city'=>$this->string(10)->defaultValue(null)->comment('城市'), 'city'=>$this->string(10)->defaultValue(null)->comment('城市'),
'area'=>$this->string(10)->defaultValue(null)->comment('区域'), 'area'=>$this->string(10)->defaultValue(null)->comment('区域'),

2
console/migrations/m191112_014508_create_table_express_template.php

@ -15,7 +15,7 @@ class m191112_014508_create_table_express_template extends Migration
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="配送情况设置表"'; $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="配送情况设置表"';
$this->createTable('ats_express_template', [ $this->createTable('ats_express_template', [
'id' => $this->primaryKey(), 'id' => $this->primaryKey(),
'name'=>$this->string(255)->defaultValue(null)->comment('名称'),
'name'=>$this->string(255)->notNull()->comment('名称'),
'province'=>$this->text()->comment('省份'), 'province'=>$this->text()->comment('省份'),
'city'=>$this->text()->comment('城市'), 'city'=>$this->text()->comment('城市'),
'area'=>$this->text()->comment('区域'), 'area'=>$this->text()->comment('区域'),

2
console/migrations/m191112_015939_create_table_delivery.php

@ -17,7 +17,7 @@ class m191112_015939_create_table_delivery extends Migration
'id' => $this->primaryKey(), 'id' => $this->primaryKey(),
'order_id'=>$this->integer(11)->defaultValue(null)->comment('订单id'), 'order_id'=>$this->integer(11)->defaultValue(null)->comment('订单id'),
'shipping_name'=>$this->string(50)->defaultValue(null)->comment('货流名称'), 'shipping_name'=>$this->string(50)->defaultValue(null)->comment('货流名称'),
'shipping_id'=>$this->string(10)->defaultValue(null)->comment('运货单位'),
'shipping_id'=>$this->string(10)->notNull()->comment('运货单位'),
'type'=>$this->tinyInteger(1)->defaultValue(0)->comment('类型'), 'type'=>$this->tinyInteger(1)->defaultValue(0)->comment('类型'),
'goods'=>$this->text()->comment('商品'), 'goods'=>$this->text()->comment('商品'),
'status'=>$this->tinyInteger(1)->defaultValue(0)->comment('状态'), 'status'=>$this->tinyInteger(1)->defaultValue(0)->comment('状态'),

0
console/migrations/m191112_020830_create_table_payment_log.php

0
console/migrations/m191112_021528_create_table_refund_log.php

0
console/migrations/m191112_022131_create_table_file.php

0
console/migrations/m191112_022532_create_table_tem_file.php

0
console/migrations/schema-mysql.sql

0
console/migrations/sql/add_category.sql

0
console/migrations/sql/area.sql

0
console/migrations/sql/city.sql

0
console/migrations/sql/province.sql

8
environments/skeleton/backend/config/main-local.php

@ -22,16 +22,16 @@ if (!YII_ENV_TEST) {
'allowedIPs' => ['127.0.0.1'], 'allowedIPs' => ['127.0.0.1'],
'generators' => [ 'generators' => [
'crud' => [ 'crud' => [
'class' => 'blobt\generators\crud\Generator',
'class' => 'iron\generators\crud\Generator',
'templates' => [ 'templates' => [
'blobtCrud' => '@blobt/generators/crud/default', 'blobtCrud' => '@blobt/generators/crud/default',
'linyaoCrud' => '@linyao/generators/crud/default',
'ironCrud' => '@iron/generators/crud/default',
] ]
], ],
'model' => [ 'model' => [
'class' => 'linyao\generators\model\Generator',
'class' => 'iron\generators\model\Generator',
'templates' => [ 'templates' => [
'linyaoModel' => '@linyao/generators/model/default',
'ironModel' => '@iron/generators/model/default',
] ]
] ]
], ],

0
environments/skeleton/backend/config/params-local.php

14
vendor/antgoods/goods/AutoloadExample.php

@ -0,0 +1,14 @@
<?php
namespace antgoods\goods;
/**
* This is just an example.
*/
class AutoloadExample extends \yii\base\Widget
{
public function run()
{
return "Hello!";
}
}

31
vendor/antgoods/goods/README.md

@ -0,0 +1,31 @@
商品模块
====
ant基础模块之一
Installation
------------
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require --prefer-dist antgoods/goods "*"
```
or add
```
"antgoods/goods": "*"
```
to the require section of your `composer.json` file.
Usage
-----
Once the extension is installed, simply use it in your code by :
```php
<?= \antgoods\goods\AutoloadExample::widget(); ?>```

21
vendor/antgoods/goods/composer.json

@ -0,0 +1,21 @@
{
"name": "antgoods/goods",
"description": "ant基础模块之一",
"type": "yii2-extension",
"keywords": ["goods"],
"license": "MIT",
"authors": [
{
"name": "linyao",
"email": "linyaostalker@gmail.com"
}
],
"require": {
"yiisoft/yii2": "~2.0.0"
},
"autoload": {
"psr-4": {
"antgoods\\goods\\": ""
}
}
}

28
vendor/antgoods/goods/src/Module.php

@ -0,0 +1,28 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/13
* Time: 11:47
*/
namespace antgoods\goods;
class Module extends \yii\base\Module
{
/**
* {@inheritdoc}
*/
public $controllerNamespace = 'antgoods\goods\controllers';
/**
* {@inheritdoc}
*/
public function init()
{
parent::init();
// custom initialization code goes here
}
}

backend/controllers/AttributeController.php → vendor/antgoods/goods/src/controllers/AttributeController.php

backend/controllers/BrandController.php → vendor/antgoods/goods/src/controllers/BrandController.php

276
vendor/antgoods/goods/src/controllers/CategoryController.php

@ -0,0 +1,276 @@
<?php
namespace antgoods\goods\controllers;
use antgoods\goods\logic\goods\GoodsManager;
use common\models\ars\File;
use Yii;
use antgoods\goods\models\ars\Category;
use antgoods\goods\models\searchs\CategorySearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* CategoryController implements the CRUD actions for Category model.
*/
class CategoryController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
public function actions()
{
return [
'upload' => [
'class' => 'iron\actions\UploadAction',
'path' => 'xls/',
'maxSize' => 20480,
]
];
}
/**
* Lists all Category models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new CategorySearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'columns' => $searchModel->columns()
]);
}
/**
* Displays a single Category model.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Category model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Category();
if ($model->load(Yii::$app->request->post())) {
//类目图片上传保存处理
$icon_image_id_str = $model->iconImageId;
$model->save();
$goods_manager = new GoodsManager();
$save_icon_image_res = $goods_manager->saveFile(explode(',', $icon_image_id_str), $model, [], File::OWN_TYPE_CATEGORY_ICON);
if($save_icon_image_res['status']){
$model->icon = $save_icon_image_res['first_file_id'];
$model->save();
}
return $this->redirect('index');
}
return $this->render('create', [
'model' => $model,
]);
}
/**
* Updates an existing Category model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
$model->iconImageId = $model->icon;
//记录已保存的类目图片id,用于修改
$icon_image_old_id_arr = $model->icon;
if ($model->load(Yii::$app->request->post())) {
//类目图片上传保存处理
$icon_image_id_str = $model->iconImageId;
$model->save();
$goods_manager = new GoodsManager();
$save_icon_image_res = $goods_manager->saveFile(explode(',', $icon_image_id_str), $model, explode(',', $icon_image_old_id_arr), File::OWN_TYPE_CATEGORY_ICON);
if($save_icon_image_res['status'] && $save_icon_image_res['first_file_id'] !== 0){
$model->icon = $save_icon_image_res['first_file_id'];
$model->save();
}
return $this->redirect('index');
}
return $this->render('update', [
'model' => $model,
]);
}
/**
* Deletes an existing Category model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionDelete($id)
{
$model = $this->findModel($id);
$model->is_delete = Category::IS_DELETE_YES;
$model->save();
return $this->redirect(['index']);
}
/**
* Finds the Category model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Category the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Category::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
/**
* @author iron
* 文件导出
*/
public function actionExport()
{
$searchModel = new CategorySearch();
$params = Yii::$app->request->queryParams;
if ($params['page-type'] == 'all') {
$dataProvider = $searchModel->allData($params);
} else {
$dataProvider = $searchModel->search($params);
}
\iron\widget\Excel::export([
'models' => $dataProvider->getModels(),
'format' => 'Xlsx',
'asAttachment' => true,
'fileName' =>'Categories'. "-" .date('Y-m-d H/i/s', time()),
'columns' => $searchModel->columns()
]);
}
/**
* 处理文件上传成功后回调保存到临时文件表中,并返回临时文件id
*/
public function actionSaveFile()
{
if(!class_exists('\common\models\ars\TemFile') || !class_exists('\backend\logic\file\FileManager')){
return '';
}
$data = Yii::$app->request->get('data');
$file_name = Yii::$app->request->get('fileName')[0];
if ($data['status'] == true) {
$model = new \common\models\ars\TemFile();
$model->user_id = Yii::$app->user->identity->id;
$model->name = $file_name;
$file_manager = new \backend\logic\file\FileManager();
$type_res = $file_manager->searchType(\backend\logic\file\FileManager::$extension, pathinfo($data['path'])['extension']);
if ($type_res['status']) {
$model->type = $type_res['type'];
}
$model->alias = $data['alias'];
$model->path = $data['path'];
$model->save();
return $model->id;
}
}
/**
* @return string
* 点击删除按钮时同时删除字符串中的id
*/
public function actionImgIdDel()
{
//判断该类是否存在
if(!class_exists('\common\models\ars\TemFile') || !class_exists('\common\models\ars\File')){
return '';
}
$img_id = Yii::$app->request->get('imgid');
$img_id_arr = explode(',', $img_id);
if(isset(Yii::$app->request->get('data')['alias'])) {
$alias = Yii::$app->request->get('data')['alias'];
$tem_file = \common\models\ars\TemFile::findOne(['alias' => $alias]);
if ($tem_file) {
$img_id_arr = array_diff($img_id_arr, [$tem_file->id]);
}
}else{
foreach (Yii::$app->request->get() as $key => $value) {
$tem_file = \common\models\ars\File::findOne(['alias' => $value]);
if ($tem_file) {
$img_id_arr = array_diff($img_id_arr, [$tem_file->id]);
}
}
}
$img_id_str = implode(',', $img_id_arr);
return $img_id_str;
}
/**
* @return bool|false|string
* 加载已有的文件
*/
public function actionImageFile()
{
//判断该类是否存在
if(!class_exists('\common\models\ars\File')){
return false;
}
$file_id_str = Yii::$app->request->get('fileidstr');
$file_id_arr = explode(',', $file_id_str);
$data = \common\models\ars\File::find()->where(['id' => $file_id_arr])->all();
$res = array();
if($data) {
$i = 0;
foreach ($data as $key => $value) {
$res[$i]['name'] = $value->alias;
$res[$i]['path'] = Yii::$app->request->hostInfo . '/' . $value->path;
$res[$i]['size'] = filesize($value->path);
$i++;
}
}
return json_encode($res);
}
}

282
vendor/antgoods/goods/src/controllers/GoodsController.php

@ -0,0 +1,282 @@
<?php
namespace antgoods\goods\controllers;
use common\models\ars\TemFile;
use MongoDB\Driver\Manager;
use Yii;
use antgoods\goods\models\ars\Goods;
use antgoods\goods\models\searchs\GoodsSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use antgoods\goods\logic\goods\GoodsManager;
use common\models\ars\File;
/**
* GoodsController implements the CRUD actions for Goods model.
*/
class GoodsController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
public function actions()
{
return [
'upload' => [
'class' => 'iron\actions\UploadAction',
'path' => 'xls/',
'maxSize' => 20480,
]
];
}
/**
* Lists all Goods models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new GoodsSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'columns' => $searchModel->columns()
]);
}
/**
* Displays a single Goods model.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Goods model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Goods();
if ($model->load(Yii::$app->request->post())) {
//商品封面图和商品详情图上传保存处理
$cover_image_id_str = $model->coverImageId;
$detail_image_id_str = $model->detailImageId;
$model->save();
$goods_manager = new GoodsManager();
$save_cover_image_res = $goods_manager->saveFile(explode(',', $cover_image_id_str), $model);
$save_detail_image_res = $goods_manager->saveFile(explode(',', $detail_image_id_str), $model, [], File::OWN_TYPE_GOODS_DETAILS);
if($save_cover_image_res['status'] && $save_detail_image_res['status']){
$model->image = $save_cover_image_res['first_file_id'];
$model->save();
}
return $this->redirect('index');
}
return $this->render('create', [
'model' => $model,
]);
}
/**
* Updates an existing Goods model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
$model->coverImageId = $model->image;
$model->detailImageId = implode(',', File::find()->select('id')->where(['is_delete' => File::IS_DELETE_NO, 'own_id' => $model->id, 'own_type' => File::OWN_TYPE_GOODS_DETAILS])->column());
//记录已保存的商品图片id,用于修改
$cover_image_old_id_arr = $model->image;
$detail_image_old_id_arr = $model->detailImageId;
if ($model->load(Yii::$app->request->post())) {
//商品封面图和商品详情图上传保存处理
$cover_image_id_str = $model->coverImageId;
$detail_image_id_str = $model->detailImageId;
$model->save();
$goods_manager = new GoodsManager();
$save_cover_image_res = $goods_manager->saveFile(explode(',', $cover_image_id_str), $model, explode(',', $cover_image_old_id_arr));
$save_detail_image_res = $goods_manager->saveFile(explode(',', $detail_image_id_str), $model, explode(',', $detail_image_old_id_arr), File::OWN_TYPE_GOODS_DETAILS);
if($save_cover_image_res['status'] && $save_detail_image_res['status'] && $save_cover_image_res['first_file_id'] !== 0){
$model->image = $save_cover_image_res['first_file_id'];
$model->save();
}
return $this->redirect('index');
}
return $this->render('update', [
'model' => $model,
]);
}
/**
* Deletes an existing Goods model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
/**
* Finds the Goods model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Goods the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Goods::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
/**
* @author iron
* 文件导出
*/
public function actionExport()
{
$searchModel = new GoodsSearch();
$params = Yii::$app->request->queryParams;
if ($params['page-type'] == 'all') {
$dataProvider = $searchModel->allData($params);
} else {
$dataProvider = $searchModel->search($params);
}
\iron\widget\Excel::export([
'models' => $dataProvider->getModels(),
'format' => 'Xlsx',
'asAttachment' => true,
'fileName' =>'Goods'. "-" .date('Y-m-d H/i/s', time()),
'columns' => $searchModel->columns()
]);
}
/**
* 处理文件上传成功后回调保存到临时文件表中,并返回临时文件id
*/
public function actionSaveFile()
{
if(!class_exists('\common\models\ars\TemFile') || !class_exists('\backend\logic\file\FileManager')){
return '';
}
$data = Yii::$app->request->get('data');
$file_name = Yii::$app->request->get('fileName')[0];
if ($data['status'] == true) {
$model = new \common\models\ars\TemFile();
$model->user_id = Yii::$app->user->identity->id;
$model->name = $file_name;
$file_manager = new \backend\logic\file\FileManager();
$type_res = $file_manager->searchType(\backend\logic\file\FileManager::$extension, pathinfo($data['path'])['extension']);
if ($type_res['status']) {
$model->type = $type_res['type'];
}
$model->alias = $data['alias'];
$model->path = $data['path'];
$model->save();
return $model->id;
}
}
/**
* @return string
* 点击删除按钮时同时删除字符串中的id
*/
public function actionImgIdDel()
{
//判断该类是否存在
if(!class_exists('\common\models\ars\TemFile') || !class_exists('\common\models\ars\File')){
return '';
}
$img_id = Yii::$app->request->get('imgid');
$img_id_arr = explode(',', $img_id);
if(isset(Yii::$app->request->get('data')['alias'])) {
$alias = Yii::$app->request->get('data')['alias'];
$tem_file = \common\models\ars\TemFile::findOne(['alias' => $alias]);
if ($tem_file) {
$img_id_arr = array_diff($img_id_arr, [$tem_file->id]);
}
}else{
foreach (Yii::$app->request->get() as $key => $value) {
$tem_file = \common\models\ars\File::findOne(['alias' => $value]);
if ($tem_file) {
$img_id_arr = array_diff($img_id_arr, [$tem_file->id]);
}
}
}
$img_id_str = implode(',', $img_id_arr);
return $img_id_str;
}
/**
* @return bool|false|string
* 加载已有的文件
*/
public function actionImageFile()
{
//判断该类是否存在
if(!class_exists('\common\models\ars\File')){
return false;
}
$file_id_str = Yii::$app->request->get('fileidstr');
$file_id_arr = explode(',', $file_id_str);
$data = \common\models\ars\File::find()->where(['id' => $file_id_arr])->all();
$res = array();
if($data) {
$i = 0;
foreach ($data as $key => $value) {
$res[$i]['name'] = $value->alias;
$res[$i]['path'] = Yii::$app->request->hostInfo . '/' . $value->path;
$res[$i]['size'] = filesize($value->path);
$i++;
}
}
return json_encode($res);
}
}

273
vendor/antgoods/goods/src/controllers/ShopcategoryController.php

@ -0,0 +1,273 @@
<?php
namespace antgoods\goods\controllers;
use antgoods\goods\logic\goods\GoodsManager;
use common\models\ars\File;
use Yii;
use antgoods\goods\models\ars\ShopCategory;
use antgoods\goods\models\searchs\ShopCategorySearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* ShopcategoryController implements the CRUD actions for ShopCategory model.
*/
class ShopcategoryController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
public function actions()
{
return [
'upload' => [
'class' => 'iron\actions\UploadAction',
'path' => 'xls/',
'maxSize' => 20480,
]
];
}
/**
* Lists all ShopCategory models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new ShopCategorySearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'columns' => $searchModel->columns()
]);
}
/**
* Displays a single ShopCategory model.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new ShopCategory model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new ShopCategory();
if ($model->load(Yii::$app->request->post())) {
//类目图片上传保存处理
$icon_image_id_str = $model->iconImageId;
$model->save();
$goods_manager = new GoodsManager();
$save_icon_image_res = $goods_manager->saveFile(explode(',', $icon_image_id_str), $model, [], File::OWN_TYPE_CATEGORY_ICON);
if($save_icon_image_res['status']){
$model->icon = $save_icon_image_res['first_file_id'];
$model->save();
}
return $this->redirect('index');
}
return $this->render('create', [
'model' => $model,
]);
}
/**
* Updates an existing ShopCategory model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
$model->iconImageId = $model->icon;
//记录已保存的类目图片id,用于修改
$icon_image_old_id_arr = $model->icon;
if ($model->load(Yii::$app->request->post())) {
//类目图片上传保存处理
$icon_image_id_str = $model->iconImageId;
$model->save();
$goods_manager = new GoodsManager();
$save_icon_image_res = $goods_manager->saveFile(explode(',', $icon_image_id_str), $model, explode(',', $icon_image_old_id_arr), File::OWN_TYPE_CATEGORY_ICON);
if($save_icon_image_res['status'] && $save_icon_image_res['first_file_id'] !== 0){
$model->icon = $save_icon_image_res['first_file_id'];
$model->save();
}
return $this->redirect('index');
}
return $this->render('update', [
'model' => $model,
]);
}
/**
* Deletes an existing ShopCategory model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
/**
* Finds the ShopCategory model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return ShopCategory the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = ShopCategory::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
/**
* @author iron
* 文件导出
*/
public function actionExport()
{
$searchModel = new ShopCategorySearch();
$params = Yii::$app->request->queryParams;
if ($params['page-type'] == 'all') {
$dataProvider = $searchModel->allData($params);
} else {
$dataProvider = $searchModel->search($params);
}
\iron\widget\Excel::export([
'models' => $dataProvider->getModels(),
'format' => 'Xlsx',
'asAttachment' => true,
'fileName' =>'Shop Categories'. "-" .date('Y-m-d H/i/s', time()),
'columns' => $searchModel->columns()
]);
}
/**
* 处理文件上传成功后回调保存到临时文件表中,并返回临时文件id
*/
public function actionSaveFile()
{
if(!class_exists('\common\models\ars\TemFile') || !class_exists('\backend\logic\file\FileManager')){
return '';
}
$data = Yii::$app->request->get('data');
$file_name = Yii::$app->request->get('fileName')[0];
if ($data['status'] == true) {
$model = new \common\models\ars\TemFile();
$model->user_id = Yii::$app->user->identity->id;
$model->name = $file_name;
$file_manager = new \backend\logic\file\FileManager();
$type_res = $file_manager->searchType(\backend\logic\file\FileManager::$extension, pathinfo($data['path'])['extension']);
if ($type_res['status']) {
$model->type = $type_res['type'];
}
$model->alias = $data['alias'];
$model->path = $data['path'];
$model->save();
return $model->id;
}
}
/**
* @return string
* 点击删除按钮时同时删除字符串中的id
*/
public function actionImgIdDel()
{
//判断该类是否存在
if(!class_exists('\common\models\ars\TemFile') || !class_exists('\common\models\ars\File')){
return '';
}
$img_id = Yii::$app->request->get('imgid');
$img_id_arr = explode(',', $img_id);
if(isset(Yii::$app->request->get('data')['alias'])) {
$alias = Yii::$app->request->get('data')['alias'];
$tem_file = \common\models\ars\TemFile::findOne(['alias' => $alias]);
if ($tem_file) {
$img_id_arr = array_diff($img_id_arr, [$tem_file->id]);
}
}else{
foreach (Yii::$app->request->get() as $key => $value) {
$tem_file = \common\models\ars\File::findOne(['alias' => $value]);
if ($tem_file) {
$img_id_arr = array_diff($img_id_arr, [$tem_file->id]);
}
}
}
$img_id_str = implode(',', $img_id_arr);
return $img_id_str;
}
/**
* @return bool|false|string
* 加载已有的文件
*/
public function actionImageFile()
{
//判断该类是否存在
if(!class_exists('\common\models\ars\File')){
return false;
}
$file_id_str = Yii::$app->request->get('fileidstr');
$file_id_arr = explode(',', $file_id_str);
$data = \common\models\ars\File::find()->where(['id' => $file_id_arr])->all();
$res = array();
if($data) {
$i = 0;
foreach ($data as $key => $value) {
$res[$i]['name'] = $value->alias;
$res[$i]['path'] = Yii::$app->request->hostInfo . '/' . $value->path;
$res[$i]['size'] = filesize($value->path);
$i++;
}
}
return json_encode($res);
}
}

backend/controllers/SupplierController.php → vendor/antgoods/goods/src/controllers/SupplierController.php

51
vendor/antgoods/goods/src/logic/goods/GoodsManager.php

@ -0,0 +1,51 @@
<?php
namespace antgoods\goods\logic\goods;
class GoodsManager
{
/**
* @param $newFileIdArr
* @param array $oldFileIdArr
* @param $goodsModel
* @param int $filetype
* @return bool
* 保存新文件,删除不需要的文件操作
*/
public function saveFile($newFileIdArr, $goodsModel, $oldFileIdArr = [], $filetype = 1)
{
//判断类名是否存在
if(!class_exists('\backend\logic\file\FileManager') || !class_exists('\common\models\ars\File')) {
return ['status' => false, 'info' => '操作失败'];
}
//需要新建的文件id
$create_file_id_arr = array_diff($newFileIdArr, $oldFileIdArr);
//创建文件
$class = new \backend\logic\file\FileManager();
$create_file_res = $class->saveTemFileToFile($create_file_id_arr, $goodsModel->id, $filetype);
//需要删除的文件id
$del_file_id_arr = array_diff($oldFileIdArr, $newFileIdArr);
//删除文件
$class->deleteFile($del_file_id_arr);
//记录第一张图片id
$first_file_id = 0;
//查看修改数组是否为空
if (!$newFileIdArr[0]) {
$first_file_id = null;
}else {
if ($create_file_res['status']) {
$first_file_id = $create_file_res['first_file_id'];
}
}
return ['status' => true, 'info' => '操作成功', 'first_file_id' => $first_file_id];
}
}

console/migrations/m191111_080318_create_table_shop_category.php → vendor/antgoods/goods/src/migrations/m191119_021851_create_table_shop_category.php

console/migrations/m191111_081842_create_table_category.php → vendor/antgoods/goods/src/migrations/m191119_022641_create_table_category.php

console/migrations/m191111_082739_create_table_attribute.php → vendor/antgoods/goods/src/migrations/m191119_022939_create_table_attribute.php

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save