Browse Source

将vendor下面的antgoods模块修改为单独的antgoods模块

wechat_public_accounts
linyaostalker 5 years ago
parent
commit
20a73e0728
  1. 2
      antgoods/.gitignore
  2. 26
      antgoods/assets/AppAsset.php
  3. 4
      antgoods/config/.gitignore
  4. 1
      antgoods/config/bootstrap.php
  5. 62
      antgoods/config/main.php
  6. 4
      antgoods/config/params.php
  7. 170
      antgoods/controllers/AttributeController.php
  8. 151
      antgoods/controllers/BrandController.php
  9. 276
      antgoods/controllers/CategoryController.php
  10. 76
      antgoods/controllers/ConfigController.php
  11. 359
      antgoods/controllers/GoodsController.php
  12. 287
      antgoods/controllers/ShopCategoryController.php
  13. 112
      antgoods/controllers/SiteController.php
  14. 151
      antgoods/controllers/SupplierController.php
  15. 578
      antgoods/logic/goods/GoodsManager.php
  16. 1
      antgoods/models/.gitkeep
  17. 111
      antgoods/models/ars/Attribute.php
  18. 82
      antgoods/models/ars/Brand.php
  19. 114
      antgoods/models/ars/Category.php
  20. 81
      antgoods/models/ars/FilterAttr.php
  21. 232
      antgoods/models/ars/Goods.php
  22. 81
      antgoods/models/ars/GoodsAttr.php
  23. 102
      antgoods/models/ars/GoodsSku.php
  24. 122
      antgoods/models/ars/ShopCategory.php
  25. 96
      antgoods/models/ars/Supplier.php
  26. 162
      antgoods/models/searchs/AttributeSearch.php
  27. 152
      antgoods/models/searchs/BrandSearch.php
  28. 172
      antgoods/models/searchs/CategorySearch.php
  29. 241
      antgoods/models/searchs/GoodsSearch.php
  30. 162
      antgoods/models/searchs/ShopCategorySearch.php
  31. 161
      antgoods/models/searchs/SupplierSearch.php
  32. 32
      antgoods/views/attribute/_form.php
  33. 49
      antgoods/views/attribute/_search.php
  34. 18
      antgoods/views/attribute/create.php
  35. 28
      antgoods/views/attribute/index.php
  36. 19
      antgoods/views/attribute/update.php
  37. 33
      antgoods/views/attribute/view.php
  38. 24
      antgoods/views/brand/_form.php
  39. 49
      antgoods/views/brand/_search.php
  40. 18
      antgoods/views/brand/create.php
  41. 28
      antgoods/views/brand/index.php
  42. 19
      antgoods/views/brand/update.php
  43. 30
      antgoods/views/brand/view.php
  44. 47
      antgoods/views/category/_form.php
  45. 49
      antgoods/views/category/_search.php
  46. 18
      antgoods/views/category/create.php
  47. 28
      antgoods/views/category/index.php
  48. 19
      antgoods/views/category/update.php
  49. 41
      antgoods/views/category/view.php
  50. 27
      antgoods/views/config/index.php
  51. 107
      antgoods/views/goods/_form.php
  52. 49
      antgoods/views/goods/_search.php
  53. 22
      antgoods/views/goods/attribute.php
  54. 72
      antgoods/views/goods/create.php
  55. 22
      antgoods/views/goods/filter_attribute.php
  56. 63
      antgoods/views/goods/goods.php
  57. 28
      antgoods/views/goods/index.php
  58. 31
      antgoods/views/goods/new_editor.php
  59. 37
      antgoods/views/goods/picture.php
  60. 15
      antgoods/views/goods/sku_edit.php
  61. 74
      antgoods/views/goods/update.php
  62. 113
      antgoods/views/goods/view.php
  63. 33
      antgoods/views/layouts/base.php
  64. 25
      antgoods/views/layouts/breadcrumb.php
  65. 7
      antgoods/views/layouts/footer.php
  66. 67
      antgoods/views/layouts/header.php
  67. 57
      antgoods/views/layouts/main.php
  68. 33
      antgoods/views/layouts/sidebar.php
  69. 55
      antgoods/views/shop-category/_form.php
  70. 49
      antgoods/views/shop-category/_search.php
  71. 18
      antgoods/views/shop-category/create.php
  72. 28
      antgoods/views/shop-category/index.php
  73. 19
      antgoods/views/shop-category/update.php
  74. 64
      antgoods/views/shop-category/view.php
  75. 27
      antgoods/views/site/error.php
  76. 6
      antgoods/views/site/index.php
  77. 34
      antgoods/views/site/login.php
  78. 68
      antgoods/views/site/test.php
  79. 30
      antgoods/views/supplier/_form.php
  80. 49
      antgoods/views/supplier/_search.php
  81. 18
      antgoods/views/supplier/create.php
  82. 28
      antgoods/views/supplier/index.php
  83. 19
      antgoods/views/supplier/update.php
  84. 33
      antgoods/views/supplier/view.php
  85. 11
      antgoods/web/.gitignore
  86. 2
      antgoods/web/assets/.gitignore
  87. 48
      antgoods/web/css/reset.css
  88. 52
      antgoods/web/css/site.css
  89. 58
      antgoods/web/custom/sku.49a56a9198d9c3ec233c.js
  90. 58
      antgoods/web/custom/sku.52802ed907a316501cd7.js
  91. 58
      antgoods/web/custom/sku.9a46222d01b3d601e5ad.js
  92. 64
      antgoods/web/custom/sku_item.6649e882bedbeb22ea3d.js
  93. BIN
      antgoods/web/favicon.ico
  94. BIN
      antgoods/web/img/avatar.png
  95. BIN
      antgoods/web/img/avatar04.png
  96. BIN
      antgoods/web/img/avatar2.png
  97. BIN
      antgoods/web/img/avatar3.png
  98. BIN
      antgoods/web/img/avatar5.png
  99. BIN
      antgoods/web/img/credit/american-express.png
  100. BIN
      antgoods/web/img/credit/cirrus.png

2
antgoods/.gitignore

@ -0,0 +1,2 @@
cert
runtime

26
antgoods/assets/AppAsset.php

@ -0,0 +1,26 @@
<?php
namespace backend\assets;
use yii\web\AssetBundle;
/**
* Main backend application asset bundle.
*/
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/site.css',
];
public $js = [
'js/common.js'
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap4\BootstrapAsset',
'yii\bootstrap4\BootstrapPluginAsset',
'iron\web\AdminlteAsset',
];
}

4
antgoods/config/.gitignore

@ -0,0 +1,4 @@
codeception-local.php
main-local.php
params-local.php
test-local.php

1
antgoods/config/bootstrap.php

@ -0,0 +1 @@
<?php

62
antgoods/config/main.php

@ -0,0 +1,62 @@
<?php
$params = array_merge(
require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php'
);
return [
'id' => 'antgoods',
'basePath' => dirname(__DIR__),
'controllerNamespace' => 'antgoods\controllers',
'bootstrap' => ['log'],
'defaultRoute' => '/category',
'modules' => [
],
'components' => [
'request' => [
'parsers' => [
'application/json' => 'yii\web\JsonParser',
],
'csrfParam' => '_csrf-api',
],
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
'identityCookie' => ['name' => '_identity-antgoods', 'httpOnly' => true],
],
'session' => [
// this is the name of the session cookie used for login on the app
'name' => 'antgoods',
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'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' => [
'errorAction' => 'site/error',
],
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
],
],
'file' => ['class' => 'backend\logic\file\FileManager'],
],
'params' => $params,
];

4
antgoods/config/params.php

@ -0,0 +1,4 @@
<?php
return [
'adminEmail' => 'admin@example.com',
];

170
antgoods/controllers/AttributeController.php

@ -0,0 +1,170 @@
<?php
namespace antgoods\controllers;
use Yii;
use antgoods\models\ars\Attribute;
use antgoods\models\searchs\AttributeSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* AttributeController implements the CRUD actions for Attribute model.
*/
class AttributeController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all Attribute models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new AttributeSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'columns' => $searchModel->columns()
]);
}
/**
* Displays a single Attribute 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 Attribute model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Attribute();
$model->sort_order = 0;
$model->cat_id = 0;
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$model->value = str_replace(',', ',', $model->value);
$array = explode(',', $model->value);
if (count($array) != count(array_unique($array))) {
\Yii::$app->getSession()->setFlash('error', '不能有相同的属性值');
return $this->render('create', ['model' => $model]);
}
if ($model->save()) {
return $this->redirect(['index']);
}
}
return $this->render('create', [
'model' => $model,
]);
}
/**
* Updates an existing Attribute 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->validate()) {
$model->value = str_replace(',', ',', $model->value);
$array = explode(',', $model->value);
if (count($array) != count(array_unique($array))) {
\Yii::$app->getSession()->setFlash('error', '不能有相同的属性值');
return $this->render('create', ['model' => $model]);
}
if ($model->save()) {
return $this->redirect(['index']);
}
return $this->redirect('index');
}
return $this->render('update', [
'model' => $model,
]);
}
/**
* Deletes an existing Attribute 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 = Attribute::IS_DELETE_YES;
$model->save();
return $this->redirect(['index']);
}
/**
* Finds the Attribute model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Attribute the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Attribute::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
/**
* @author iron
* 文件导出
*/
public function actionExport()
{
$searchModel = new AttributeSearch();
$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' =>'Attributes'. "-" .date('Y-m-d H/i/s', time()),
'columns' => $searchModel->columns()
]);
}
}

151
antgoods/controllers/BrandController.php

@ -0,0 +1,151 @@
<?php
namespace antgoods\controllers;
use Yii;
use antgoods\models\ars\Brand;
use antgoods\models\searchs\BrandSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* BrandController implements the CRUD actions for Brand model.
*/
class BrandController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all Brand models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new BrandSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'columns' => $searchModel->columns()
]);
}
/**
* Displays a single Brand 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 Brand model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Brand();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect('index');
}
return $this->render('create', [
'model' => $model,
]);
}
/**
* Updates an existing Brand 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 Brand 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 = Brand::IS_DELETE_YES;
$model->save();
return $this->redirect(['index']);
}
/**
* Finds the Brand model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Brand the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Brand::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
/**
* @author iron
* 文件导出
*/
public function actionExport()
{
$searchModel = new BrandSearch();
$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' =>'Brands'. "-" .date('Y-m-d H/i/s', time()),
'columns' => $searchModel->columns()
]);
}
}

276
antgoods/controllers/CategoryController.php

@ -0,0 +1,276 @@
<?php
namespace antgoods\controllers;
use antgoods\logic\goods\GoodsManager;
use common\models\ars\File;
use Yii;
use antgoods\models\ars\Category;
use antgoods\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();
$model->is_show = Category::IS_SHOW_DISPLAY;
$model->sort_order = 0;
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
//类目图片上传保存处理
$icon_image_id_str = $model->iconImageId;
$model->save();
$save_icon_image_res = GoodsManager::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()) && $model->validate()) {
//类目图片上传保存处理
$icon_image_id_str = $model->iconImageId;
$model->save();
$save_icon_image_res = GoodsManager::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);
}
}

76
antgoods/controllers/ConfigController.php

@ -0,0 +1,76 @@
<?php
namespace antgoods\controllers;
use Yii;
use common\models\ars\Category;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* CategoryController implements the CRUD actions for Category model.
*/
class ConfigController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all Category models.
* @return mixed
*/
public function actionIndex()
{
return $this->render('index');
}
/**
* 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,
]);
}
/**
* 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.');
}
}

359
antgoods/controllers/GoodsController.php

@ -0,0 +1,359 @@
<?php
namespace antgoods\controllers;
use antgoods\models\ars\GoodsAttr;
use antgoods\models\ars\GoodsSku;
use common\models\ars\OrderGoods;
use common\models\ars\TemFile;
use MongoDB\Driver\Manager;
use Yii;
use antgoods\models\ars\Goods;
use antgoods\models\searchs\GoodsSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use antgoods\logic\goods\GoodsManager;
use common\models\ars\File;
use yii\web\Response;
use antgoods\models\ars\Attribute;
/**
* 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,
],
'ueditor' => [
'class' => 'common\widgets\ueditor\UeditorAction',
'config' => [
//上传图片配置
'imageUrlPrefix' => "", /* 图片访问路径前缀 */
'imagePathFormat' => "/uploads/origin/introduce/" . md5(time() . rand(000, 999)), /* 上传保存路径,可以自定义保存路径和文件名格式 */
]
],
];
}
/**
* 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();
$model->is_sale = Goods::IS_SALE_YES;
$model->stock = -1;
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
//商品封面图和商品详情图上传保存处理
$res = GoodsManager::updateGoods(Yii::$app->request->post(), $model);
if ($res['status']) {
return $this->redirect('index');
}
} else {
$model->ruleVerify = 1;
}
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_str = $model->image;
$detail_image_old_id_str = $model->detailImageId;
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
//商品封面图和商品详情图上传保存处理
$res = GoodsManager::updateGoods(Yii::$app->request->post(), $model, $cover_image_old_id_str, $detail_image_old_id_str);
if ($res['status']) {
return $this->redirect('index');
}
}
$attributeModel = GoodsManager::getAttribute($id);
$checkAttr = GoodsManager::getSkuInfo($id);
$filterAttributeModel = GoodsManager::getFilterAttribute($id);
$judgeGoodsCategory = GoodsManager::judgeGoodsCategory($model);
return $this->render('update', [
'model' => $model,
'attributeModel' => $attributeModel,
'attrValue' => $checkAttr,
'filterAttributeModel' => $filterAttributeModel,
'judgeGoodsCategory' => $judgeGoodsCategory,
]);
}
/**
* 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)
{
$model = $this->findModel($id);
$model->is_delete = Goods::IS_DELETE_YES;
$model->save();
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;
}
$rule_verify = Yii::$app->request->get('ruleverify');
$file_id_str = Yii::$app->request->get('fileidstr');
$file_id_arr = explode(',', $file_id_str);
if ($rule_verify == 1) {
$data = \common\models\ars\TemFile::find()->where(['id' => $file_id_arr])->all();
} else {
$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);
}
/**
* @param $id
* @return string
* 商品编辑sku
*/
public function actionEditSku($id)
{
$sku = GoodsManager::getCreatedSku($id);
$attributes = GoodsManager::getAttrs($id);
return $this->render('sku_edit', [
'attributes' => $attributes,
'sku' => $sku,]);
}
/**
* @return array
* @throws \Throwable
* 添加sku
*/
public function actionAddSku()
{
$data = [];
Yii::$app->response->format = 'json';
$res = Yii::$app->request->post('sku');
$goodsId = Yii::$app->request->post('goodsId');
$tra = Yii::$app->db->beginTransaction();
try {
$data['originalIds'] = GoodsManager::getOriginalIds($res['type'], $goodsId);
$data['acceptIds'] = [];
foreach ($res['data'] as $sku) {
GoodsManager::AddOrUpdateData($sku, $res['type'], $goodsId);
if ($sku['id'] > 0) {
$data['acceptIds'][] = $sku['id'];
}
}
GoodsManager::deleteSku($res['type'], $data, $goodsId);
$tra->commit();
return ['status' => true];
} catch (\Exception $e) {
$tra->rollBack();
return ['status' => false, 'info' => $e->getMessage()];
}
}
public function actionSwitch()
{
Yii::$app->response->format = 'json';
$data = [];
$type = Yii::$app->request->get('type');
$id = Yii::$app->request->get('goodsId');
$data['sku'] = GoodsManager::getCreatedSku($id, $type);
$data['attributes'] = GoodsManager::getAttrs($id, $type);
return $data;
}
/**
* @return false|string
* 根据商品分类获取商品属性
*/
public function actionFilterAttribute()
{
$catId = Yii::$app->request->get('catId')??0;
$goodsId = Yii::$app->request->get('goodsId')??0;
$allAttr = Attribute::find()->where(['type' => Attribute::TYPE_ATTR])->andWhere(['cat_id' => [0,$catId]])->asArray()->all();
return json_encode($allAttr);
}
}

287
antgoods/controllers/ShopCategoryController.php

@ -0,0 +1,287 @@
<?php
namespace antgoods\controllers;
use antgoods\logic\goods\GoodsManager;
use common\models\ars\File;
use Yii;
use antgoods\models\ars\ShopCategory;
use antgoods\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();
$model->is_show = ShopCategory::IS_SHOW_HIDE;
$model->sort_order = 0;
if ($model->load(Yii::$app->request->post())) {
if ($model->filter_attr != null && is_array($model->filter_attr)) {
$model->filter_attr = implode(',', $model->filter_attr);
} else {
$model->filter_attr = '';
}
//类目图片上传保存处理
$icon_image_id_str = $model->iconImageId;
$model->save();
$save_icon_image_res = GoodsManager::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);
if ($model->filter_attr != null) {
$model->filter_attr = explode(',', $model->filter_attr);
}
$model->iconImageId = $model->icon;
$icon_image_old_id_arr = $model->icon;//记录已保存的类目图片id,用于修改
if ($model->load(Yii::$app->request->post())) {
if ($model->filter_attr != null && is_array($model->filter_attr)) {
$model->filter_attr = implode(',', $model->filter_attr);
} else {
$model->filter_attr = '';
}
//类目图片上传保存处理
$icon_image_id_str = $model->iconImageId;
$model->save();
$save_icon_image_res = GoodsManager::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)
{
$model = $this->findModel($id);
$model->is_delete = ShopCategory::IS_DELETE_YES;
$model->save();
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);
}
}

112
antgoods/controllers/SiteController.php

@ -0,0 +1,112 @@
<?php
namespace antgoods\controllers;
use Yii;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\models\LoginForm;
use common\models\CategorySearch;
/**
* Site controller
*/
class SiteController extends Controller {
/**
* {@inheritdoc}
*/
public function behaviors() {
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['login', 'error', 'test'],
'allow' => true,
],
[
'actions' => ['logout', 'index'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
// 'logout' => ['post'],
],
],
];
}
/**
* {@inheritdoc}
*/
public function actions() {
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
'upload'=>[
'class'=>'iron\actions\UploadAction',
]
];
}
/**
* Displays homepage.
*
* @return string
*/
public function actionIndex() {
return $this->render('index');
}
/**
* Login action.
*
* @return string
*/
public function actionLogin() {
$this->layout = 'base';
if (!Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
} else {
$model->password = '';
return $this->render('login', [
'model' => $model,
]);
}
}
/**
* Logout action.
*
* @return string
*/
public function actionLogout() {
Yii::$app->user->logout();
return $this->goHome();
}
public function actionTest() {
$searchModel = new CategorySearch();
return $this->render('test', [
'name' => 'blobt',
'model' => $searchModel
]);
}
}

151
antgoods/controllers/SupplierController.php

@ -0,0 +1,151 @@
<?php
namespace antgoods\controllers;
use Yii;
use antgoods\models\ars\Supplier;
use antgoods\models\searchs\SupplierSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* SupplierController implements the CRUD actions for Supplier model.
*/
class SupplierController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all Supplier models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new SupplierSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'columns' => $searchModel->columns()
]);
}
/**
* Displays a single Supplier 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 Supplier model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Supplier();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect('index');
}
return $this->render('create', [
'model' => $model,
]);
}
/**
* Updates an existing Supplier 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 Supplier 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 = Supplier::IS_DELETE_YES;
$model->save();
return $this->redirect(['index']);
}
/**
* Finds the Supplier model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Supplier the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Supplier::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
/**
* @author iron
* 文件导出
*/
public function actionExport()
{
$searchModel = new SupplierSearch();
$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' =>'Suppliers'. "-" .date('Y-m-d H/i/s', time()),
'columns' => $searchModel->columns()
]);
}
}

578
antgoods/logic/goods/GoodsManager.php

@ -0,0 +1,578 @@
<?php
namespace antgoods\logic\goods;
use common\models\ars\File;
use Yii;
use yii\base\Exception;
use antgoods\models\ars\GoodsAttr;
use antgoods\models\ars\Attribute;
use antgoods\models\ars\GoodsSku;
use antgoods\models\ars\Goods;
use antgoods\models\ars\FilterAttr;
use antgoods\models\ars\Category;
class GoodsManager
{
/**
* @param $newFileIdArr
* @param $goodsModel
* @param array $oldFileIdArr
* @param int $fileType
* @return array
* 保存新文件,删除不需要的文件操作
*/
public static 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
$createFileIdArr = array_diff($newFileIdArr, $oldFileIdArr);
//创建文件
$class = new \backend\logic\file\FileManager();
$createFileRes = $class->saveTemFileToFile($createFileIdArr, $goodsModel->id, $fileType);
//需要删除的文件id
$delFileIdArr = array_diff($oldFileIdArr, $newFileIdArr);
//删除文件
$class->deleteFile($delFileIdArr);
//记录第一张图片id
$firstFileId = 0;
//查看修改数组是否为空
if (!$newFileIdArr[0]) {
$firstFileId = null;
}else {
if ($createFileRes['status']) {
$firstFileId = $createFileRes['first_file_id'];
}
}
return ['status' => true, 'info' => '操作成功', 'first_file_id' => $firstFileId];
}
/**
* @param $data
* @param $model
* @param null $coverImageOldIdStr
* @param null $detailImageOldIdStr
* @return array
* @throws \Throwable
* 创建修改商品操作
*/
public static function updateGoods($data, $model, $coverImageOldIdStr = null, $detailImageOldIdStr = null)
{
$attribute = $data['attribute'];
$filterAttribute = $data['filterattribute'];
$tra = Yii::$app->db->beginTransaction();
try {
if (!$model->save()) {
throw new Exception('');
}
$saveCoverImageRes = self::saveFile(explode(',', $model->coverImageId), $model, explode(',', $coverImageOldIdStr));
$saveDetailImageRes = self::saveFile(explode(',', $model->detailImageId), $model, explode(',', $detailImageOldIdStr), File::OWN_TYPE_GOODS_DETAILS);
if ($saveCoverImageRes['status'] && $saveDetailImageRes['status']) {
if($saveCoverImageRes['first_file_id'] !== 0) {
$model->image = $saveCoverImageRes['first_file_id'];
if (!$model->save()) {
throw new Exception('图片保存失败');
}
}
} else {
throw new Exception('图片保存失败');
}
self::addAttributeOperating(['id' => $model->id, 'attribute' => $attribute]);
self::addFilterAttributeOperating(['id' => $model->id, 'filterAttribute' => $filterAttribute]);
$tra->commit();
return ['status' => true];
} catch (\yii\base\Exception $e) {
$tra->rollBack();
return ['status' => false, 'info' => $e->getMessage()];
}
}
/**
* @param $data
* @return bool
* @throws Exception
* 创建修改商品属性操作
*/
public static function addAttributeOperating($data)
{
if (!$data['attribute']) {
return true;
}
$data['attribute'] = json_decode($data['attribute'], true);
$oldAttr = [];
$goodsAttr = GoodsAttr::find()->where(['goods_id' => $data['id'], 'is_delete' => GoodsAttr::IS_DELETE_NO])->all();
if ($goodsAttr) { //如果商品有旧的属性
if(count($data['attribute']) == 0 && is_array($data['attribute'])) { //如果传上来的是空数组,删除该商品下的全部属性
self::delAttribute($goodsAttr);
return true;
}
foreach ($goodsAttr as $key => $value) { //把旧的商品属性保存到一个数组
$oldAttr[$value->id] = $value->attr_value;
}
}
$newAttr = self::addAttribute($data['attribute'], $data['id']); //添加新的商品属性
$delAttr = array_diff(array_keys($oldAttr), array_keys($newAttr)); //找出需要删除的goodsAttrId
if (!$delAttr) {
return true;
}
foreach ($delAttr as $value) {
$model = GoodsAttr::find()->where(['id' => $value, 'is_delete' => GoodsAttr::IS_DELETE_NO])->One();
if ($model) {
$model->is_delete = GoodsAttr::IS_DELETE_YES;
if (!$model->save()) {
throw new Exception('goodsAttribute delete false');
}
}
}
}
/**
* @param $goodsAttr
* @throws Exception
* 删除商品属性
*/
public static function delAttribute($goodsAttr)
{
foreach ($goodsAttr as $key => $value) {
$value->is_delete = GoodsAttr::IS_DELETE_YES;
if (!$value->save()) {
throw new Exception('goods attribute delete false');
}
}
}
/**
* @param $attribute
* @param $goodsId
* @return array
* @throws Exception
* 保存商品属性
*/
public static function addAttribute($attribute, $goodsId)
{
$newAttr = [];
if (!$attribute) {
return [];
}
foreach ($attribute as $value) {
foreach ($value['value'] as $k => $v) {
$goodsAttrModel = new GoodsAttr();
$goodsAttrModel->attr_id = $value['id'];
$attr = GoodsAttr::find()->where(['goods_id' => $goodsId, 'attr_id' => $value['id'], 'attr_value' => $v, 'is_delete' => GoodsAttr::IS_DELETE_NO])->one();
if ($attr) {
$newAttr[$attr->id] = $attr->attr_value; //原有的数据
} else {
$goodsAttrModel->goods_id = $goodsId;
$goodsAttrModel->attr_value = $v;
if (!$goodsAttrModel->save()) {
throw new Exception('goodsAttribute save false');
}
$newAttr[$goodsAttrModel->id] = $goodsAttrModel->attr_value; //新增的数据
}
}
}
return $newAttr;
}
/**
* @param $id
* @return Attribute|array|null
* 获取属性信息
*/
public static function getAttribute($id)
{
$goodsAttributes = GoodsAttr::find()->where(['goods_id' => $id, 'is_delete' => GoodsAttr::IS_DELETE_NO])->andWhere(['!=', 'attr_id', 0])->all();
$filter = [];
$goodsAttributeModel = [];
if (!$goodsAttributes) {
return $goodsAttributeModel;
}
foreach ($goodsAttributes as $key => $value) {
$attribute = Attribute::findOne($value->attr_id);
if (!in_array($attribute->name, $filter)) {
$filter[] = $attribute->name;
$attribute = ['name' => $attribute->name, 'id' => $attribute->id, 'value' => [$value->attr_value]];
$goodsAttributeModel[] = $attribute;
} else {
foreach ($goodsAttributeModel as $k => $v) {
if ($v['name'] == $attribute->name) {
$goodsAttributeModel[$k]['value'][] = $value->attr_value;
}
}
}
}
return $goodsAttributeModel;
}
/**
* @param $id
* @return array
* 获取sku信息
*/
public static function getSkuInfo($id)
{
$skus = GoodsSku::find()->where(['goods_id' => $id, 'is_delete' => GoodsSku::IS_DELETE_NO])->all();
$attrId = [];
foreach ($skus as $sku) {
$attrId = array_merge(explode(',', $sku->goods_attr), $attrId);
}
$attrs = GoodsAttr::find()->where(['id' => $attrId, 'is_delete' => GoodsAttr::IS_DELETE_NO])->andWhere(['!=', 'attr_id', 0])->all();
$checkAttr = [];
$filterAttr = [];
foreach ($attrs as $value) {
$attr = Attribute::findOne(['id' => $value->attr_id, 'is_delete' => Attribute::IS_DELETE_NO]);
if (!in_array($attr->name, $filterAttr)) {
$filterAttr[] = $attr->name;
$newAttr = ['id' => $attr->id, 'name' => $attr->name, 'value' => [$value->attr_value]];
$checkAttr[] = $newAttr;
} else {
foreach ($checkAttr as $key => $item) {
if ($item['name'] == $attr->name) { //如果attr_id与$filter的attr_id相符,入栈
$checkAttr[$key]['value'][] = $value->attr_value;
}
}
}
}
return $checkAttr;
}
/**
* @param $id
* @return mixed
* 已创建sku信息
*/
public static function getCreatedSku($id, $type = 0)
{
$goods = Goods::findOne($id);
$data['type'] = $type ?: $goods->sku_mode;
$data['data'] = [];
if ($data['type'] == Goods::SKU_MODE_ATTR) {
$sku = GoodsSku::find()
->where(['goods_id' => $id, 'is_manaul' => 0])
->all();
} else {
$sku = GoodsSku::find()
->where(['goods_id' => $id, 'is_manaul' => 1])
->all();
}
foreach ($sku as $value) {
$data['data'][] = self::getAttrInfo($data['type'], $value);
}
return $data;
}
/**
* @param $type
* @param $sku
* @return array
* 获取商品详情
*/
public static function getAttrInfo($type, $sku)
{
$data = [];
if ($type == Goods::SKU_MODE_ATTR) {
$data['value'] = array_filter(explode(',', $sku->goods_attr));
} else {
$attr = explode(',', $sku->goods_attr);
$goodsAttr = GoodsAttr::findOne($attr[0]);
$data['value'] = $goodsAttr->attr_value;
}
$data['id'] = $sku->id;
$data['price'] = $sku->price;
$data['stock'] = $sku->stock;
$data['weight'] = $sku->weight;
return $data;
}
/**
* @param $id
* @return array
* 获取商品属性
*/
public static function getAttrs($id)
{
$attrId = GoodsAttr::find()->where(['goods_id' => $id, 'is_delete' => GoodsAttr::IS_DELETE_NO])
->andWhere(['>', 'attr_id', 0])
->select('attr_id')
->distinct()
->all();
$attributes = [];
foreach ($attrId as $v) {
$attribute = Attribute::findOne($v);
if ($attribute && $attribute->type == Attribute::TYPE_ATTR) {
$ret['name'] = $attribute->name;
$ret['id'] = $attribute->id;
$ret['attrValue'] = self::getAttrValue($attribute->id, $id);
$attributes[] = $ret;
}
}
return $attributes;
}
/**
* @param $attrId
* @param $goodsId
* @return GoodsAttr[]|GoodsSku[]|array|File[]|\common\models\ars\TemFile[]|\yii\db\ActiveRecord[]
* 获取属性值
*/
public static function getAttrValue($attrId, $goodsId)
{
return GoodsAttr::find()
->select(['id', 'attr_value'])
->where(['goods_id' => $goodsId])
->andWhere(['attr_id' => $attrId])
->asArray()
->all();
}
/**
* @param $type
* @param $goodsId
* @return array
* 获取已存储的商品sku的id
*/
public static function getOriginalIds($type, $goodsId)
{
$ids = [];
if ($type == Goods::SKU_MODE_MANUAL) {
$query = GoodsSku::find()
->where(['is_manaul' => 1]);
} else {
$query = GoodsSku::find()
->where(['is_manaul' => 0]);
}
$sku = $query
->andWhere(['goods_id' => $goodsId])
->all();
foreach ($sku as $value) {
$ids[] = $value->id;
}
return $ids;
}
/**
* @param $sku
* @throws \yii\db\Exception
* 添加或更新sku数据
*/
public static function AddOrUpdateData($sku, $type, $goodsId)
{
$goodsModel = Goods::findOne($goodsId);
if ($sku['id'] > 0) {
$goodsSku = GoodsSku::findOne($sku['id']);
$attrId = array_filter(explode(',', $goodsSku->goods_attr));
$attr = GoodsAttr::findOne($attrId[0]);
} else {
$goodsSku = new GoodsSku();
$attr = new GoodsAttr();
}
if (!$attr || !$goodsSku || !$goodsModel) {
throw new \yii\db\Exception('系统异常');
}
if ($type == Goods::SKU_MODE_MANUAL) {
$attr->attr_value = $sku['value'];
if (!$attr->save()) {
throw new \yii\db\Exception('手动属性修改失败');
}
$goodsSku->goods_attr = (string)$attr->id;
$goodsSku->is_manaul = 1;
} else {
$goodsSku->goods_attr = implode(',', array_filter($sku['value']));
}
$goodsSku->goods_id = $goodsId;
$goodsSku->price = $sku['price'];
$goodsSku->stock = $sku['stock'];
$goodsSku->weight = $sku['weight'];
$goodsSku->goods_sn = $goodsModel->sn;
if (!$goodsSku->save()) {
throw new \yii\db\Exception('保存失败,请检查是否有重复规格');
}
$goods = Goods::findOne($goodsId);
$goods->sku_mode = $type;
if (!$goods->save()) {
throw new \yii\db\Exception('商品sku类型修改失败');
}
}
/**
* @param $type
* @param $data
* @param $goodsId
* @return bool
* @throws \Throwable
* @throws \yii\db\StaleObjectException
* 删除sku
*/
public static function deleteSku($type, $data, $goodsId)
{
if (!$data['originalIds']) {
return true;
}
if ($type == Goods::SKU_MODE_MANUAL) {
$query = GoodsSku::find()
->where(['is_manaul' => 1]);
} else {
$query = GoodsSku::find()
->where(['is_manaul' => 0]);
}
$sku = $query
->andWhere(['goods_id' => $goodsId])
->andWhere(['in', 'id', $data['originalIds']])
->andWhere(['not in', 'id', $data['acceptIds']])
->all();
foreach ($sku as $value) {
$value->delete();
}
}
/**
* @param $data
* @return bool
* @throws Exception
* 创建修改商品筛选属性操作
*/
public static function addFilterAttributeOperating($data)
{
if (!$data['filterAttribute']) {
return true;
}
$data['filterAttribute'] = json_decode($data['filterAttribute'], true);
$oldFilterAttr = [];
$goodsFilterAttr = FilterAttr::find()->where(['goods_id' => $data['id'], 'is_delete' => FilterAttr::IS_DELETE_NO])->all();
if ($goodsFilterAttr) { //如果商品有旧的属性
if(count($data['filterAttribute']) == 0 && is_array($data['filterAttribute'])) { //如果传上来的是空数组,删除该商品下的全部属性
self::delFilterAttribute($goodsFilterAttr);
return true;
}
foreach ($goodsFilterAttr as $key => $value) { //把旧的商品属性保存到一个数组
$oldFilterAttr[$value->id] = $value->attr_value;
}
}
$newAttr = self::addFilterAttribute($data['filterAttribute'], $data['id']); //添加新的商品属性
$delAttr = array_diff(array_keys($oldFilterAttr), array_keys($newAttr)); //找出需要删除的goodsAttrId
if (!$delAttr) {
return true;
}
foreach ($delAttr as $value) {
$model = FilterAttr::find()->where(['id' => $value, 'is_delete' => FilterAttr::IS_DELETE_NO])->One();
if ($model) {
$model->is_delete = FilterAttr::IS_DELETE_YES;
if (!$model->save()) {
throw new Exception('goodsAttribute delete false');
}
}
}
}
/**
* @param $goodsFilterAttr
* @throws Exception
* 删除商品筛选属性
*/
public static function delFilterAttribute($goodsFilterAttr)
{
foreach ($goodsFilterAttr as $key => $value) {
$value->is_delete = FilterAttr::IS_DELETE_YES;
if (!$value->save()) {
throw new Exception('goods attribute delete false');
}
}
}
/**
* @param $attribute
* @param $goodsId
* @return array
* @throws Exception
* 保存商品筛选属性
*/
public static function addFilterAttribute($attribute, $goodsId)
{
$newAttr = [];
if (!$attribute) {
return [];
}
foreach ($attribute as $value) {
foreach ($value['value'] as $k => $v) {
$goodsFilterAttrModel = new FilterAttr();
$goodsFilterAttrModel->attr_id = $value['id'];
$attr = FilterAttr::find()->where(['goods_id' => $goodsId, 'attr_id' => $value['id'], 'attr_value' => $v, 'is_delete' => FilterAttr::IS_DELETE_NO])->one();
if ($attr) {
$newAttr[$attr->id] = $attr->attr_value; //原有的数据
} else {
$goodsFilterAttrModel->goods_id = $goodsId;
$goodsFilterAttrModel->attr_value = $v;
if (!$goodsFilterAttrModel->save()) {
throw new Exception('goodsAttribute save false');
}
$newAttr[$goodsFilterAttrModel->id] = $goodsFilterAttrModel->attr_value; //新增的数据
}
}
}
return $newAttr;
}
/**
* @param $id
* @return Attribute|array|null
* 获取筛选属性信息
*/
public static function getFilterAttribute($id)
{
$goodsFilterAttributes = FilterAttr::find()->where(['goods_id' => $id, 'is_delete' => FilterAttr::IS_DELETE_NO])->andWhere(['!=', 'attr_id', 0])->all();
$filter = [];
$goodsFilterAttributeModel = [];
if (!$goodsFilterAttributes) {
return $goodsFilterAttributeModel;
}
foreach ($goodsFilterAttributes as $key => $value) {
$attribute = Attribute::findOne($value->attr_id);
if (!in_array($attribute->name, $filter)) {
$filter[] = $attribute->name;
$attribute = ['name' => $attribute->name, 'id' => $attribute->id, 'value' => [$value->attr_value]];
$goodsFilterAttributeModel[] = $attribute;
} else {
foreach ($goodsFilterAttributeModel as $k => $v) {
if ($v['name'] == $attribute->name) {
$goodsFilterAttributeModel[$k]['value'][] = $value->attr_value;
}
}
}
}
return $goodsFilterAttributeModel;
}
/**
* @param $goodsModel
* @return bool
*
*/
public static function judgeGoodsCategory($goodsModel)
{
$skus = GoodsSku::find()->where(['goods_id' => $goodsModel->id, 'is_delete' => GoodsSku::IS_DELETE_NO])->all();
$attrId = [];
foreach ($skus as $sku) {
$attrId = array_merge(explode(',', $sku->goods_attr), $attrId);
}
$goodsAttr = array_unique(GoodsAttr::find()->select(['attr_id'])->where(['id' => $attrId, 'is_delete' => GoodsAttr::IS_DELETE_NO])->andWhere(['!=', 'attr_id', 0])->column());
$attrArr = array_unique(Attribute::find()->select(['cat_id'])->where(['is_delete' => Attribute::IS_DELETE_NO, 'id' => $goodsAttr])->column());
if (in_array($goodsModel->cat_id, $attrArr)) {
return true; //存在,则返回true,表示后台分类不得修改
}
return false; //否则返回false,表示后台分类可以修改
}
public static function categoryBtreeList()
{
}
}

1
antgoods/models/.gitkeep

@ -0,0 +1 @@
*

111
antgoods/models/ars/Attribute.php

@ -0,0 +1,111 @@
<?php
namespace antgoods\models\ars;
use Yii;
use yii\behaviors\TimestampBehavior;
use antgoods\models\ars\Category;
/**
* This is the model class for table "antgoods_attribute".
*
* @property int $id
* @property string $name 属性名
* @property string $value 属性值
* @property int $type 类型
* @property int $sort_order 排序
* @property int $is_delete 是否删除,1为已删除
* @property int $created_at 创建时间
* @property int $updated_at 更新时间
* @property int $cat_id 后台商品分类id
*/
class Attribute extends \yii\db\ActiveRecord
{
//是否删除is_delete
const IS_DELETE_NO = 0;//未删除
const IS_DELETE_YES = 1;//已删除
//类型type
const TYPE_ATTR = 1;//商品sku属性
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'antgoods_attribute';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['name', 'value'], 'required'],
[['value'], 'string'],
[['type', 'sort_order', 'is_delete', 'cat_id'], 'integer'],
[['name'], 'string', 'max' => 50],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'id',
'name' => '规格名称',
'value' => '规格内容(每项以逗号隔开)',
'type' => '类型',
'sort_order' => '排序',
'is_delete' => '是否删除,1为已删除',
'created_at' => '创建时间',
'updated_at' => '更新时间',
'cat_id' => '后台商品分类',
];
}
/**
* @author linyao
* @email 602604991@qq.com
* @created Nov 8, 2019
*
* 行为存储创建时间和更新时间
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => function() {
return time();
},
],
];
}
/**
* @return array
* 数据键值对
*/
public static function modelColumn()
{
return $column = self::find()->select(['name'])->where(['is_delete' => self::IS_DELETE_NO])->indexBy('id')->column();
}
public function beforeSave($insert)
{
if(!$this->type){
$this->type = self::TYPE_ATTR;
}
return parent::beforeSave($insert); // TODO: Change the autogenerated stub
}
public function getCategory()
{
return $this->hasOne(Category::className(), ['id' => 'cat_id']);
}
}

82
antgoods/models/ars/Brand.php

@ -0,0 +1,82 @@
<?php
namespace antgoods\models\ars;
use Yii;
use yii\behaviors\TimestampBehavior;
/**
* This is the model class for table "antgoods_brand".
*
* @property int $id
* @property string $name 品牌名
* @property int $is_delete 是否删除,1为已删除
* @property int $created_at 创建时间
* @property int $updated_at 更新时间
*/
class Brand extends \yii\db\ActiveRecord
{
//是否删除is_delete
const IS_DELETE_NO = 0;//未删除
const IS_DELETE_YES = 1;//已删除
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'antgoods_brand';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['name'], 'required'],
[['is_delete'], 'integer'],
[['name'], 'string', 'max' => 50],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'id',
'name' => '品牌名',
'is_delete' => '是否删除,1为已删除',
'created_at' => '创建时间',
'updated_at' => '更新时间',
];
}
/**
* @author linyao
* @email 602604991@qq.com
* @created Nov 8, 2019
*
* 行为存储创建时间和更新时间
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => function() {
return time();
},
],
];
}
public static function modelColumn()
{
return $column = self::find()->select(['name'])->where(['is_delete' => self::IS_DELETE_NO])->indexBy('id')->column();
}
}

114
antgoods/models/ars/Category.php

@ -0,0 +1,114 @@
<?php
namespace antgoods\models\ars;
use Yii;
use yii\behaviors\TimestampBehavior;
use common\models\ars\File;
/**
* This is the model class for table "antgoods_category".
*
* @property int $id
* @property string $name 类别名称
* @property int $pid 父级id
* @property int $goods_count 商品数量
* @property int $sort_order 排序
* @property int $icon 图标
* @property int $is_show 是否显示,1为不显示
* @property int $is_delete 是否删除,1为已删除
* @property int $created_at 创建时间
* @property int $updated_at 更新时间
*/
class Category extends \yii\db\ActiveRecord
{
public $iconImageId;
public $iconImagePath;
//是否显示is_show
const IS_SHOW_DISPLAY = 0;//显示
const IS_SHOW_HIDE = 1;//隐藏
//是否删除is_delete
const IS_DELETE_NO = 0;//未删除
const IS_DELETE_YES = 1;//已删除
public static $isShow = [
self::IS_SHOW_DISPLAY => '显示',
self::IS_SHOW_HIDE => '隐藏'
];
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'antgoods_category';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['name'], 'required'],
[['pid', 'goods_count', 'sort_order', 'is_show', 'is_delete', 'icon'], 'integer'],
[['name'], 'string', 'max' => 60],
[['iconImageId'], 'string'],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'id',
'name' => '类别名称',
'pid' => '父级',
'goods_count' => '商品数量',
'sort_order' => '排序',
'icon' => '图标',
'is_show' => '是否显示',
'is_delete' => '是否删除,1为已删除',
'created_at' => '创建时间',
'updated_at' => '更新时间',
];
}
/**
* @author linyao
* @email 602604991@qq.com
* @created Nov 8, 2019
*
* 行为存储创建时间和更新时间
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => function() {
return time();
},
],
];
}
/**
* @return array
* 数据键值对
*/
public static function modelColumn()
{
return $column = self::find()->select(['name'])->where(['is_delete' => self::IS_DELETE_NO])->indexBy('id')->column();
}
public function getIconFile()
{
return $this->hasOne(File::className(), ['id' => 'icon']);
}
}

81
antgoods/models/ars/FilterAttr.php

@ -0,0 +1,81 @@
<?php
namespace antgoods\models\ars;
use Yii;
use yii\behaviors\TimestampBehavior;
/**
* This is the model class for table "antgoods_filter_attr".
*
* @property int $id
* @property int $goods_id 商品id
* @property int $attr_id 属性id
* @property string $attr_value 属性值
* @property int $is_delete 是否删除,1为已删除
* @property int $created_at 创建时间
* @property int $updated_at 更新时间
*/
class FilterAttr extends \yii\db\ActiveRecord
{
//是否删除is_delete
const IS_DELETE_NO = 0;//未删除
const IS_DELETE_YES = 1;//已删除
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'antgoods_filter_attr';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['goods_id', 'attr_id', 'attr_value'], 'required'],
[['goods_id', 'attr_id', 'is_delete'], 'integer'],
[['attr_value'], 'string', 'max' => 50],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'id',
'goods_id' => '商品id',
'attr_id' => '属性id',
'attr_value' => '属性值',
'is_delete' => '是否删除,1为已删除',
'created_at' => '创建时间',
'updated_at' => '更新时间',
];
}
/**
* @author linyao
* @email 602604991@qq.com
* @created Nov 8, 2019
*
* 行为存储创建时间和更新时间
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => function() {
return time();
},
],
];
}
}

232
antgoods/models/ars/Goods.php

@ -0,0 +1,232 @@
<?php
namespace antgoods\models\ars;
use Yii;
use yii\behaviors\TimestampBehavior;
use antgoods\models\ars\Category;
use antgoods\models\ars\ShopCategory;
use common\models\ars\File;
use antgoods\models\ars\Brand;
use antgoods\models\ars\Supplier;
/**
* This is the model class for table "antgoods_goods".
*
* @property int $id
* @property int $pid 父级id
* @property int $cat_id 后台商品类别id
* @property int $brand_id 品牌id
* @property int $shop_cat_id 前端商品类别id
* @property string $name 商品名称
* @property string $sn 商品唯一货号
* @property string $code 商品货码
* @property int $supplier_id 供应商id
* @property int $weight 重量
* @property int $length 长度
* @property int $width 宽度
* @property int $height 高度
* @property int $diameter 直径
* @property string $unit 单位
* @property int $sold_count 已售数量
* @property int $limit_count 限购数量
* @property int $stock 库存
* @property int $stock_warn 库存警告
* @property int $market_price 市场价
* @property int $price 销售价
* @property string $brief 简介
* @property string $description 详细介绍
* @property int $image 图片id
* @property int $model_id 模型id
* @property int $is_sale 该商品是否开放销售,1为是,0为否
* @property int $sort_order 排序
* @property int $bouns_points 奖励积分
* @property int $experience_points 经验值
* @property int $is_delete 是否删除,1为已删除
* @property int $express_template 配送详情id
* @property int $created_at 创建时间
* @property int $updated_at 更新时间
* @property int $sku_mode sku类型
*/
class Goods extends \yii\db\ActiveRecord
{
//商品封面图
public $coverImagePath;
public $coverImageId;
//商品详情图
public $detailImagePath;
public $detailImageId;
//是否删除is_delete
const IS_DELETE_NO = 0;//未删除
const IS_DELETE_YES = 1;//已删除
//该商品是否开放销售is_sale
const IS_SALE_NO = 0;//否
const IS_SALE_YES = 1;//是
//sku类型
const SKU_MODE_ATTR = 1;//SKU类型属性
const SKU_MODE_MANUAL = 2;//SKU类型手写
public static $isSale = [
self::IS_SALE_NO => '不在售',
self::IS_SALE_YES => '在售'
];
public $ruleVerify = 0;//规则验证是否通过
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'antgoods_goods';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['pid', 'cat_id', 'brand_id', 'shop_cat_id', 'supplier_id', 'weight', 'length', 'width', 'height', 'diameter', 'sold_count', 'limit_count', 'stock', 'stock_warn', 'market_price', 'price', 'image', 'model_id', 'is_sale', 'sort_order', 'bouns_points', 'experience_points', 'is_delete', 'express_template', 'sku_mode'], 'integer'],
[['cat_id', 'brand_id', 'shop_cat_id', 'name'], 'required'],
[['sn'], 'checkExist'],
[['description', 'coverImageId', 'detailImageId'], 'string'],
[['name'], 'string', 'max' => 120],
[['sn'], 'string', 'max' => 60],
[['code'], 'string', 'max' => 50],
[['unit'], 'string', 'max' => 16],
[['brief'], 'string', 'max' => 255],
[['weight', 'length', 'width', 'height', 'diameter', 'sold_count', 'market_price', 'price'], 'checkNegative'],
];
}
/**
* @param $attribute
* @param $params
* 验证是否为负数
*/
public function checkNegative($attribute, $params)
{
if ($this->$attribute < 0) {
$this->addError($attribute, "不得为负数");
}
}
/**
* @param $attribute
* @param $params
* 验证商品编号唯一
*/
public function checkExist($attribute, $params)
{
$goods = self::find()->where([$attribute => $this->$attribute, 'is_delete' => 0])->one();
if ($this->isNewRecord) {
if ($goods) {
$this->addError($attribute, "该商品编号已经存在");
}
} else {
if ($goods && $goods->id != $this->id) {
$this->addError($attribute, "该商品编号已经存在");
}
}
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'id',
'pid' => '父级id',
'cat_id' => '后台商品类别',
'brand_id' => '品牌',
'shop_cat_id' => '前端商品类别',
'name' => '商品名称',
'sn' => '商品唯一货号',
'code' => '商品货码',
'supplier_id' => '供应商',
'weight' => '重量',
'length' => '长度',
'width' => '宽度',
'height' => '高度',
'diameter' => '直径',
'unit' => '单位',
'sold_count' => '已售数量',
'limit_count' => '限购数量',
'stock' => '库存',
'stock_warn' => '库存警告',
'market_price' => '市场价',
'price' => '销售价',
'brief' => '简介',
'description' => '详细介绍',
'image' => '首页图片',
'model_id' => '模型id',
'is_sale' => '销售状态',
'sort_order' => '排序',
'bouns_points' => '奖励积分',
'experience_points' => '经验值',
'is_delete' => '是否删除,1为已删除',
'express_template' => '配送详情id',
'created_at' => '创建时间',
'updated_at' => '更新时间',
];
}
/**
* @author linyao
* @email 602604991@qq.com
* @created Nov 8, 2019
*
* 行为存储创建时间和更新时间
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => function() {
return time();
},
],
];
}
/**
* @param bool $insert
* @return bool
* 自动填入参数
*/
public function beforeSave($insert)
{
if (!$this->sn) {
$this->sn = time() . rand(1111, 9999);
}
return parent::beforeSave($insert); // TODO: Change the autogenerated stub
}
public function getCategory()
{
return $this->hasOne(Category::className(), ['id' => 'cat_id']);
}
public function getShopCategory()
{
return $this->hasOne(ShopCategory::className(), ['id' => 'shop_cat_id']);
}
public function getImageFile()
{
return $this->hasOne(File::className(), ['id' => 'image']);
}
public function getBrand()
{
return $this->hasOne(Brand::className(), ['id' => 'brand_id']);
}
public function getSupplier()
{
return $this->hasOne(Supplier::className(), ['id' => 'supplier_id']);
}
}

81
antgoods/models/ars/GoodsAttr.php

@ -0,0 +1,81 @@
<?php
namespace antgoods\models\ars;
use Yii;
use yii\behaviors\TimestampBehavior;
/**
* This is the model class for table "antgoods_goods_attr".
*
* @property int $id
* @property int $goods_id 商品id
* @property int $attr_id 属性id
* @property string $attr_value 属性名
* @property int $is_delete 是否删除,1为已删除
* @property int $created_at 创建时间
* @property int $updated_at 更新时间
*/
class GoodsAttr extends \yii\db\ActiveRecord
{
//是否删除is_delete
const IS_DELETE_NO = 0;//未删除
const IS_DELETE_YES = 1;//已删除
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'antgoods_goods_attr';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['attr_value'], 'required'],
[['goods_id', 'attr_id', 'is_delete'], 'integer'],
[['attr_value'], 'string', 'max' => 50],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'id',
'goods_id' => '商品id',
'attr_id' => '属性id',
'attr_value' => '属性名',
'is_delete' => '是否删除,1为已删除',
'created_at' => '创建时间',
'updated_at' => '更新时间',
];
}
/**
* @author linyao
* @email 602604991@qq.com
* @created Nov 8, 2019
*
* 行为存储创建时间和更新时间
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => function() {
return time();
},
],
];
}
}

102
antgoods/models/ars/GoodsSku.php

@ -0,0 +1,102 @@
<?php
namespace antgoods\models\ars;
use Yii;
use yii\behaviors\TimestampBehavior;
/**
* This is the model class for table "antgoods_goods_sku".
*
* @property int $id
* @property int $goods_id 商品id
* @property string $goods_code 商品条码
* @property string $goods_sn 商品唯一货号
* @property string $goods_attr 属性匹配
* @property int $sold_count 已售数量
* @property int $stock 库存
* @property int $market_price 市场价
* @property int $price 销售价
* @property int $model_id 模型id
* @property int $is_sale 该商品是否开放销售,1为是,0为否
* @property int $sort_order 排序
* @property int $is_delete 是否删除,1为已删除
* @property int $created_at 创建时间
* @property int $updated_at 更新时间
* @property int $is_manaul 是否手动
*/
class GoodsSku extends \yii\db\ActiveRecord
{
//是否手动is_manaul
const IS_MANUAL_YES = 1; //是手动
const IS_MANUAL_NO = 0; //不是手动
//是否删除is_delete
const IS_DELETE_NO = 0;//未删除
const IS_DELETE_YES = 1;//已删除
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'antgoods_goods_sku';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['goods_id', 'goods_sn'], 'required'],
[['goods_id', 'diameter', 'sold_count', 'stock', 'market_price', 'price', 'model_id', 'is_sale', 'sort_order', 'is_delete', 'is_manaul'], 'integer'],
[['goods_code'], 'string', 'max' => 50],
[['goods_sn', 'goods_attr'], 'string', 'max' => 60],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'id',
'goods_id' => '商品id',
'goods_code' => '商品条码',
'goods_sn' => '商品唯一货号',
'goods_attr' => '属性匹配',
'sold_count' => '已售数量',
'stock' => '库存',
'market_price' => '市场价',
'price' => '销售价',
'model_id' => '模型id',
'is_sale' => '该商品是否开放销售,1为是,0为否',
'sort_order' => '排序',
'is_delete' => '是否删除,1为已删除',
'created_at' => '创建时间',
'updated_at' => '更新时间',
];
}
/**
* @author linyao
* @email 602604991@qq.com
* @created Nov 8, 2019
*
* 行为存储创建时间和更新时间
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => function() {
return time();
},
],
];
}
}

122
antgoods/models/ars/ShopCategory.php

@ -0,0 +1,122 @@
<?php
namespace antgoods\models\ars;
use Yii;
use yii\behaviors\TimestampBehavior;
use common\models\ars\File;
/**
* This is the model class for table "antgoods_shop_category".
*
* @property int $id
* @property string $name 类别名称
* @property int $pid 父级id
* @property int $goods_count 商品数量
* @property string $keywords 关键字
* @property string $desc 描述
* @property int $sort_order 排序
* @property string $icon 图标
* @property string $filter_attr 筛选属性
* @property int $is_show 是否显示,1为不显示
* @property int $is_delete 是否删除,1为已删除
* @property int $created_at 创建时间
* @property int $updated_at 更新时间
*/
class ShopCategory extends \yii\db\ActiveRecord
{
public $iconImageId;
public $iconImagePath;
//是否显示is_show
const IS_SHOW_DISPLAY = 0;//显示
const IS_SHOW_HIDE = 1;//隐藏
//是否删除is_delete
const IS_DELETE_NO = 0;//未删除
const IS_DELETE_YES = 1;//已删除
public static $isShow = [
self::IS_SHOW_DISPLAY => '显示',
self::IS_SHOW_HIDE => '隐藏'
];
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'antgoods_shop_category';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['name'], 'required'],
[['pid', 'goods_count', 'sort_order', 'icon', 'is_show', 'is_delete', 'iconImageId'], 'integer'],
[['filter_attr'], 'safe'],
[['name'], 'string', 'max' => 60],
[['keywords'], 'string', 'max' => 100],
[['desc'], 'string', 'max' => 255],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'id',
'name' => '类别名称',
'pid' => '父级',
'goods_count' => '商品数量',
'keywords' => '关键字',
'desc' => '描述',
'sort_order' => '排序',
'icon' => '图标',
'filter_attr' => '筛选属性',
'is_show' => '是否显示',
'is_delete' => '是否删除',
'created_at' => '创建时间',
'updated_at' => '更新时间',
];
}
/**
* @author linyao
* @email 602604991@qq.com
* @created Nov 8, 2019
*
* 行为存储创建时间和更新时间
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => function() {
return time();
},
],
];
}
/**
* @return array
* 数据键值对
*/
public static function modelColumn()
{
return $column = self::find()->select(['name'])->where(['is_delete' => self::IS_DELETE_NO])->indexBy('id')->column();
}
public function getIconFile()
{
return $this->hasOne(File::className(), ['id' => 'icon']);
}
}

96
antgoods/models/ars/Supplier.php

@ -0,0 +1,96 @@
<?php
namespace antgoods\models\ars;
use Yii;
use yii\behaviors\TimestampBehavior;
/**
* This is the model class for table "antgoods_supplier".
*
* @property int $id
* @property string $name 供应商名称
* @property string $full_name 供应商全称
* @property string $phone 手机号码
* @property string $address 地址
* @property int $is_delete 是否删除,1为已删除
* @property int $created_at 创建时间
* @property int $updated_at 更新时间
*/
class Supplier extends \yii\db\ActiveRecord
{
//是否删除is_delete
const IS_DELETE_NO = 0;//未删除
const IS_DELETE_YES = 1;//已删除
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'antgoods_supplier';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['name', 'full_name', 'phone', 'address'], 'required'],
[['is_delete'], 'integer'],
[['name', 'full_name', 'address'], 'string', 'max' => 50],
[['phone'], 'string', 'max' => 20],
['phone', 'filter', 'filter' => 'trim'],
['phone','match','pattern'=>'/^[1][34578][0-9]{9}$/'],
['phone', 'unique', 'targetClass' => '\antgoods\models\ars\Supplier', 'message' => '手机号已被使用'],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'id',
'name' => '供应商名称',
'full_name' => '供应商全称',
'phone' => '手机号码',
'address' => '地址',
'is_delete' => '是否删除,1为已删除',
'created_at' => '创建时间',
'updated_at' => '更新时间',
];
}
/**
* @author linyao
* @email 602604991@qq.com
* @created Nov 8, 2019
*
* 行为存储创建时间和更新时间
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => function() {
return time();
},
],
];
}
/**
* @return array
* 数据键值对
*/
public static function modelColumn()
{
return $column = self::find()->select(['name'])->where(['is_delete' => self::IS_DELETE_NO])->indexBy('id')->column();
}
}

162
antgoods/models/searchs/AttributeSearch.php

@ -0,0 +1,162 @@
<?php
namespace antgoods\models\searchs;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use yii\helpers\ArrayHelper;
use antgoods\models\ars\Attribute;
/**
* AttributeSearch represents the model behind the search form of `antgoods\models\ars\Attribute`.
*/
class AttributeSearch extends Attribute
{
/**
* @return array
* 增加创建时间查询字段
*/
public function attributes()
{
return ArrayHelper::merge(['created_at_range'], parent::attributes());
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id', 'type', 'sort_order', 'is_delete', 'created_at', 'updated_at'], 'integer'],
[['name', 'value'], 'safe'],
['created_at_range','safe'],
];
}
/**
* {@inheritdoc}
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* @return array
* 列格式
*/
public function columns()
{
return [
[
'class' => 'blobt\grid\CheckboxColumn',
'width' => '2%',
'align' => 'center'
],
'id',
'name',
'value',
'sort_order',
['attribute' => 'cat_id',
'value' => function ($model){
return $model->cat_id ? $model->category->name : '无限制';
},
],
[
'class' => 'iron\grid\ActionColumn',
'align' => 'center',
'config' => [
[
'name' => 'update',
'icon' => 'pencil',
'title' => '修改'
],
[
'name' => 'delete',
'icon' => 'trash',
'title' => '删除',
'contents' => '确定删除?'
]
],
],
];
}
/**
* @param $params
* @return ActiveDataProvider
* 不分页的所有数据
*/
public function allData($params)
{
$query = Attribute::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => false,
'sort' => false
]);
$this->load($params);
return $this->filter($query, $dataProvider);
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Attribute::find()->where(['is_delete' => Attribute::IS_DELETE_NO]);
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSizeLimit' => [1, 200]
],
'sort' => [
'defaultOrder' => [
'id' => SORT_DESC,
]
],
]);
$this->load($params);
return $this->filter($query, $dataProvider);
}
/**
* @param $query
* @param $dataProvider
* @return ActiveDataProvider
* 条件筛选
*/
private function filter($query, $dataProvider){
$query->andFilterWhere(['is_delete' => Attribute::IS_DELETE_NO]);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
'type' => $this->type,
'sort_order' => $this->sort_order,
'is_delete' => $this->is_delete,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'name', $this->name])
->andFilterWhere(['like', 'value', $this->value]);
if ($this->created_at_range) {
$arr = explode(' ~ ', $this->created_at_range);
$start = strtotime($arr[0]);
$end = strtotime($arr[1]) + 3600 * 24;
$query->andFilterWhere(['between', 'created_at', $start, $end]);
}
return $dataProvider;
}
}

152
antgoods/models/searchs/BrandSearch.php

@ -0,0 +1,152 @@
<?php
namespace antgoods\models\searchs;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use yii\helpers\ArrayHelper;
use antgoods\models\ars\Brand;
/**
* BrandSearch represents the model behind the search form of `antgoods\models\ars\Brand`.
*/
class BrandSearch extends Brand
{
/**
* @return array
* 增加创建时间查询字段
*/
public function attributes()
{
return ArrayHelper::merge(['created_at_range'], parent::attributes());
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id', 'is_delete', 'created_at', 'updated_at'], 'integer'],
[['name'], 'safe'],
['created_at_range','safe'],
];
}
/**
* {@inheritdoc}
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* @return array
* 列格式
*/
public function columns()
{
return [
[
'class' => 'blobt\grid\CheckboxColumn',
'width' => '2%',
'align' => 'center'
],
'id',
'name',
[
'class' => 'iron\grid\ActionColumn',
'align' => 'center',
'config' => [
[
'name' => 'update',
'icon' => 'pencil',
'title' => '修改'
],
[
'name' => 'delete',
'icon' => 'trash',
'title' => '删除',
'contents' => '确定删除?'
]
],
],
];
}
/**
* @param $params
* @return ActiveDataProvider
* 不分页的所有数据
*/
public function allData($params)
{
$query = Brand::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => false,
'sort' => false
]);
$this->load($params);
return $this->filter($query, $dataProvider);
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Brand::find()->where(['is_delete' => Brand::IS_DELETE_NO]);
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSizeLimit' => [1, 200]
],
'sort' => [
'defaultOrder' => [
'id' => SORT_DESC,
]
],
]);
$this->load($params);
return $this->filter($query, $dataProvider);
}
/**
* @param $query
* @param $dataProvider
* @return ActiveDataProvider
* 条件筛选
*/
private function filter($query, $dataProvider){
$query->andFilterWhere(['is_delete' => Brand::IS_DELETE_NO]);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
'is_delete' => $this->is_delete,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'name', $this->name]);
if ($this->created_at_range) {
$arr = explode(' ~ ', $this->created_at_range);
$start = strtotime($arr[0]);
$end = strtotime($arr[1]) + 3600 * 24;
$query->andFilterWhere(['between', 'created_at', $start, $end]);
}
return $dataProvider;
}
}

172
antgoods/models/searchs/CategorySearch.php

@ -0,0 +1,172 @@
<?php
namespace antgoods\models\searchs;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use yii\helpers\ArrayHelper;
use antgoods\models\ars\Category;
use yii\bootstrap4\Html;
/**
* CategorySearch represents the model behind the search form of `antgoods\models\ars\Category`.
*/
class CategorySearch extends Category
{
/**
* @return array
* 增加创建时间查询字段
*/
public function attributes()
{
return ArrayHelper::merge(['created_at_range'], parent::attributes());
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id', 'pid', 'goods_count', 'sort_order', 'is_show', 'is_delete', 'created_at', 'updated_at', 'icon'], 'integer'],
[['name'], 'safe'],
['created_at_range','safe'],
];
}
/**
* {@inheritdoc}
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* @return array
* 列格式
*/
public function columns()
{
return [
[
'class' => 'blobt\grid\CheckboxColumn',
'width' => '2%',
'align' => 'center'
],
'id',
'name',
['attribute' => 'icon',
'contentOptions' => [
'align' => 'center',
],
'width'=>'10%',
'format' => 'raw',
'value' => function ($model) {
return $model->iconFile ?
Html::img(['/'.$model->iconFile->path], ['style' => 'width:80px'])
: '<div class="table_not_setting">未设置</div>';
}
],
'sort_order',
[
'class' => 'iron\grid\ActionColumn',
'align' => 'center',
'config' => [
[
'name' => 'update',
'icon' => 'pencil',
'title' => '修改'
],
[
'name' => 'delete',
'icon' => 'trash',
'title' => '删除',
'contents' => '确定删除?'
]
],
],
];
}
/**
* @param $params
* @return ActiveDataProvider
* 不分页的所有数据
*/
public function allData($params)
{
$query = Category::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => false,
'sort' => false
]);
$this->load($params);
return $this->filter($query, $dataProvider);
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Category::find()->where(['is_delete' => Category::IS_DELETE_NO]);
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSizeLimit' => [1, 200]
],
'sort' => [
'defaultOrder' => [
'id' => SORT_DESC,
]
],
]);
$this->load($params);
return $this->filter($query, $dataProvider);
}
/**
* @param $query
* @param $dataProvider
* @return ActiveDataProvider
* 条件筛选
*/
private function filter($query, $dataProvider){
$query->andFilterWhere(['is_delete' => Category::IS_DELETE_NO]);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
'pid' => $this->pid,
'goods_count' => $this->goods_count,
'sort_order' => $this->sort_order,
'is_show' => $this->is_show,
'is_delete' => $this->is_delete,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'icon' => $this->icon,
]);
$query->andFilterWhere(['like', 'name', $this->name]);
if ($this->created_at_range) {
$arr = explode(' ~ ', $this->created_at_range);
$start = strtotime($arr[0]);
$end = strtotime($arr[1]) + 3600 * 24;
$query->andFilterWhere(['between', 'created_at', $start, $end]);
}
return $dataProvider;
}
}

241
antgoods/models/searchs/GoodsSearch.php

@ -0,0 +1,241 @@
<?php
namespace antgoods\models\searchs;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use yii\helpers\ArrayHelper;
use antgoods\models\ars\Goods;
use yii\bootstrap4\Html;
use antgoods\models\ars\Category;
use antgoods\models\ars\ShopCategory;
/**
* GoodsSearch represents the model behind the search form of `antgoods\models\ars\Goods`.
*/
class GoodsSearch extends Goods
{
/**
* @return array
* 增加创建时间查询字段
*/
public function attributes()
{
return ArrayHelper::merge(['created_at_range'], parent::attributes());
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id', 'pid', 'cat_id', 'brand_id', 'shop_cat_id', 'supplier_id', 'weight', 'length', 'width', 'height', 'diameter', 'sold_count', 'limit_count', 'stock', 'stock_warn', 'market_price', 'price', 'image', 'model_id', 'is_sale', 'sort_order', 'bouns_points', 'experience_points', 'is_delete', 'express_template', 'created_at', 'updated_at'], 'integer'],
[['name', 'sn', 'code', 'unit', 'brief', 'description'], 'safe'],
['created_at_range','safe'],
];
}
/**
* {@inheritdoc}
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* @return array
* 列格式
*/
public function columns()
{
return [
[
'class' => 'blobt\grid\CheckboxColumn',
'width' => '2%',
'align' => 'center'
],
'id',
['attribute' => 'image',
'contentOptions' => [
'align' => 'center',
],
'width'=>'10%',
'format' => 'raw',
'value' => function ($model) {
return $model->image ?
Html::img(['/'.$model->imageFile->path], ['style' => 'width:80px'])
: '<div class="table_not_setting">未设置</div>';
}
],
'name',
[
'attribute' => 'cat_id',
'width' => '10%',
'value' => function ($model) {
return $model->category ? $model->category->name : '';
},
],
[
'attribute' => 'shop_cat_id',
'width' => '10%',
'value' => function ($model) {
return $model->shopCategory ? $model->shopCategory->name : '';
},
],
[
'attribute' => 'stock',
'width' => '5%',
'value' => function ($model) {
if ($model->stock == -1) {
return '未开启';
} else {
return $model->stock;
}
},
],
'price',
['attribute' => 'is_sale',
'width' => '5%',
'value' =>
function ($model) {
return $model->is_sale==Goods::IS_SALE_YES ? '在售' : '不在售';
},
],
'updated_at:datetime',
[
'class' => 'iron\grid\ActionColumn',
'align' => 'center',
'config' => [
[
'name' => 'view',
'icon' => 'list',
'title' => '详情',
],
[
'name' => 'update',
'icon' => 'pencil',
'title' => '修改'
],
[
'name' => 'edit-sku',
'icon' => 'hard-drive',
'title' => '商品sku'
],
[
'name' => 'delete',
'icon' => 'trash',
'title' => '删除',
'contents' => '确定删除?'
]
],
],
];
}
/**
* @param $params
* @return ActiveDataProvider
* 不分页的所有数据
*/
public function allData($params)
{
$query = Goods::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => false,
'sort' => false
]);
$this->load($params);
return $this->filter($query, $dataProvider);
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Goods::find()->where(['is_delete' => Goods::IS_DELETE_NO]);
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSizeLimit' => [1, 200]
],
'sort' => [
'defaultOrder' => [
'id' => SORT_DESC,
]
],
]);
$this->load($params);
return $this->filter($query, $dataProvider);
}
/**
* @param $query
* @param $dataProvider
* @return ActiveDataProvider
* 条件筛选
*/
private function filter($query, $dataProvider){
$query->andFilterWhere(['is_delete' => Goods::IS_DELETE_NO]);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
'pid' => $this->pid,
'cat_id' => $this->cat_id,
'brand_id' => $this->brand_id,
'shop_cat_id' => $this->shop_cat_id,
'supplier_id' => $this->supplier_id,
'weight' => $this->weight,
'length' => $this->length,
'width' => $this->width,
'height' => $this->height,
'diameter' => $this->diameter,
'sold_count' => $this->sold_count,
'limit_count' => $this->limit_count,
'stock' => $this->stock,
'stock_warn' => $this->stock_warn,
'market_price' => $this->market_price,
'price' => $this->price,
'image' => $this->image,
'model_id' => $this->model_id,
'is_sale' => $this->is_sale,
'sort_order' => $this->sort_order,
'bouns_points' => $this->bouns_points,
'experience_points' => $this->experience_points,
'is_delete' => $this->is_delete,
'express_template' => $this->express_template,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'name', $this->name])
->andFilterWhere(['like', 'sn', $this->sn])
->andFilterWhere(['like', 'code', $this->code])
->andFilterWhere(['like', 'unit', $this->unit])
->andFilterWhere(['like', 'brief', $this->brief])
->andFilterWhere(['like', 'description', $this->description]);
if ($this->created_at_range) {
$arr = explode(' ~ ', $this->created_at_range);
$start = strtotime($arr[0]);
$end = strtotime($arr[1]) + 3600 * 24;
$query->andFilterWhere(['between', 'created_at', $start, $end]);
}
return $dataProvider;
}
}

162
antgoods/models/searchs/ShopCategorySearch.php

@ -0,0 +1,162 @@
<?php
namespace antgoods\models\searchs;
use yii\base\Model;
use yii\bootstrap4\Html;
use yii\data\ActiveDataProvider;
use yii\helpers\ArrayHelper;
use antgoods\models\ars\ShopCategory;
/**
* ShopCategorySearch represents the model behind the search form of `antgoods\models\ars\ShopCategory`.
*/
class ShopCategorySearch extends ShopCategory
{
/**
* @return array
* 增加创建时间查询字段
*/
public function attributes()
{
return ArrayHelper::merge(['created_at_range'], parent::attributes());
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id', 'pid', 'goods_count', 'sort_order', 'is_show', 'is_delete', 'created_at', 'updated_at', 'icon'], 'integer'],
[['name', 'keywords', 'desc', 'filter_attr'], 'safe'],
['created_at_range','safe'],
];
}
/**
* {@inheritdoc}
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* @return array
* 列格式
*/
public function columns()
{
return [
[
'class' => 'blobt\grid\CheckboxColumn',
'width' => '2%',
'align' => 'center'
],
'id',
'name',
['attribute' => 'icon',
'contentOptions' => [
'align' => 'center',
],
'width'=>'10%',
'format' => 'raw',
'value' => function ($model) {
return $model->iconFile ?
Html::img(['/'.$model->iconFile->path], ['style' => 'width:80px'])
: '<div class="table_not_setting">未设置</div>';
}
],
'sort_order',
[
'class' => 'iron\grid\ActionColumn',
'align' => 'center',
],
];
}
/**
* @param $params
* @return ActiveDataProvider
* 不分页的所有数据
*/
public function allData($params)
{
$query = ShopCategory::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => false,
'sort' => false
]);
$this->load($params);
return $this->filter($query, $dataProvider);
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = ShopCategory::find()
->where(['is_delete' => ShopCategory::IS_DELETE_NO]);
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSizeLimit' => [1, 200]
],
'sort' => [
'defaultOrder' => [
'id' => SORT_DESC,
]
],
]);
$this->load($params);
return $this->filter($query, $dataProvider);
}
/**
* @param $query
* @param $dataProvider
* @return ActiveDataProvider
* 条件筛选
*/
private function filter($query, $dataProvider){
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
'pid' => $this->pid,
'goods_count' => $this->goods_count,
'sort_order' => $this->sort_order,
'icon' => $this->icon,
'is_show' => $this->is_show,
'is_delete' => $this->is_delete,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'name', $this->name])
->andFilterWhere(['like', 'keywords', $this->keywords])
->andFilterWhere(['like', 'desc', $this->desc])
->andFilterWhere(['like', 'filter_attr', $this->filter_attr]);
if ($this->created_at_range) {
$arr = explode(' ~ ', $this->created_at_range);
$start = strtotime($arr[0]);
$end = strtotime($arr[1]) + 3600 * 24;
$query->andFilterWhere(['between', 'created_at', $start, $end]);
}
return $dataProvider;
}
}

161
antgoods/models/searchs/SupplierSearch.php

@ -0,0 +1,161 @@
<?php
namespace antgoods\models\searchs;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use yii\helpers\ArrayHelper;
use antgoods\models\ars\Supplier;
/**
* SupplierSearch represents the model behind the search form of `antgoods\models\ars\Supplier`.
*/
class SupplierSearch extends Supplier
{
/**
* @return array
* 增加创建时间查询字段
*/
public function attributes()
{
return ArrayHelper::merge(['created_at_range'], parent::attributes());
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id', 'is_delete', 'created_at', 'updated_at'], 'integer'],
[['name', 'full_name', 'phone', 'address'], 'safe'],
['created_at_range','safe'],
];
}
/**
* {@inheritdoc}
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* @return array
* 列格式
*/
public function columns()
{
return [
[
'class' => 'blobt\grid\CheckboxColumn',
'width' => '2%',
'align' => 'center'
],
'id',
'name',
'full_name',
'phone',
'address',
//'is_delete',
//'created_at',
//'updated_at',
[
'class' => 'iron\grid\ActionColumn',
'align' => 'center',
'config' => [
[
'name' => 'update',
'icon' => 'pencil',
'title' => '修改'
],
[
'name' => 'delete',
'icon' => 'trash',
'title' => '删除',
'contents' => '确定删除?'
]
],
],
];
}
/**
* @param $params
* @return ActiveDataProvider
* 不分页的所有数据
*/
public function allData($params)
{
$query = Supplier::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => false,
'sort' => false
]);
$this->load($params);
return $this->filter($query, $dataProvider);
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Supplier::find()->where(['is_delete' => Supplier::IS_DELETE_NO]);
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSizeLimit' => [1, 200]
],
'sort' => [
'defaultOrder' => [
'id' => SORT_DESC,
]
],
]);
$this->load($params);
return $this->filter($query, $dataProvider);
}
/**
* @param $query
* @param $dataProvider
* @return ActiveDataProvider
* 条件筛选
*/
private function filter($query, $dataProvider){
$query->andFilterWhere(['is_delete' => Supplier::IS_DELETE_NO]);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
'is_delete' => $this->is_delete,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'name', $this->name])
->andFilterWhere(['like', 'full_name', $this->full_name])
->andFilterWhere(['like', 'phone', $this->phone])
->andFilterWhere(['like', 'address', $this->address]);
if ($this->created_at_range) {
$arr = explode(' ~ ', $this->created_at_range);
$start = strtotime($arr[0]);
$end = strtotime($arr[1]) + 3600 * 24;
$query->andFilterWhere(['between', 'created_at', $start, $end]);
}
return $dataProvider;
}
}

32
antgoods/views/attribute/_form.php

@ -0,0 +1,32 @@
<?php
use yii\helpers\Html;
use yii\bootstrap4\ActiveForm;
use linyao\widgets\Select2;
use antgoods\models\ars\Category;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\Attribute */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="attribute-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'value')->textarea(['rows' => 6]) ?>
<?= $form->field($model, 'sort_order')->textInput() ?>
<?= $form->field($model, 'cat_id')->widget(Select2::className(), ["items" => array_merge([0 => '请选择'], Category::modelColumn()), "promptText" => false]) ?>
<div class="form-group">
<?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>
<?= Html::a('返回', ['index'], ['class' => 'btn btn-info']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

49
antgoods/views/attribute/_search.php

@ -0,0 +1,49 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use \blobt\widgets\DateRangePicker;
/* @var $this yii\web\View */
/* @var $model common\models\searchs\AttributeSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
'validateOnType' => true,
]);
?>
<div class="row">
<div class="col">
<?= $form->field($model, 'id', [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "检索ID",
"class" => "form-control",
],
"errorOptions" => [
"class" => "error-tips"
]
])
?>
</div>
<div class="col">
<?= $form->field($model, "created_at_range", [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "创建时间",
],
"errorOptions" => [
"class" => "error-tips"
]
])->widget(DateRangePicker::className());
?>
</div>
<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>
<?php ActiveForm::end(); ?>

18
antgoods/views/attribute/create.php

@ -0,0 +1,18 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\Attribute */
$this->title = '创建规格';
$this->params['breadcrumbs'][] = ['label' => '规格管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="attribute-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

28
antgoods/views/attribute/index.php

@ -0,0 +1,28 @@
<?php
use yii\helpers\Html;
use iron\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel common\models\searchs\AttributeSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = '规格管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="row">
<div class="col-12">
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filter' => $this->render("_search", ['model' => $searchModel]),
'batch' => [
[
"label" => "删除",
"url" => "attribute/deletes"
],
],
'columns' => $columns
]);
?>
</div>
</div>

19
antgoods/views/attribute/update.php

@ -0,0 +1,19 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\Attribute */
$this->title = '编辑规格: ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => '规格管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update ';
?>
<div class="attribute-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

33
antgoods/views/attribute/view.php

@ -0,0 +1,33 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\Attribute */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => '规格管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="attribute-view">
<p>
<?= Html::a('返回列表', ['index'], ['class' => 'btn btn-success']) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'name',
'value:ntext',
'type',
'sort_order',
'created_at:datetime',
'updated_at:datetime',
],
]) ?>
</div>

24
antgoods/views/brand/_form.php

@ -0,0 +1,24 @@
<?php
use yii\helpers\Html;
use yii\bootstrap4\ActiveForm;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\Brand */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="brand-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<div class="form-group">
<?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>
<?= Html::a('返回', ['index'], ['class' => 'btn btn-info']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

49
antgoods/views/brand/_search.php

@ -0,0 +1,49 @@
<?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="row">
<div class="col">
<?= $form->field($model, 'id', [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "检索ID",
"class" => "form-control",
],
"errorOptions" => [
"class" => "error-tips"
]
])
?>
</div>
<div class="col">
<?= $form->field($model, "created_at_range", [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "创建时间",
],
"errorOptions" => [
"class" => "error-tips"
]
])->widget(DateRangePicker::className());
?>
</div>
<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>
<?php ActiveForm::end(); ?>

18
antgoods/views/brand/create.php

@ -0,0 +1,18 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\Brand */
$this->title = '创建品牌';
$this->params['breadcrumbs'][] = ['label' => '品牌管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="brand-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

28
antgoods/views/brand/index.php

@ -0,0 +1,28 @@
<?php
use yii\helpers\Html;
use iron\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel common\models\searchs\BrandSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = '品牌管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="row">
<div class="col-12">
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filter' => $this->render("_search", ['model' => $searchModel]),
'batch' => [
[
"label" => "删除",
"url" => "brand/deletes"
],
],
'columns' => $columns
]);
?>
</div>
</div>

19
antgoods/views/brand/update.php

@ -0,0 +1,19 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\Brand */
$this->title = '编辑品牌: ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => '品牌管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = '编辑 ';
?>
<div class="brand-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

30
antgoods/views/brand/view.php

@ -0,0 +1,30 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\Brand */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => '品牌管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="brand-view">
<p>
<?= Html::a('返回列表', ['index'], ['class' => 'btn btn-success']) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'name',
'created_at:datetime',
'updated_at:datetime',
],
]) ?>
</div>

47
antgoods/views/category/_form.php

@ -0,0 +1,47 @@
<?php
use yii\helpers\Html;
use yii\bootstrap4\ActiveForm;
use blobt\widgets\Icheck;
use yii\helpers\Url;
use antgoods\models\ars\Category;
/* @var $this yii\web\View */
/* @var $model antgoods\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')->dropDownList(array_merge([0 => '一级分类'], Category::modelColumn())) ?>
<?= $form->field($model, 'sort_order')->textInput() ?>
<?= $form->field($model, 'iconImageId')->hiddenInput()->label('') ?>
<?= $form->field($model, 'iconImagePath')->widget(\iron\widgets\Upload::className(), [
'url' => 'upload',
'deleteUrl' => 'img-id-del',
'dragdropWidth'=> 800,
'afterSave' => 'save-file',
'maxCount' => 1,
'fillInAttribute' => 'iconImageId',
'model' => $model,
'previewConfig' => [
'url' => Url::to(['image-file', 'fileidstr' => $model->iconImageId]),
],
])->label('类目图片') ?>
<?= $form->field($model, 'is_show')->widget(Icheck::className(), ["items" => $model::$isShow, 'type' => "radio"]) ?>
<div class="form-group">
<?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>
<?= Html::a('返回', ['index'], ['class' => 'btn btn-info']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

49
antgoods/views/category/_search.php

@ -0,0 +1,49 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use \blobt\widgets\DateRangePicker;
/* @var $this yii\web\View */
/* @var $model common\models\searchs\CategorySearch */
/* @var $form yii\widgets\ActiveForm */
?>
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
'validateOnType' => true,
]);
?>
<div class="row">
<div class="col">
<?= $form->field($model, 'id', [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "检索ID",
"class" => "form-control",
],
"errorOptions" => [
"class" => "error-tips"
]
])
?>
</div>
<div class="col">
<?= $form->field($model, "created_at_range", [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "创建时间",
],
"errorOptions" => [
"class" => "error-tips"
]
])->widget(DateRangePicker::className());
?>
</div>
<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>
<?php ActiveForm::end(); ?>

18
antgoods/views/category/create.php

@ -0,0 +1,18 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\Category */
$this->title = '创建后台商品分类';
$this->params['breadcrumbs'][] = ['label' => '后台商品分类', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="category-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

28
antgoods/views/category/index.php

@ -0,0 +1,28 @@
<?php
use yii\helpers\Html;
use iron\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel common\models\searchs\CategorySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = '后台商品分类';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="row">
<div class="col-12">
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filter' => $this->render("_search", ['model' => $searchModel]),
'batch' => [
[
"label" => "删除",
"url" => "category/deletes"
],
],
'columns' => $columns
]);
?>
</div>
</div>

19
antgoods/views/category/update.php

@ -0,0 +1,19 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\Category */
$this->title = '编辑后台商品分类: ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => '后台商品分类', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = '编辑 ';
?>
<div class="category-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

41
antgoods/views/category/view.php

@ -0,0 +1,41 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\Category */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => '后台商品分类', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="category-view">
<p>
<?= Html::a('返回列表', ['index'], ['class' => 'btn btn-success']) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'name',
'pid',
'goods_count',
'sort_order',
'icon_type',
'icon',
[
'attribute' => 'is_show',
'value' => function ($model) {
return $model->is_show == \antgoods\models\ars\Category::IS_SHOW_DISPLAY ? '显示':'隐藏';
}
],
'created_at:datetime',
'updated_at:datetime',
],
]) ?>
</div>

27
antgoods/views/config/index.php

@ -0,0 +1,27 @@
<?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.
*/
?>
配置页

107
antgoods/views/goods/_form.php

@ -0,0 +1,107 @@
<?php
use yii\helpers\Html;
use yii\bootstrap4\ActiveForm;
use antgoods\models\ars\Category;
use antgoods\models\ars\Brand;
use antgoods\models\ars\ShopCategory;
use antgoods\models\ars\Supplier;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\Goods */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="goods-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'cat_id')->dropDownList(Category::modelColumn(), ['prompt' => '请选择']) ?>
<?= $form->field($model, 'brand_id')->dropDownList(Brand::modelColumn(), ['prompt' => '请选择']) ?>
<?= $form->field($model, 'shop_cat_id')->dropDownList(ShopCategory::modelColumn(), ['prompt' => '请选择']) ?>
<?= $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')->dropDownList(Supplier::modelColumn(), ['prompt' => '请选择']) ?>
<?= $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, '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, 'model_id')->textInput() ?>
<?= $form->field($model, 'is_sale')->radioList($model::$isSale) ?>
<?= $form->field($model, 'sort_order')->textInput() ?>
<?= $form->field($model, 'bouns_points')->textInput() ?>
<?= $form->field($model, 'experience_points')->textInput() ?>
<?= $form->field($model, 'express_template')->textInput() ?>
<?= $form->field($model, 'coverImageId')->hiddenInput()->label('') ?>
<?= $form->field($model, 'coverImagePath')->widget(\iron\widgets\Upload::className(), [
'url' => 'upload',
'deleteUrl' => 'img-id-del',
'dragdropWidth'=> 800,
'afterSave' => 'save-file',
'maxCount' => 1,
'fillInAttribute' => 'coverImageId',
'model' => $model,
'previewConfig' => [
'url' => Url::to(['image-file', 'fileidstr' => $model->coverImageId]),
],
])->label('商品封面图') ?>
<?= $form->field($model, 'detailImageId')->hiddenInput()->label('') ?>
<?= $form->field($model, 'detailImagePath')->widget(\iron\widgets\Upload::className(), [
'url' => 'upload',
'deleteUrl' => 'img-id-del',
'dragdropWidth'=> 800,
'afterSave' => 'save-file',
'maxCount' => 5,
'fillInAttribute' => 'detailImageId',
'model' => $model,
'previewConfig' => [
'url' => Url::to(['image-file', 'fileidstr' => $model->detailImageId]),
],
])->label('商品详情图') ?>
<div class="form-group">
<?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>
<?= Html::a('返回', ['index'], ['class' => 'btn btn-info']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

49
antgoods/views/goods/_search.php

@ -0,0 +1,49 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use \blobt\widgets\DateRangePicker;
/* @var $this yii\web\View */
/* @var $model common\models\searchs\GoodsSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
'validateOnType' => true,
]);
?>
<div class="row">
<div class="col">
<?= $form->field($model, 'id', [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "检索ID",
"class" => "form-control",
],
"errorOptions" => [
"class" => "error-tips"
]
])
?>
</div>
<div class="col">
<?= $form->field($model, "created_at_range", [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "创建时间",
],
"errorOptions" => [
"class" => "error-tips"
]
])->widget(DateRangePicker::className());
?>
</div>
<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>
<?php ActiveForm::end(); ?>

22
antgoods/views/goods/attribute.php

@ -0,0 +1,22 @@
<?php
use antgoods\models\ars\Attribute;
use antgoods\web\GoodsAttributeAsset;
$param = [];
$value = [];
$attrId = [];
$allAttr = Attribute::find()->where(['type' => Attribute::TYPE_ATTR])->asArray()->all();
GoodsAttributeAsset::register($this);
?>
<div class="content-box">
<input type="hidden" id="attribute" name="attribute"/>
<div id="sku-choose"></div>
</div>
<script>
var csrf = "<?= Yii::$app->request->csrfToken ?>";
var allAttr = <?= isset($allAttr) ? json_encode($allAttr) : [] ?>; // 所有数据
var currentAttr = <?= isset($model) ? json_encode($model) : [] ?>; // 默认数据(之前已选择的数据)
var canNotDeleteAttr =<?=isset($attrValue) ? json_encode($attrValue) : [] ?>; // 已设置sku的值,不可删除
</script>

72
antgoods/views/goods/create.php

@ -0,0 +1,72 @@
<?php
use kartik\tabs\TabsX;
use yii\bootstrap4\ActiveForm;
use yii\bootstrap4\Html;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\Goods */
$this->title = '创建商品';
$this->params['breadcrumbs'][] = ['label' => '商品列表', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
Yii::$app->params['bsVersion'] = '4.x';
?>
<div class="goods-create">
<div class="goods-form">
<?php
$form = ActiveForm::begin(['options' => ['class' => 'container-fluid']]);
echo TabsX::widget([
'bordered' => true,
'items' => [
[
'label' => '<i class="fas fa-user"></i> 基本信息',
'content' => $this->render('goods', ['model' => $model,
'form' => $form,
'judgeGoodsCategory' => false, //表示后台分类可以修改
]),
],
[
'label' => '<i class="fas fa-list-alt"></i> 筛选规格',
'content' => $this->render('filter_attribute', [
'filterModel' => [],
'filterAttrValue' => [],
]),
],
[
'label' => '<i class="fas fa-list-alt"></i> 商品规格',
'content' => $this->render('attribute', [
'model' => [],
'attrValue' => [],
]),
],
[
'label' => '<i class="fas fa-ad"></i> 详情上传',
'content' => $this->render('new_editor', ['model' => $model,
'form' => $form,
]),
],
[
'label' => '<i class="fas fa-picture-o"></i> 图片上传',
'content' => $this->render('picture', [
'model' => $model,
'form' => $form
]),
],
],
'position' => TabsX::POS_ABOVE,
'encodeLabels' => false
]);
?>
<div class="form-group">
<?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>
<?= Html::a('返回', ['index'], ['class' => 'btn btn-info']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>

22
antgoods/views/goods/filter_attribute.php

@ -0,0 +1,22 @@
<?php
use antgoods\models\ars\Attribute;
use antgoods\web\GoodsFilterAttributeAsset;
$param = [];
$value = [];
$attrId = [];
$allFilterAttr = Attribute::find()->where(['type' => Attribute::TYPE_ATTR])->asArray()->all();
GoodsFilterAttributeAsset::register($this);
?>
<div class="content-box">
<input type="hidden" id="attribute" name="attribute"/>
<div id="filter-choose"></div>
</div>
<script>
var csrf = "<?= Yii::$app->request->csrfToken ?>";
var allFilterAttr = <?= isset($allFilterAttr) ? json_encode($allFilterAttr) : [] ?>; // 所有数据
var currentFilterAttr = <?= isset($filterModel) ? json_encode($filterModel) : [] ?>; // 默认数据(之前已选择的数据)
var canNotDeleteFilterAttr =<?=isset($filterAttrValue) ? json_encode($filterAttrValue) : [] ?>; // 已设置sku的值,不可删除
</script>

63
antgoods/views/goods/goods.php

@ -0,0 +1,63 @@
<?php
use antgoods\models\ars\Category;
use antgoods\models\ars\Brand;
use antgoods\models\ars\ShopCategory;
use antgoods\models\ars\Supplier;
use linyao\widgets\Select2;
use yii\bootstrap4\Html;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\Goods */
/* @var $form yii\widgets\ActiveForm */
?>
<?= $form->field($model, 'cat_id')->dropDownList(Category::modelColumn(), ['prompt' => '请选择', 'disabled' => $judgeGoodsCategory]) ?>
<?= $form->field($model, 'brand_id')->dropDownList(Brand::modelColumn(), ['prompt' => '请选择']) ?>
<?= $form->field($model, 'shop_cat_id')->dropDownList(ShopCategory::modelColumn(), ['prompt' => '请选择']) ?>
<?= $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')->dropDownList(Supplier::modelColumn(), ['prompt' => '请选择']) ?>
<?= $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, '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, 'is_sale')->radioList($model::$isSale) ?>
<?= $form->field($model, 'sort_order')->textInput() ?>
<?= $form->field($model, 'bouns_points')->textInput() ?>
<?= $form->field($model, 'experience_points')->textInput() ?>
<div class="form-group">
<?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>
<?= Html::a('返回', ['index'], ['class' => 'btn btn-info']) ?>
</div>

28
antgoods/views/goods/index.php

@ -0,0 +1,28 @@
<?php
use yii\helpers\Html;
use iron\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel common\models\searchs\GoodsSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = '商品列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="row">
<div class="col-12">
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filter' => $this->render("_search", ['model' => $searchModel]),
'batch' => [
[
"label" => "删除",
"url" => "goods/deletes"
],
],
'columns' => $columns
]);
?>
</div>
</div>

31
antgoods/views/goods/new_editor.php

@ -0,0 +1,31 @@
<?php
/**
* Created by PhpStorm.
* User: livan
* Date: 2018/7/9
* Time: 14:22
*/
use yii\helpers\Html;
?>
<div>
<div class="row">
<div class="col-lg-3">
<?= $form->field($model, 'description')->widget('common\widgets\ueditor\Ueditor',[
'options'=>[
'initialFrameWidth' => 760,//宽度
'initialFrameHeight' => 500,//高度
]
]) ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>
</div>
</div>

37
antgoods/views/goods/picture.php

@ -0,0 +1,37 @@
<?php
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\Goods */
/* @var $form yii\widgets\ActiveForm */
?>
<?= $form->field($model, 'coverImageId')->hiddenInput()->label('') ?>
<?= $form->field($model, 'coverImagePath')->widget(\iron\widgets\Upload::className(), [
'url' => 'upload',
'deleteUrl' => 'img-id-del',
'dragdropWidth'=> 800,
'afterSave' => 'save-file',
'maxCount' => 1,
'fillInAttribute' => 'coverImageId',
'model' => $model,
'ruleVerify' => $model->ruleVerify,
'previewConfig' => [
'url' => Url::to(['image-file', 'fileidstr' => $model->coverImageId]),
],
])->label('商品封面图') ?>
<?= $form->field($model, 'detailImageId')->hiddenInput()->label('') ?>
<?= $form->field($model, 'detailImagePath')->widget(\iron\widgets\Upload::className(), [
'url' => 'upload',
'deleteUrl' => 'img-id-del',
'dragdropWidth'=> 800,
'afterSave' => 'save-file',
'maxCount' => 5,
'fillInAttribute' => 'detailImageId',
'model' => $model,
'ruleVerify' => $model->ruleVerify,
'previewConfig' => [
'url' => Url::to(['image-file', 'fileidstr' => $model->detailImageId]),
],
])->label('商品详情图') ?>

15
antgoods/views/goods/sku_edit.php

@ -0,0 +1,15 @@
<?php
use antgoods\web\GoodsSkuEditAsset;
$this->title = '添加SKU';
$this->params['breadcrumbs'][] = ['label' => '商品列表', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
GoodsSkuEditAsset::register($this);
?>
<div id="app"></div>
<script>
var sku = <?=json_encode($sku)?>;
var attributes = <?=json_encode($attributes)?>;
var csrfToken = "<?= Yii::$app->request->csrfToken ?>";
</script>

74
antgoods/views/goods/update.php

@ -0,0 +1,74 @@
<?php
use yii\bootstrap4\Html;
use yii\bootstrap4\ActiveForm;
use kartik\tabs\TabsX;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\Goods */
$this->title = '编辑商品: ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => '商品管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = '编辑 ';
Yii::$app->params['bsVersion'] = '4.x';
?>
<div class="goods-update">
<div class="goods-form">
<?php
$form = ActiveForm::begin(['options' => ['class' => 'container-fluid']]);
echo TabsX::widget([
'bordered' => true,
'items' => [
[
'label' => '<i class="fas fa-user"></i> 基本信息',
'content' => $this->render('goods', [
'model' => $model,
'form' => $form,
'judgeGoodsCategory' => $judgeGoodsCategory
]),
],
[
'label' => '<i class="fas fa-list-alt"></i> 筛选规格',
'content' => $this->render('filter_attribute', [
'filterModel' => $filterAttributeModel,
'filterAttrValue' => [],
]),
],
[
'label' => '<i class="fas fa-list-alt"></i> 商品规格',
'content' => $this->render('attribute', [
'model' => $attributeModel,
'attrValue' => $attrValue,
'goodsModel' => $model,
]),
],
[
'label' => '<i class="fas fa-picture-o"></i> 图片上传',
'content' => $this->render('picture', [
'model' => $model,
'form' => $form,
]),
],
],
'position' => TabsX::POS_ABOVE,
'encodeLabels' => false
]);
?>
<div class="form-group">
<?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>
<?= Html::a('返回', ['index'], ['class' => 'btn btn-info']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
<?php
// $this->render('_form', [
// 'model' => $model,
// ])
?>
</div>

113
antgoods/views/goods/view.php

@ -0,0 +1,113 @@
<?php
use antgoods\models\ars\Goods;
use yii\bootstrap4\Html;
use yii\widgets\DetailView;
use common\models\ars\File;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\Goods */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => '商品管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="goods-view">
<p>
<?= Html::a('返回列表', ['index'], ['class' => 'btn btn-success']) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'name',
'sn',
[
'attribute' => 'cat_id',
'width' => '10%',
'value' => function ($model) {
return $model->category ? $model->category->name : '';
},
],
[
'attribute' => 'shop_cat_id',
'width' => '10%',
'value' => function ($model) {
return $model->shopCategory ? $model->shopCategory->name : '';
},
],
[
'attribute' => 'brand_id',
'width' => '10%',
'value' => function ($model) {
return $model->brand ? $model->brand->name : '';
},
],
'code',
[
'attribute' => 'supplier_id',
'width' => '10%',
'value' => function ($model) {
return $model->supplier ? $model->supplier->name : '';
},
],
'weight',
'length',
'width',
'height',
'diameter',
'unit',
[
'attribute' => 'stock',
'width' => '5%',
'value' => function ($model) {
if ($model->stock == -1) {
return '未开启';
} else {
return $model->stock;
}
},
],
'market_price',
'price',
'brief',
['attribute' => 'image',
'format' => 'raw',
'value' => function ($model) {
return $model->image ?
Html::img(['/'.$model->imageFile->path], ['style' => 'width:80px'])
: '<div class="table_not_setting">未设置</div>';
}
],
[
'label' => '详情图',
'format' => 'raw',
'value' => function ($model) {
$image = '';
$imgs = File::findAll(['own_id' => $model->id, 'own_type' => File::OWN_TYPE_GOODS_DETAILS, 'is_delete' => File::IS_DELETE_NO]);
foreach ($imgs as $img) {
$image .= Html::img(['/'.$img->path], ['style' => 'width:150px']);
}
return $image;
}
],
['attribute' => 'is_sale',
'width' => '5%',
'value' =>
function ($model) {
return $model->is_sale ? Goods::$isSale[$model->is_sale] : '未设置';
},
],
'sort_order',
'created_at:datetime',
'updated_at:datetime',
],
]) ?>
</div>

33
antgoods/views/layouts/base.php

@ -0,0 +1,33 @@
<?php
/* @var $this \yii\web\View */
/* @var $content string */
use backend\assets\AppAsset;
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use common\widgets\Alert;
AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php $this->registerCsrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<?= $content ?>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>

25
antgoods/views/layouts/breadcrumb.php

@ -0,0 +1,25 @@
<?PHP
use yii\widgets\Breadcrumbs;
?>
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<?php if (!empty($this->title)): ?>
<h1><?= $this->title ?><?php if (isset($this->params['subtitle'])): ?>
<small><?= $this->params['subtitle'] ?></small><?php endif ?></h1>
<?php endif ?>
</div>
<div class="col-sm-6">
<?php
echo Breadcrumbs::widget([
'tag' => 'ol',
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
'itemTemplate' => "<li class='breadcrumb-item'>{link}</li>\n",
'activeItemTemplate' => "<li class=\"breadcrumb-item active\">{link}</li>\n",
'options' => ['class' => 'breadcrumb float-sm-right']
]);
?>
</div>
</div>

7
antgoods/views/layouts/footer.php

@ -0,0 +1,7 @@
<footer class="main-footer">
<div class="pull-right hidden-xs">
<b>Version</b> 0.1.0
</div>
<strong>Copyright &copy; 2014-2019 <a href="https://kuaichuangkeji.com">KcAdmin</a>.</strong> All rights
reserved.
</footer>

67
antgoods/views/layouts/header.php

@ -0,0 +1,67 @@
<?php
use yii\helpers\Html;
?>
<header>
<div class="wrapper">
<!-- Navbar -->
<nav class="main-header navbar navbar-expand navbar-white navbar-light">
<!-- Left navbar links -->
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" data-widget="pushmenu" href="#"><i class="fas fa-bars"></i></a>
</li>
<li class="nav-item d-none d-sm-inline-block">
<a href="#" class="nav-link">Home</a>
</li>
</ul>
<!-- Right navbar links -->
<ul class="navbar-nav ml-auto">
<!-- Messages Dropdown Menu -->
<li class="nav-item dropdown">
<a class="nav-link" data-toggle="dropdown" href="#">
<i class="far fa-comments"></i>
<span class="badge badge-danger navbar-badge">3</span>
</a>
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
<div class="dropdown-divider"></div>
<div class="dropdown-divider"></div>
<div class="dropdown-divider"></div>
<a href="#" class="dropdown-item dropdown-footer">See All Messages</a>
</div>
</li>
<!-- Notifications Dropdown Menu -->
<li class="nav-item user-menu ">
<a href="#" class="nav-link" data-toggle="dropdown">
<i class="fas fa-th-large"></i>
<!-- <img src="/img/user2-160x160.jpg" class="user-image" alt="User Image">-->
<!-- <span class="hidden-xs">-->
<? //= yii::$app->user->identity->username ?><!--</span>-->
</a>
<ul class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
<!-- User image -->
<li class="user-header">
<img src="/img/user2-160x160.jpg" class="img-circle" alt="User Image">
<p>
<?= yii::$app->user->identity->username ?>
<small>Member since <?= date('m-d-Y', yii::$app->user->identity->created_at) ?></small>
</p>
</li>
<!-- Menu Footer-->
<li class="user-footer">
<div class="pull-left">
<?= Html::a('个人设置', ['/site/profile'], ['class' => 'btn btn-default btn-flat']) ?>
</div>
<div class="pull-right">
<?= Html::a('退出', ['/site/logout'], ['data-method' => 'post', 'class' => 'btn btn-default btn-flat']) ?>
</div>
</li>
</ul>
<!-- <a class="nav-link" data-widget="control-sidebar" data-slide="true" href="#"><i-->
<!-- class="fas fa-th-large"></i></a>-->
</li>
</ul>
</nav>
</header>

57
antgoods/views/layouts/main.php

@ -0,0 +1,57 @@
<?php
/* @var $this \yii\web\View */
/* @var $content string */
use backend\assets\AppAsset;
use yii\helpers\Html;
use yii\widgets\Breadcrumbs;
use common\widgets\Alert;
AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<?php $this->registerCsrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<?php if (YII_ENV == 'dev'){?>
<!-- 开发环境版本,包含了有帮助的命令行警告 -->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<?php } else {?>
<!-- 生产环境版本,优化了尺寸和速度 -->
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<?php } ?>
<?php $this->head() ?>
</head>
<body class="hold-transition skin-blue-light sidebar-mini">
<?php $this->beginBody() ?>
<div class="wrapper">
<?= $this->render('header') ?>
<?= $this->render('sidebar') ?>
<div class="content-wrapper">
<?php
if (Yii::$app->session->hasFlash('error') || Yii::$app->session->hasFlash('success')) {
echo Alert::widget();
}
?>
<section class="content-header">
<?= $this->render('breadcrumb') ?>
</section>
<section class="content">
<?= $content ?>
</section>
</div>
<?= $this->render('footer') ?>
</div>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>

33
antgoods/views/layouts/sidebar.php

@ -0,0 +1,33 @@
<?php
use iron\widgets\Menu;
?>
<aside class="main-sidebar sidebar-dark-info elevation-4">
<a href="#" class="brand-link">
<img src="/img/logo.jpeg" alt="AdminLTE" class="brand-image img-circle elevation-3"
style="opacity: .8">
<span class="brand-text font-weight-light">AdminLTE 3</span>
</a>
<!-- sidebar: style can be found in sidebar.less -->
<section class="sidebar">
<?php
echo Menu::widget([
'items' => [
// ['label' => 'MAIN NAVIGATION', 'is_header' => true],
['label' => '商品管理', 'url' => '#', 'icon' => 'far fa-box', 'items' => [
['label' => '后台商品分类', 'url' => ['/category/index']],
['label' => '规格管理', 'url' => ['/attribute/index']],
['label' => '前端商品分类', 'url' => ['/shop-category/index']],
['label' => '品牌管理', 'url' => ['/brand/index']],
['label' => '供应商管理', 'url' => ['/supplier/index']],
['label' => '商品列表', 'url' => ['/goods/index']],
]
],
]
]);
?>
</section>
<!-- /.sidebar -->
</aside>

55
antgoods/views/shop-category/_form.php

@ -0,0 +1,55 @@
<?php
use yii\helpers\Html;
use yii\bootstrap4\ActiveForm;
use blobt\widgets\Icheck;
use yii\helpers\Url;
use antgoods\models\ars\Attribute;
use linyao\widgets\Select2;
use antgoods\models\ars\ShopCategory;
/* @var $this yii\web\View */
/* @var $model antgoods\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, 'keywords')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'pid')->dropDownList(array_merge([0 => '一级分类'], ShopCategory::modelColumn())) ?>
<?= $form->field($model, 'desc')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'sort_order')->textInput() ?>
<?= $form->field($model, 'iconImageId')->hiddenInput()->label('') ?>
<?= $form->field($model, 'iconImagePath')->widget(\iron\widgets\Upload::className(), [
'url' => 'upload',
'deleteUrl' => 'img-id-del',
'dragdropWidth'=> 800,
'afterSave' => 'save-file',
'maxCount' => 1,
'fillInAttribute' => 'iconImageId',
'model' => $model,
'previewConfig' => [
'url' => Url::to(['image-file', 'fileidstr' => $model->iconImageId]),
],
])->label('类目图片') ?>
<?= $form->field($model, 'filter_attr')->widget(Select2::className(), ["items" => Attribute::modelColumn(), "promptText" => false, 'options' => ['multiple' => true, 'placeholder' => '请选择...'] ]) ?>
<?= $form->field($model, 'is_show')->widget(Icheck::className(), ["items" => $model::$isShow, 'type' => "radio"]) ?>
<div class="form-group">
<?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>
<?= Html::a('返回', ['index'], ['class' => 'btn btn-info']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

49
antgoods/views/shop-category/_search.php

@ -0,0 +1,49 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use \blobt\widgets\DateRangePicker;
/* @var $this yii\web\View */
/* @var $model common\models\searchs\ShopCategorySearch */
/* @var $form yii\widgets\ActiveForm */
?>
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
'validateOnType' => true,
]);
?>
<div class="row">
<div class="col">
<?= $form->field($model, 'id', [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "检索ID",
"class" => "form-control",
],
"errorOptions" => [
"class" => "error-tips"
]
])
?>
</div>
<div class="col">
<?= $form->field($model, "created_at_range", [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "创建时间",
],
"errorOptions" => [
"class" => "error-tips"
]
])->widget(DateRangePicker::className());
?>
</div>
<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>
<?php ActiveForm::end(); ?>

18
antgoods/views/shop-category/create.php

@ -0,0 +1,18 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\ShopCategory */
$this->title = '创建前端商品分类';
$this->params['breadcrumbs'][] = ['label' => '前端商品分类', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="shop-category-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

28
antgoods/views/shop-category/index.php

@ -0,0 +1,28 @@
<?php
use yii\helpers\Html;
use iron\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel common\models\searchs\ShopCategorySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = '前端商品分类';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="row">
<div class="col-12">
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filter' => $this->render("_search", ['model' => $searchModel]),
'batch' => [
[
"label" => "删除",
"url" => "shopcategory/deletes"
],
],
'columns' => $columns
]);
?>
</div>
</div>

19
antgoods/views/shop-category/update.php

@ -0,0 +1,19 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\ShopCategory */
$this->title = '编辑前端商品分类: ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => '前端商品分类', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = '编辑 ';
?>
<div class="shop-category-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

64
antgoods/views/shop-category/view.php

@ -0,0 +1,64 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
use antgoods\models\ars\ShopCategory;
use antgoods\models\ars\Attribute;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\ShopCategory */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => '前端商品分类', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
$filter_attr_arr = explode(',', $model->filter_attr);
$attr_str = '';
foreach ($filter_attr_arr as $filter_attr_id) {
$attr = Attribute::findOne($filter_attr_id);
if ($attr) {
$attr_str = $attr_str . ',' . $attr->name;
}
}
$attr_str = substr($attr_str, 1);
?>
<div class="shop-category-view">
<p>
<?= Html::a('返回列表', ['index'], ['class' => 'btn btn-success']) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'name',
'keywords',
'desc',
'sort_order',
['attribute' => 'icon',
'width'=>'10%',
'format' => 'raw',
'value' => function ($model) {
return $model->iconFile ?
\yii\bootstrap4\Html::img(['/'.$model->iconFile->path], ['style' => 'width:80px'])
: '未设置';
}
],
['attribute' => 'filter_attr',
'value' => $attr_str
],
['attribute' => 'is_show',
'width' => '5%',
'value' =>
function ($model) {
return $model->is_show == ShopCategory::IS_SHOW_HIDE ? '隐藏' : '显示';
},
],
'created_at:datetime',
'updated_at:datetime',
],
]) ?>
</div>

27
antgoods/views/site/error.php

@ -0,0 +1,27 @@
<?php
/* @var $this yii\web\View */
/* @var $name string */
/* @var $message string */
/* @var $exception Exception */
use yii\helpers\Html;
$this->title = $name;
?>
<div class="site-error">
<h1><?= Html::encode($this->title) ?></h1>
<div class="alert alert-danger">
<?= nl2br(Html::encode($message)) ?>
</div>
<p>
The above error occurred while the Web server was processing your request.
</p>
<p>
Please contact us if you think this is a server error. Thank you.
</p>
</div>

6
antgoods/views/site/index.php

@ -0,0 +1,6 @@
<?php
/* @var $this yii\web\View */
$this->title = 'Dashboard';
$this->params['subtitle'] = 'Control panel';
$this->params['breadcrumbs'][] = $this->title;
?>

34
antgoods/views/site/login.php

@ -0,0 +1,34 @@
<?php
/* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $model \common\models\LoginForm */
use yii\helpers\Html;
use yii\bootstrap4\ActiveForm;
$this->title = '系统登录';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="login-body">
<div class="login-form col-md-3 offset-md-4">
<h2><?= Html::encode($this->title) ?></h2>
<h6 class="login-tips font-small-3 line text-muted"><span>Login with Blobt Admin</span></h6>
<div class="row">
<div class="col-lg-12">
<?php $form = ActiveForm::begin(['id' => 'login-form']); ?>
<?= $form->field($model, 'username')->textInput(['autofocus' => true]) ?>
<?= $form->field($model, 'password')->passwordInput() ?>
<?= $form->field($model, 'rememberMe')->checkbox() ?>
<div class="form-group">
<?= Html::submitButton('Login', ['class' => 'btn btn-primary btn-lg btn-block', 'name' => 'login-button']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
</div>
</div>

68
antgoods/views/site/test.php

@ -0,0 +1,68 @@
<?PHP
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use blobt\widgets\DateRangePicker;
$this->title = '测试';
$this->params['subtitle'] = '这是一个小小的测试';
$this->params['breadcrumbs'][] = $this->title;
/* @var $this yii\web\View */
/* @var $model common\models\CategorySearch */
/* @var $form yii\widgets\ActiveForm */
?>
<?php
$form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
'validateOnType' => true,
]);
?>
<div class="col-sm-11">
<div class="dataTables_filter">
<?=
$form->field($model, 'id', [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "检索的id",
"class" => "form-control"
],
"errorOptions" => [
"class" => "error-tips"
]
])
?>
<?=
$form->field($model, 'cat_name', [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "检索类名",
"class" => "form-control",
],
"errorOptions" => [
"class" => "error-tips"
]
])
?>
<?=
$form->field($model, "created_at", [
"template" => "{input}{error}",
"errorOptions" => [
"class" => "error-tips"
]
])->widget(DateRangePicker::className());
?>
</div>
</div>
<div class="col-sm-1" style="padding: 0;">
<?= 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>
<?php ActiveForm::end(); ?>

30
antgoods/views/supplier/_form.php

@ -0,0 +1,30 @@
<?php
use yii\helpers\Html;
use yii\bootstrap4\ActiveForm;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\Supplier */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="supplier-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'full_name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'phone')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'address')->textInput(['maxlength' => true]) ?>
<div class="form-group">
<?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>
<?= Html::a('返回', ['index'], ['class' => 'btn btn-info']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

49
antgoods/views/supplier/_search.php

@ -0,0 +1,49 @@
<?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="row">
<div class="col">
<?= $form->field($model, 'id', [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "检索ID",
"class" => "form-control",
],
"errorOptions" => [
"class" => "error-tips"
]
])
?>
</div>
<div class="col">
<?= $form->field($model, "created_at_range", [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "创建时间",
],
"errorOptions" => [
"class" => "error-tips"
]
])->widget(DateRangePicker::className());
?>
</div>
<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>
<?php ActiveForm::end(); ?>

18
antgoods/views/supplier/create.php

@ -0,0 +1,18 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\Supplier */
$this->title = '创建供应商';
$this->params['breadcrumbs'][] = ['label' => '供应商管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="supplier-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

28
antgoods/views/supplier/index.php

@ -0,0 +1,28 @@
<?php
use yii\helpers\Html;
use iron\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel common\models\searchs\SupplierSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = '供应商管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="row">
<div class="col-12">
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filter' => $this->render("_search", ['model' => $searchModel]),
'batch' => [
[
"label" => "删除",
"url" => "supplier/deletes"
],
],
'columns' => $columns
]);
?>
</div>
</div>

19
antgoods/views/supplier/update.php

@ -0,0 +1,19 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\Supplier */
$this->title = '编辑供应商: ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => '供应商管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = '编辑 ';
?>
<div class="supplier-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

33
antgoods/views/supplier/view.php

@ -0,0 +1,33 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model antgoods\models\ars\Supplier */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => '供应商管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="supplier-view">
<p>
<?= Html::a('返回列表', ['index'], ['class' => 'btn btn-success']) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'name',
'full_name',
'phone',
'address',
'created_at:datetime',
'updated_at:datetime',
],
]) ?>
</div>

11
antgoods/web/.gitignore

@ -0,0 +1,11 @@
/index.php
/index-test.php
/robots.txt
uploads
css/umeditor/php/upload/
node_modules/
yarn-error.log
yarn.lock
package-lock.json
ueditor

2
antgoods/web/assets/.gitignore

@ -0,0 +1,2 @@
*
!.gitignore

48
antgoods/web/css/reset.css

@ -0,0 +1,48 @@
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}

52
antgoods/web/css/site.css

@ -0,0 +1,52 @@
/*公共样式*/
/*登录页*/
.login-body{
display: flex;
align-items: center;
height: 100vh;
}
.login-body .line {
border-bottom: 1px solid #dadada;
line-height: 0.1em;
margin: 10px 0 20px;
}
.login-body .line span {
background: #fff;
padding: 0 10px;
}
.login-form {
box-shadow: 0 8px 17px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
margin: 0 auto;
}
.login-form h2{
text-align: center;
margin-bottom: 20px;
}
.login-form h6 {
text-align: center;
}
/*修复select2插件 from表框颜色不生效*/
.form-group.has-error .select2-selection, .form-group.has-error .select2-selection {
border-color: #dd4b39;
box-shadow: none;
}
.form-group.has-success .select2-selection, .form-group.has-success .select2-selection {
border-color: #00a65a;
box-shadow: none;
}
.icheck-label-group {
padding-top: 2px;
}
.icheck-label-group label{
margin-right: 20px;
}

58
antgoods/web/custom/sku.49a56a9198d9c3ec233c.js
File diff suppressed because it is too large
View File

58
antgoods/web/custom/sku.52802ed907a316501cd7.js
File diff suppressed because it is too large
View File

58
antgoods/web/custom/sku.9a46222d01b3d601e5ad.js
File diff suppressed because it is too large
View File

64
antgoods/web/custom/sku_item.6649e882bedbeb22ea3d.js
File diff suppressed because it is too large
View File

BIN
antgoods/web/favicon.ico

BIN
antgoods/web/img/avatar.png

After

Width: 215  |  Height: 215  |  Size: 7.9 KiB

BIN
antgoods/web/img/avatar04.png

After

Width: 215  |  Height: 215  |  Size: 13 KiB

BIN
antgoods/web/img/avatar2.png

After

Width: 215  |  Height: 215  |  Size: 8.1 KiB

BIN
antgoods/web/img/avatar3.png

After

Width: 215  |  Height: 215  |  Size: 9.0 KiB

BIN
antgoods/web/img/avatar5.png

After

Width: 215  |  Height: 215  |  Size: 7.4 KiB

BIN
antgoods/web/img/credit/american-express.png

After

Width: 51  |  Height: 32  |  Size: 2.1 KiB

BIN
antgoods/web/img/credit/cirrus.png

After

Width: 51  |  Height: 32  |  Size: 1.5 KiB

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

Loading…
Cancel
Save