linyaostalker
5 years ago
248 changed files with 0 additions and 29726 deletions
-
9backend/config/main.php
-
24backend/modules/file/Module.php
-
217backend/modules/file/logic/file/FileManager.php
-
39backend/modules/file/migrations/m191112_022131_create_table_file.php
-
36backend/modules/file/migrations/m191112_022532_create_table_tem_file.php
-
95backend/modules/file/models/ars/File.php
-
81backend/modules/file/models/ars/TemFile.php
-
24backend/modules/goods/Module.php
-
58backend/modules/goods/assets/custom/sku.49a56a9198d9c3ec233c.js
-
58backend/modules/goods/assets/custom/sku.52802ed907a316501cd7.js
-
58backend/modules/goods/assets/custom/sku.9a46222d01b3d601e5ad.js
-
64backend/modules/goods/assets/custom/sku_item.6649e882bedbeb22ea3d.js
-
9210backend/modules/goods/assets/js/jquery.js
-
159backend/modules/goods/controllers/AttributeController.php
-
152backend/modules/goods/controllers/BrandController.php
-
211backend/modules/goods/controllers/CategoryController.php
-
310backend/modules/goods/controllers/GoodsController.php
-
213backend/modules/goods/controllers/ShopCategoryController.php
-
152backend/modules/goods/controllers/SupplierController.php
-
651backend/modules/goods/logic/goods/GoodsManager.php
-
42backend/modules/goods/migrations/m191119_021851_create_table_atg_shop_category.php
-
39backend/modules/goods/migrations/m191119_022641_create_table_atg_category.php
-
36backend/modules/goods/migrations/m191119_022939_create_table_atg_attribute.php
-
35backend/modules/goods/migrations/m191119_023115_create_table_atg_goods_attr.php
-
33backend/modules/goods/migrations/m191119_024029_create_table_atg_brand.php
-
27backend/modules/goods/migrations/m191119_024205_create_table_atg_goods.php
-
27backend/modules/goods/migrations/m191119_024345_create_table_atg_goods_sku.php
-
36backend/modules/goods/migrations/m191119_025607_create_table_atg_supplier.php
-
35backend/modules/goods/migrations/m191119_025843_create_table_atg_filter_attr.php
-
22backend/modules/goods/migrations/m191125_012449_update_column_icon_type_in_atg_category.php
-
20backend/modules/goods/migrations/m191125_083820_drop_column_icon_type_in_table_atg_category.php
-
26backend/modules/goods/migrations/m191125_084547_update_column_pid_and_icon_in_table_atg_category.php
-
20backend/modules/goods/migrations/m191125_104137_drop_column_icon_type_in_table_atg_shop_category.php
-
26backend/modules/goods/migrations/m191125_104510_update_column_pid_and_icon_in_table_atg_shop_category.php
-
20backend/modules/goods/migrations/m191127_114228_add_column_is_manaul_in_table_atg_goods_sku.php
-
20backend/modules/goods/migrations/m191129_010349_add_column_sku_mode_in_atg_goods.php
-
26backend/modules/goods/migrations/m191129_020131_add_columns_goods_id_and_attr_id_in_table_atg_goods_attr.php
-
20backend/modules/goods/migrations/m191130_004933_add_column_cat_id_in_table_atg_attribute.php
-
27backend/modules/goods/migrations/m191202_082041_drop_columns_in_table_atg_goods_sku.php
-
26backend/modules/goods/migrations/m191207_004848_add_columns_is_taking_is_express_express_type_uniform_postage_in_table_atg_goods.php
-
23backend/modules/goods/migrations/m191209_091129_update_columns_in_table_atg_goods.php
-
20backend/modules/goods/migrations/m191209_091524_add_column_weight_in_table_atg_goods_sku.php
-
22backend/modules/goods/migrations/m191211_060934_update_column_limit_count_in_table_atg_goods.php
-
22backend/modules/goods/migrations/m191211_092335_update_column_sort_order_in_table_atg_goods.php
-
41backend/modules/goods/migrations/m191217_091658_update_column_is_manual_in_table_atg_goods_sku.php
-
26backend/modules/goods/migrations/m191217_092101_add_column_sku_image_in_table_atg_goods_sku.php
-
37backend/modules/goods/migrations/sql/goods.sql
-
24backend/modules/goods/migrations/sql/goods_sku.sql
-
17backend/modules/goods/migrations/sql/update_goods.sql
-
114backend/modules/goods/models/ars/Attribute.php
-
82backend/modules/goods/models/ars/Brand.php
-
132backend/modules/goods/models/ars/Category.php
-
81backend/modules/goods/models/ars/FilterAttr.php
-
288backend/modules/goods/models/ars/Goods.php
-
81backend/modules/goods/models/ars/GoodsAttr.php
-
107backend/modules/goods/models/ars/GoodsSku.php
-
144backend/modules/goods/models/ars/ShopCategory.php
-
96backend/modules/goods/models/ars/Supplier.php
-
162backend/modules/goods/models/searchs/AttributeSearch.php
-
152backend/modules/goods/models/searchs/BrandSearch.php
-
184backend/modules/goods/models/searchs/CategorySearch.php
-
231backend/modules/goods/models/searchs/GoodsSearch.php
-
162backend/modules/goods/models/searchs/ShopCategorySearch.php
-
161backend/modules/goods/models/searchs/SupplierSearch.php
-
32backend/modules/goods/views/attribute/_form.php
-
62backend/modules/goods/views/attribute/_search.php
-
18backend/modules/goods/views/attribute/create.php
-
28backend/modules/goods/views/attribute/index.php
-
19backend/modules/goods/views/attribute/update.php
-
33backend/modules/goods/views/attribute/view.php
-
24backend/modules/goods/views/brand/_form.php
-
62backend/modules/goods/views/brand/_search.php
-
18backend/modules/goods/views/brand/create.php
-
28backend/modules/goods/views/brand/index.php
-
19backend/modules/goods/views/brand/update.php
-
30backend/modules/goods/views/brand/view.php
-
47backend/modules/goods/views/category/_form.php
-
62backend/modules/goods/views/category/_search.php
-
18backend/modules/goods/views/category/create.php
-
28backend/modules/goods/views/category/index.php
-
19backend/modules/goods/views/category/update.php
-
41backend/modules/goods/views/category/view.php
-
27backend/modules/goods/views/config/index.php
-
107backend/modules/goods/views/goods/_form.php
-
104backend/modules/goods/views/goods/_search.php
-
22backend/modules/goods/views/goods/attribute.php
-
112backend/modules/goods/views/goods/create.php
-
90backend/modules/goods/views/goods/express.php
-
22backend/modules/goods/views/goods/filter_attribute.php
-
139backend/modules/goods/views/goods/goods.php
-
28backend/modules/goods/views/goods/index.php
-
25backend/modules/goods/views/goods/new_editor.php
-
35backend/modules/goods/views/goods/picture.php
-
15backend/modules/goods/views/goods/sku_edit.php
-
123backend/modules/goods/views/goods/update.php
-
113backend/modules/goods/views/goods/view.php
-
55backend/modules/goods/views/shop-category/_form.php
-
62backend/modules/goods/views/shop-category/_search.php
-
18backend/modules/goods/views/shop-category/create.php
-
28backend/modules/goods/views/shop-category/index.php
@ -1,24 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\file; |
|||
|
|||
/** |
|||
* file module definition class |
|||
*/ |
|||
class Module extends \yii\base\Module |
|||
{ |
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public $controllerNamespace = 'backend\modules\file\controllers'; |
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function init() |
|||
{ |
|||
parent::init(); |
|||
|
|||
// custom initialization code goes here
|
|||
} |
|||
} |
@ -1,217 +0,0 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace backend\modules\file\logic\file; |
|||
|
|||
use backend\modules\file\models\ars\File; |
|||
use backend\modules\file\models\ars\TemFile; |
|||
use Exception; |
|||
use yii\web\HttpException; |
|||
use yii; |
|||
use yii\web\ServerErrorHttpException; |
|||
use backend\modules\goods\logic\goods\GoodsManager; |
|||
|
|||
class FileManager |
|||
{ |
|||
//数据表ats_file和ats_tem_file的类型字段type
|
|||
const TYPE_NONE = 0;//不存在
|
|||
const TYPE_IMAGE = 1;//图片
|
|||
const TYPE_VIDEO = 2;//影视
|
|||
const TYPE_EXCEL = 3;//excel表单
|
|||
const TYPE_WORD = 4;//word文本
|
|||
const TYPE_TXT = 5;//txt文本
|
|||
|
|||
public static $extension = [ |
|||
self::TYPE_IMAGE => ['jpg', 'png', 'jpeg'], |
|||
self::TYPE_VIDEO => ['mp4'], |
|||
self::TYPE_EXCEL => [], |
|||
self::TYPE_WORD => ['docx'], |
|||
self::TYPE_TXT => ['txt'], |
|||
]; |
|||
|
|||
/** |
|||
* @param $keyword |
|||
* @return int|string |
|||
* 根据文件拓展名在$extension中查找对应的文件类型,若不存在则返回self::TYPE_NONE |
|||
*/ |
|||
public static function searchType($keyword) |
|||
{ |
|||
foreach(self::$extension as $key => $type){ |
|||
if (in_array($keyword, $type)) { |
|||
return $key; |
|||
} |
|||
} |
|||
return self::TYPE_NONE; |
|||
} |
|||
|
|||
/** |
|||
* @param $temFileIdArr |
|||
* @param $ownId |
|||
* @param $ownType |
|||
* @return array|bool |
|||
* @throws HttpException |
|||
* @throws ServerErrorHttpException |
|||
* 根据临时文件id将临时文件保存在文件中 |
|||
*/ |
|||
public function saveTemFileToFile($temFileIdArr, $ownId, $ownType) |
|||
{ |
|||
if(empty($temFileIdArr) || !$ownId) { |
|||
return false; |
|||
} |
|||
|
|||
$tra = Yii::$app->db->beginTransaction(); |
|||
try { |
|||
$firstFileId = 0; |
|||
foreach ($temFileIdArr as $key => $value) { |
|||
$temFile = TemFile::findOne($value); |
|||
|
|||
if ($temFile) { |
|||
$res = self::saveNewFile($temFile, $ownId, $ownType); |
|||
if ($key == 0) { |
|||
$firstFileId = $res['file_id']; |
|||
} |
|||
} |
|||
} |
|||
|
|||
$tra->commit(); |
|||
return ['status' => true, 'info' => '保存成功', 'first_file_id' => $firstFileId]; |
|||
} catch (yii\db\Exception $e) { |
|||
$tra->rollBack(); |
|||
throw new ServerErrorHttpException($e->getMessage()); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @param TemFile|$temFile |
|||
* @param $ownId |
|||
* @param $ownType |
|||
* @return array |
|||
* @throws HttpException |
|||
* 创建新的文件 |
|||
*/ |
|||
private function saveNewFile($temFile, $ownId, $ownType) |
|||
{ |
|||
$newFile = new File(); |
|||
$newFile->name = $temFile->name; |
|||
$newFile->type = $temFile->type; |
|||
$newFile->own_id = $ownId; |
|||
$newFile->own_type = $ownType; |
|||
$newFile->alias = $temFile->alias; |
|||
$newFile->path = $temFile->path; |
|||
if($newFile->save()) { |
|||
return ['status' => true, 'info' => '操作成功', 'file_id' => $newFile->id]; |
|||
} else { |
|||
throw new HttpException('500', 'File保存失败'); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @param $fileIdArr |
|||
* @return bool |
|||
* @throws HttpException |
|||
* 删除file表中的文件 |
|||
*/ |
|||
public function deleteFile($fileIdArr) |
|||
{ |
|||
if($fileIdArr){ |
|||
foreach ($fileIdArr as $key => $value) { |
|||
$fileModel = File::findOne($value); |
|||
if($fileModel){ |
|||
$fileModel->is_delete = File::IS_DELETE_YES; |
|||
if(!$fileModel->save()){ |
|||
throw new HttpException('500', '文件删除失败'); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
/** |
|||
* @param yii\base\Model|$dataModel //数据模型
|
|||
* @param $fileIdStrName //表单中临时保存的文件id字符串组合(以,隔开)
|
|||
* @param string $fileNameInModel //需要保存到数据库中的数据表字段名称
|
|||
* @param $fileOldIdStr //数据库中已经保存的文件id字符串组合(以,隔开)
|
|||
* @param $fileType //File模型中定义的own_type常量
|
|||
* @return bool |
|||
* @throws Exception |
|||
* 数据模型保存文件操作 |
|||
*/ |
|||
public static function saveFileInModel($dataModel, $fileIdStrName, $fileOldIdStr, $fileType, $fileNameInModel = '') |
|||
{ |
|||
if (is_array($dataModel)) { |
|||
throw new ServerErrorHttpException('数据模型不得为数组'); |
|||
} |
|||
$dataModel->save(); |
|||
$saveFileRes = GoodsManager::saveFile(explode(',', $dataModel->$fileIdStrName), $dataModel, explode(',', $fileOldIdStr), $fileType); |
|||
if ($fileNameInModel && $saveFileRes['status'] && $saveFileRes['first_file_id'] !== 0) { |
|||
$dataModel->$fileNameInModel = $saveFileRes['first_file_id']; |
|||
if (!$dataModel->save()) { |
|||
throw new ServerErrorHttpException('dataModel保存失败'); |
|||
} |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
/** |
|||
* @param $fileName |
|||
* @param $formData |
|||
* @return int |
|||
* 保存临时文件操作 |
|||
*/ |
|||
public static function saveTemFile($fileName, $formData) |
|||
{ |
|||
$temFileModel = new TemFile(); |
|||
$temFileModel->user_id = Yii::$app->user->identity->id; |
|||
$temFileModel->name = $fileName; |
|||
$temFileModel->type = FileManager::searchType(pathinfo($formData['path'])['extension']); |
|||
$temFileModel->alias = $formData['alias']; |
|||
$temFileModel->path = $formData['path']; |
|||
$temFileModel->save(); |
|||
return $temFileModel->id; |
|||
} |
|||
|
|||
/** |
|||
* @param $data //ajax接收的数据
|
|||
* @return string |
|||
* 上传插件点击删除按钮时处理文件id字符串(以,分隔) |
|||
*/ |
|||
public static function dealFileIdStrInDel($data) |
|||
{ |
|||
$imgIdArr = explode(',', $data['imgid']); |
|||
if(isset($data['data']['alias'])) { |
|||
$temFile = TemFile::findOne(['alias' => $data['data']['alias']]); |
|||
if ($temFile) { |
|||
$imgIdArr = array_diff($imgIdArr, [$temFile->id]); |
|||
} |
|||
}else{ |
|||
foreach ($data as $key => $value) { |
|||
$temFile = File::findOne(['alias' => $value]); |
|||
if ($temFile) { |
|||
$imgIdArr = array_diff($imgIdArr, [$temFile->id]); |
|||
} |
|||
} |
|||
} |
|||
return implode(',', $imgIdArr); |
|||
} |
|||
|
|||
/** |
|||
* @param $fileIdStr |
|||
* @return false|string |
|||
* 加载已有的文件数据 |
|||
*/ |
|||
public static function loadExitFile($fileIdStr) |
|||
{ |
|||
$fileIdArr = explode(',', $fileIdStr); |
|||
$files = File::find()->where(['id' => $fileIdArr])->all(); |
|||
$fileInfo = array(); |
|||
if($files) { |
|||
foreach ($files as $key => $file) { |
|||
$fileInfo[$key]['name'] = $file->alias; |
|||
$fileInfo[$key]['path'] = Yii::$app->request->hostInfo . '/' . $file->path; |
|||
$fileInfo[$key]['size'] = filesize($file->path); |
|||
} |
|||
} |
|||
return json_encode($fileInfo); |
|||
} |
|||
} |
@ -1,39 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191112_022131_create_table_file |
|||
*/ |
|||
class m191112_022131_create_table_file extends Migration |
|||
{ |
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function up() |
|||
{ |
|||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="文件表"'; |
|||
$this->createTable('ats_file', [ |
|||
'id' => $this->primaryKey(), |
|||
'pid'=>$this->integer(11)->defaultValue(null)->comment('父级id'), |
|||
'name'=>$this->string(255)->defaultValue(null)->comment('名称'), |
|||
'type'=>$this->tinyInteger(1)->defaultValue(0)->comment('类型'), |
|||
'own_type'=>$this->tinyInteger(1)->defaultValue(0)->comment('拥有者类型'), |
|||
'own_id'=>$this->integer(11)->defaultValue(null)->comment('拥有者id'), |
|||
'alias'=>$this->string(50)->defaultValue(null)->comment('别名'), |
|||
'path'=>$this->string(255)->defaultValue(null)->comment('地址'), |
|||
'is_delete'=>$this->tinyInteger(1)->defaultValue(0)->comment('是否删除,1为已删除'), |
|||
'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'), |
|||
'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'), |
|||
],$tableOptions); |
|||
} |
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function down() |
|||
{ |
|||
$this->dropTable('ats_file'); |
|||
return true; |
|||
} |
|||
} |
@ -1,36 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191112_022532_create_table_tem_file |
|||
*/ |
|||
class m191112_022532_create_table_tem_file extends Migration |
|||
{ |
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function up() |
|||
{ |
|||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="临时文件表"'; |
|||
$this->createTable('ats_tem_file', [ |
|||
'id' => $this->primaryKey(), |
|||
'user_id'=>$this->integer(11)->defaultValue(null)->comment('父级id'), |
|||
'name'=>$this->string(255)->defaultValue(null)->comment('名称'), |
|||
'type'=>$this->tinyInteger(1)->defaultValue(0)->comment('类型'), |
|||
'alias'=>$this->string(50)->defaultValue(null)->comment('别名'), |
|||
'path'=>$this->string(255)->defaultValue(null)->comment('地址'), |
|||
'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'), |
|||
'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'), |
|||
],$tableOptions); |
|||
} |
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function down() |
|||
{ |
|||
$this->dropTable('ats_tem_file'); |
|||
return true; |
|||
} |
|||
} |
@ -1,95 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\file\models\ars; |
|||
|
|||
use yii\behaviors\TimestampBehavior; |
|||
use yii\db\ActiveRecord; |
|||
|
|||
/** |
|||
* This is the model class for table "ats_file". |
|||
* |
|||
* @property int $id |
|||
* @property int $pid 父级id |
|||
* @property string $name 名称 |
|||
* @property int $type 类型 |
|||
* @property int $own_type 拥有者类型 |
|||
* @property int $own_id 拥有者id |
|||
* @property string $alias 别名 |
|||
* @property string $path 地址 |
|||
* @property int $is_delete 是否删除,1为已删除 |
|||
* @property int $updated_at 更新时间 |
|||
* @property int $created_at 创建时间 |
|||
*/ |
|||
class File extends ActiveRecord |
|||
{ |
|||
//own_type
|
|||
const OWN_TYPE_GOODS_INDEX = 1;//商品首页
|
|||
const OWN_TYPE_GOODS_DETAILS = 2;//商品详情
|
|||
const OWN_TYPE_CATEGORY_ICON = 3;//类目图标
|
|||
const OWN_TYPE_COMMENT = 4;//评论图片
|
|||
//is_delete
|
|||
const IS_DELETE_YES = 1;//已删除
|
|||
const IS_DELETE_NO = 0;//未删除
|
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public static function tableName() |
|||
{ |
|||
return 'ats_file'; |
|||
} |
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
[['pid', 'type', 'own_type', 'own_id', 'is_delete'], 'integer'], |
|||
[['name', 'path'], 'string', 'max' => 255], |
|||
[['alias'], 'string', 'max' => 50], |
|||
]; |
|||
} |
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function attributeLabels() |
|||
{ |
|||
return [ |
|||
'id' => 'id', |
|||
'pid' => '父级id', |
|||
'name' => '名称', |
|||
'type' => '类型', |
|||
'own_type' => '拥有者类型', |
|||
'own_id' => '拥有者id', |
|||
'alias' => '别名', |
|||
'path' => '地址', |
|||
'is_delete' => '是否删除,1为已删除', |
|||
'updated_at' => '更新时间', |
|||
'created_at' => '创建时间', |
|||
]; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* @author linyao |
|||
* @email 602604991@qq.com |
|||
* @created Nov 8, 2019 |
|||
* |
|||
* 行为存储创建时间和更新时间 |
|||
*/ |
|||
public function behaviors() |
|||
{ |
|||
return [ |
|||
[ |
|||
'class' => TimestampBehavior::class, |
|||
'createdAtAttribute' => 'created_at', |
|||
'updatedAtAttribute' => 'updated_at', |
|||
'value' => function () { |
|||
return time(); |
|||
}, |
|||
], |
|||
]; |
|||
} |
|||
} |
@ -1,81 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\file\models\ars; |
|||
|
|||
use yii\behaviors\TimestampBehavior; |
|||
use yii\db\ActiveRecord; |
|||
|
|||
/** |
|||
* This is the model class for table "ats_tem_file". |
|||
* |
|||
* @property int $id |
|||
* @property int $user_id 父级id |
|||
* @property string $name 名称 |
|||
* @property int $type 类型 |
|||
* @property string $alias 别名 |
|||
* @property string $path 地址 |
|||
* @property int $updated_at 更新时间 |
|||
* @property int $created_at 创建时间 |
|||
*/ |
|||
class TemFile extends ActiveRecord |
|||
{ |
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public static function tableName() |
|||
{ |
|||
return 'ats_tem_file'; |
|||
} |
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
[['user_id', 'type'], 'integer'], |
|||
[['name', 'path'], 'string', 'max' => 255], |
|||
[['alias'], 'string', 'max' => 50], |
|||
]; |
|||
} |
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function attributeLabels() |
|||
{ |
|||
return [ |
|||
'id' => 'id', |
|||
'user_id' => '父级id', |
|||
'name' => '名称', |
|||
'type' => '类型', |
|||
'alias' => '别名', |
|||
'path' => '地址', |
|||
'updated_at' => '更新时间', |
|||
'created_at' => '创建时间', |
|||
]; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* @author linyao |
|||
* @email 602604991@qq.com |
|||
* @created Nov 8, 2019 |
|||
* |
|||
* 行为存储创建时间和更新时间 |
|||
*/ |
|||
public function behaviors() |
|||
{ |
|||
return [ |
|||
[ |
|||
'class' => TimestampBehavior::class, |
|||
'createdAtAttribute' => 'created_at', |
|||
'updatedAtAttribute' => 'updated_at', |
|||
'value' => function() { |
|||
return time(); |
|||
}, |
|||
], |
|||
]; |
|||
} |
|||
} |
@ -1,24 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\goods; |
|||
|
|||
/** |
|||
* goods module definition class |
|||
*/ |
|||
class Module extends \yii\base\Module |
|||
{ |
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public $controllerNamespace = 'backend\modules\goods\controllers'; |
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function init() |
|||
{ |
|||
parent::init(); |
|||
|
|||
// custom initialization code goes here
|
|||
} |
|||
} |
58
backend/modules/goods/assets/custom/sku.49a56a9198d9c3ec233c.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
58
backend/modules/goods/assets/custom/sku.52802ed907a316501cd7.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
58
backend/modules/goods/assets/custom/sku.9a46222d01b3d601e5ad.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
64
backend/modules/goods/assets/custom/sku_item.6649e882bedbeb22ea3d.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
9210
backend/modules/goods/assets/js/jquery.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,159 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\goods\controllers; |
|||
|
|||
use backend\modules\goods\logic\goods\GoodsManager; |
|||
use Yii; |
|||
use backend\modules\goods\models\ars\Attribute; |
|||
use backend\modules\goods\models\searchs\AttributeSearch; |
|||
use yii\web\Controller; |
|||
use yii\web\NotFoundHttpException; |
|||
use yii\filters\VerbFilter; |
|||
use iron\widget\Excel; |
|||
|
|||
/** |
|||
* 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()) { |
|||
if (GoodsManager::updateAttribute($model)) { |
|||
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()) { |
|||
if (GoodsManager::updateAttribute($model)) { |
|||
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); |
|||
} |
|||
Excel::export([ |
|||
'models' => $dataProvider->getModels(), |
|||
'format' => 'Xlsx', |
|||
'asAttachment' => true, |
|||
'fileName' =>'Attributes'. "-" .date('Y-m-d H/i/s', time()), |
|||
'columns' => $searchModel->columns() |
|||
]); |
|||
} |
|||
} |
@ -1,152 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\goods\controllers; |
|||
|
|||
use Yii; |
|||
use backend\modules\goods\models\ars\Brand; |
|||
use backend\modules\goods\models\searchs\BrandSearch; |
|||
use yii\web\Controller; |
|||
use yii\web\NotFoundHttpException; |
|||
use yii\filters\VerbFilter; |
|||
use iron\widget\Excel; |
|||
|
|||
/** |
|||
* 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); |
|||
} |
|||
Excel::export([ |
|||
'models' => $dataProvider->getModels(), |
|||
'format' => 'Xlsx', |
|||
'asAttachment' => true, |
|||
'fileName' =>'Brands'. "-" .date('Y-m-d H/i/s', time()), |
|||
'columns' => $searchModel->columns() |
|||
]); |
|||
} |
|||
} |
@ -1,211 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\goods\controllers; |
|||
|
|||
use backend\modules\file\models\ars\File; |
|||
use Exception; |
|||
use Yii; |
|||
use backend\modules\goods\models\ars\Category; |
|||
use backend\modules\goods\models\searchs\CategorySearch; |
|||
use yii\web\Controller; |
|||
use yii\web\NotFoundHttpException; |
|||
use yii\filters\VerbFilter; |
|||
use backend\modules\file\logic\file\FileManager; |
|||
use yii\web\Response; |
|||
use iron\widget\Excel; |
|||
|
|||
/** |
|||
* 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), |
|||
]); |
|||
} |
|||
|
|||
/** |
|||
* @return string|Response |
|||
* @throws Exception |
|||
*/ |
|||
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()) { |
|||
//类目图片上传保存处理
|
|||
$res = FileManager::saveFileInModel($model, 'iconImageId', '', File::OWN_TYPE_CATEGORY_ICON, 'icon'); |
|||
if ($res) { |
|||
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 |
|||
* @throws Exception |
|||
*/ |
|||
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()) { |
|||
//类目图片上传保存处理
|
|||
$res = FileManager::saveFileInModel($model, 'iconImageId', $icon_image_old_id_arr, File::OWN_TYPE_CATEGORY_ICON, 'icon'); |
|||
if ($res) { |
|||
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); |
|||
} |
|||
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() |
|||
{ |
|||
$data = Yii::$app->request->get('data'); |
|||
$fileName = Yii::$app->request->get('fileName')[0]; |
|||
|
|||
if ($data['status'] == true) { |
|||
return FileManager::saveTemFile($fileName, $data); |
|||
} |
|||
return false; |
|||
} |
|||
|
|||
/** |
|||
* @return string |
|||
* 点击删除按钮时同时删除字符串中的id |
|||
*/ |
|||
public function actionImgIdDel() |
|||
{ |
|||
$data = Yii::$app->request->get(); |
|||
return FileManager::dealFileIdStrInDel($data); |
|||
} |
|||
|
|||
/** |
|||
* @return bool|false|string |
|||
* 加载已有的文件 |
|||
*/ |
|||
public function actionImageFile() |
|||
{ |
|||
$fileIdStr = Yii::$app->request->get('fileIdStr'); |
|||
return FileManager::loadExitFile($fileIdStr); |
|||
} |
|||
} |
@ -1,310 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\goods\controllers; |
|||
|
|||
use backend\modules\file\logic\file\FileManager; |
|||
use backend\modules\goods\models\ars\FilterAttr; |
|||
use backend\modules\goods\models\ars\GoodsAttr; |
|||
use backend\modules\shop\logic\ShopManager; |
|||
use Exception; |
|||
use Throwable; |
|||
use Yii; |
|||
use backend\modules\goods\models\ars\Goods; |
|||
use backend\modules\goods\models\searchs\GoodsSearch; |
|||
use yii\web\Controller; |
|||
use yii\web\NotFoundHttpException; |
|||
use yii\filters\VerbFilter; |
|||
use backend\modules\goods\logic\goods\GoodsManager; |
|||
use backend\modules\file\models\ars\File; |
|||
use backend\modules\goods\models\ars\Attribute; |
|||
use iron\widget\Excel; |
|||
|
|||
/** |
|||
* 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 |
|||
* @throws Exception |
|||
*/ |
|||
public function actionCreate() |
|||
{ |
|||
$model = new Goods(); |
|||
$model->is_sale = Goods::IS_SALE_YES; |
|||
$model->stock = -1; |
|||
$model->is_taking = Goods::IS_TAKING_NO; |
|||
$model->is_express = Goods::IS_EXPRESS_YES; |
|||
$model->express_type = Goods::EXPRESS_TYPE_EXPRESS_TEMPLATE; |
|||
if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
|||
//商品封面图和商品详情图上传保存处理
|
|||
$res = GoodsManager::updateGoods(Yii::$app->request->post(), $model); |
|||
if ($res) { |
|||
return $this->redirect('index'); |
|||
} |
|||
} |
|||
return $this->render('create', [ |
|||
'model' => $model, |
|||
]); |
|||
} |
|||
|
|||
/** |
|||
* Updates an existing Goods model. |
|||
* If update is successful, the browser will be redirected to the 'view' page. |
|||
* @param integer $id |
|||
* @return mixed |
|||
* @throws NotFoundHttpException if the model cannot be found |
|||
* @throws Exception |
|||
*/ |
|||
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) { |
|||
return $this->redirect('index'); |
|||
} |
|||
} |
|||
$model->uniform_postage /= ShopManager::proportionalConversion(ShopManager::UNIT_TYPE_MONEY); |
|||
$model->market_price /= ShopManager::proportionalConversion(ShopManager::UNIT_TYPE_MONEY); |
|||
$model->price /= ShopManager::proportionalConversion(ShopManager::UNIT_TYPE_MONEY); |
|||
$goodsAttributes = GoodsAttr::find()->where(['goods_id' => $id, 'is_delete' => GoodsAttr::IS_DELETE_NO])->andWhere(['!=', 'attr_id', 0])->all(); |
|||
$attributeModel = GoodsManager::getAttribute($goodsAttributes); |
|||
$checkAttr = GoodsManager::getSkuInfo($id); |
|||
$goodsFilterAttributes = FilterAttr::find()->where(['goods_id' => $id, 'is_delete' => FilterAttr::IS_DELETE_NO])->andWhere(['!=', 'attr_id', 0])->all(); |
|||
$filterAttributeModel = GoodsManager::getAttribute($goodsFilterAttributes); |
|||
$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); |
|||
} |
|||
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() |
|||
{ |
|||
$data = Yii::$app->request->get('data'); |
|||
$fileName = Yii::$app->request->get('fileName')[0]; |
|||
|
|||
if ($data['status'] == true) { |
|||
return FileManager::saveTemFile($fileName, $data); |
|||
} |
|||
return false; |
|||
} |
|||
|
|||
/** |
|||
* @return string |
|||
* 点击删除按钮时同时删除字符串中的id |
|||
*/ |
|||
public function actionImgIdDel() |
|||
{ |
|||
$data = Yii::$app->request->get(); |
|||
return FileManager::dealFileIdStrInDel($data); |
|||
} |
|||
|
|||
/** |
|||
* @return bool|false|string |
|||
* 加载已有的文件 |
|||
*/ |
|||
public function actionImageFile() |
|||
{ |
|||
$fileIdStr = Yii::$app->request->get('fileIdStr'); |
|||
return FileManager::loadExitFile($fileIdStr); |
|||
} |
|||
|
|||
/** |
|||
* @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); |
|||
return $data; |
|||
} |
|||
|
|||
/** |
|||
* @return false|string |
|||
* 根据商品分类获取商品属性 |
|||
*/ |
|||
public function actionFilterAttribute() |
|||
{ |
|||
$catId = Yii::$app->request->get('catId')??0; |
|||
$allAttr = Attribute::find()->where(['type' => Attribute::TYPE_ATTR, 'is_delete' => Attribute::IS_DELETE_NO])->andWhere(['cat_id' => [0,$catId]])->asArray()->all(); |
|||
return json_encode($allAttr); |
|||
} |
|||
} |
@ -1,213 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\goods\controllers; |
|||
|
|||
use backend\modules\file\logic\file\FileManager; |
|||
use backend\modules\file\models\ars\File; |
|||
use Exception; |
|||
use Yii; |
|||
use backend\modules\goods\models\ars\ShopCategory; |
|||
use backend\modules\goods\models\searchs\ShopCategorySearch; |
|||
use yii\web\Controller; |
|||
use yii\web\NotFoundHttpException; |
|||
use yii\filters\VerbFilter; |
|||
use iron\widget\Excel; |
|||
|
|||
/** |
|||
* 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 |
|||
* @throws Exception |
|||
*/ |
|||
public function actionCreate() |
|||
{ |
|||
$model = new ShopCategory(); |
|||
$model->is_show = ShopCategory::IS_SHOW_HIDE; |
|||
$model->sort_order = 0; |
|||
if ($model->load(Yii::$app->request->post())) { |
|||
//类目图片上传保存处理
|
|||
$res = FileManager::saveFileInModel($model, 'iconImageId', '', File::OWN_TYPE_CATEGORY_ICON, 'icon'); |
|||
if ($res) { |
|||
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 |
|||
* @throws Exception |
|||
*/ |
|||
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())) { |
|||
//类目图片上传保存处理
|
|||
$res = FileManager::saveFileInModel($model, 'iconImageId', $icon_image_old_id_arr, File::OWN_TYPE_CATEGORY_ICON, 'icon'); |
|||
if ($res) { |
|||
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); |
|||
} |
|||
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() |
|||
{ |
|||
$data = Yii::$app->request->get('data'); |
|||
$fileName = Yii::$app->request->get('fileName')[0]; |
|||
|
|||
if ($data['status'] == true) { |
|||
return FileManager::saveTemFile($fileName, $data); |
|||
} |
|||
return false; |
|||
} |
|||
|
|||
/** |
|||
* @return string |
|||
* 点击删除按钮时同时删除字符串中的id |
|||
*/ |
|||
public function actionImgIdDel() |
|||
{ |
|||
$data = Yii::$app->request->get(); |
|||
return FileManager::dealFileIdStrInDel($data); |
|||
} |
|||
|
|||
/** |
|||
* @return bool|false|string |
|||
* 加载已有的文件 |
|||
*/ |
|||
public function actionImageFile() |
|||
{ |
|||
$fileIdStr = Yii::$app->request->get('fileIdStr'); |
|||
return FileManager::loadExitFile($fileIdStr); |
|||
} |
|||
} |
@ -1,152 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\goods\controllers; |
|||
|
|||
use Yii; |
|||
use backend\modules\goods\models\ars\Supplier; |
|||
use backend\modules\goods\models\searchs\SupplierSearch; |
|||
use yii\web\Controller; |
|||
use yii\web\NotFoundHttpException; |
|||
use yii\filters\VerbFilter; |
|||
use iron\widget\Excel; |
|||
|
|||
/** |
|||
* 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); |
|||
} |
|||
Excel::export([ |
|||
'models' => $dataProvider->getModels(), |
|||
'format' => 'Xlsx', |
|||
'asAttachment' => true, |
|||
'fileName' =>'Suppliers'. "-" .date('Y-m-d H/i/s', time()), |
|||
'columns' => $searchModel->columns() |
|||
]); |
|||
} |
|||
} |
@ -1,651 +0,0 @@ |
|||
<?php |
|||
namespace backend\modules\goods\logic\goods; |
|||
|
|||
use backend\modules\file\models\ars\File; |
|||
use backend\modules\goods\models\ars\Category; |
|||
use backend\modules\goods\models\ars\ShopCategory; |
|||
use Throwable; |
|||
use Yii; |
|||
use yii\db\Exception; |
|||
use backend\modules\goods\models\ars\GoodsAttr; |
|||
use backend\modules\goods\models\ars\Attribute; |
|||
use backend\modules\goods\models\ars\GoodsSku; |
|||
use backend\modules\goods\models\ars\Goods; |
|||
use backend\modules\goods\models\ars\FilterAttr; |
|||
use yii\db\StaleObjectException; |
|||
use backend\modules\file\logic\file\FileManager; |
|||
use yii\web\ServerErrorHttpException; |
|||
use backend\modules\shop\logic\ShopManager; |
|||
|
|||
class GoodsManager |
|||
{ |
|||
/** |
|||
* @param $newFileIdArr |
|||
* @param $hostObject |
|||
* @param array $oldFileIdArr |
|||
* @param int $fileType |
|||
* @return array |
|||
* @throws \Exception |
|||
* 保存新文件,删除不需要的文件操作 |
|||
*/ |
|||
public static function saveFile($newFileIdArr, $hostObject, $oldFileIdArr = [], $fileType = File::OWN_TYPE_GOODS_INDEX) |
|||
{ |
|||
$tra = Yii::$app->db->beginTransaction(); |
|||
try { |
|||
//需要新建的文件id
|
|||
$createFileIdArr = array_diff($newFileIdArr, $oldFileIdArr); |
|||
|
|||
//创建文件
|
|||
$class = new FileManager(); |
|||
$createFileRes = $class->saveTemFileToFile($createFileIdArr, $hostObject->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']; |
|||
} |
|||
} |
|||
|
|||
$tra->commit(); |
|||
return ['status' => true, 'info' => '操作成功', 'first_file_id' => $firstFileId]; |
|||
} catch (Exception $e) { |
|||
$tra->rollBack(); |
|||
throw new ServerErrorHttpException($e->getMessage()); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @param $formData |
|||
* @param Goods|$goodsModel |
|||
* @param null $coverImageOldIdStr |
|||
* @param null $detailImageOldIdStr |
|||
* @return bool |
|||
* @throws \Exception 创建修改商品操作 |
|||
*/ |
|||
public static function updateGoods($formData, $goodsModel, $coverImageOldIdStr = null, $detailImageOldIdStr = null) |
|||
{ |
|||
$attribute = $formData['attribute']; |
|||
$filterAttribute = $formData['filterattribute']; |
|||
$goodsModel->uniform_postage *= ShopManager::proportionalConversion(ShopManager::UNIT_TYPE_MONEY); |
|||
$goodsModel->market_price *= ShopManager::proportionalConversion(ShopManager::UNIT_TYPE_MONEY); |
|||
$goodsModel->price *= ShopManager::proportionalConversion(ShopManager::UNIT_TYPE_MONEY); |
|||
$tra = Yii::$app->db->beginTransaction(); |
|||
try { |
|||
FileManager::saveFileInModel($goodsModel, 'coverImageId', $coverImageOldIdStr, File::OWN_TYPE_GOODS_INDEX, 'image'); |
|||
FileManager::saveFileInModel($goodsModel, 'detailImageId', $detailImageOldIdStr, File::OWN_TYPE_GOODS_DETAILS); |
|||
self::addAttributeOperating(['id' => $goodsModel->id, 'attribute' => $attribute]); |
|||
self::addFilterAttributeOperating(['id' => $goodsModel->id, 'filterAttribute' => $filterAttribute]); |
|||
$tra->commit(); |
|||
return true; |
|||
} catch (\yii\base\Exception $e) { |
|||
$tra->rollBack(); |
|||
throw new \Exception($e->getMessage()); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @param $data |
|||
* @return bool |
|||
* @throws \Exception |
|||
* 创建修改商品属性操作 |
|||
*/ |
|||
private static function addAttributeOperating($data) |
|||
{ |
|||
$tra = Yii::$app->db->beginTransaction(); |
|||
try { |
|||
if (!$data['attribute']) { |
|||
$tra->commit(); |
|||
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); |
|||
$tra->commit(); |
|||
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) { |
|||
$tra->commit(); |
|||
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'); |
|||
} |
|||
} |
|||
} |
|||
$tra->commit(); |
|||
return true; |
|||
} catch (\Exception $e) { |
|||
$tra->rollBack(); |
|||
throw new \Exception($e->getMessage()); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @param $goodsAttr |
|||
* @throws \Exception |
|||
* 删除商品属性 |
|||
*/ |
|||
private 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 |
|||
* 保存商品属性 |
|||
*/ |
|||
private 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 $attributes |
|||
* @return array |
|||
* 获取属性信息 |
|||
*/ |
|||
public static function getAttribute($attributes) |
|||
{ |
|||
$filter = array(); |
|||
$attributeModel = array(); |
|||
if (!$attributes) { |
|||
return $attributeModel; |
|||
} |
|||
foreach ($attributes 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]]; |
|||
$attributeModel[] = $attribute; |
|||
} else { |
|||
foreach ($attributeModel as $k => $v) { |
|||
if ($v['name'] == $attribute->name) { |
|||
$attributeModel[$k]['value'][] = $value->attr_value; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
return $attributeModel; |
|||
} |
|||
|
|||
/** |
|||
* @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 |
|||
* @param int $type |
|||
* @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_manual' => 0]) |
|||
->all(); |
|||
} else { |
|||
$sku = GoodsSku::find() |
|||
->where(['goods_id' => $id, 'is_manual' => 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/ShopManager::proportionalConversion(ShopManager::UNIT_TYPE_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'] = GoodsAttr::find() |
|||
->select(['id', 'attr_value']) |
|||
->where(['goods_id' => $id, 'is_delete' => GoodsAttr::IS_DELETE_NO]) |
|||
->andWhere(['attr_id' => $attribute->id]) |
|||
->asArray() |
|||
->all(); |
|||
$attributes[] = $ret; |
|||
} |
|||
} |
|||
return $attributes; |
|||
} |
|||
|
|||
/** |
|||
* @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_manual' => 1]); |
|||
} else { |
|||
$query = GoodsSku::find() |
|||
->where(['is_manual' => 0]); |
|||
} |
|||
$sku = $query |
|||
->andWhere(['goods_id' => $goodsId]) |
|||
->all(); |
|||
foreach ($sku as $value) { |
|||
$ids[] = $value->id; |
|||
} |
|||
return $ids; |
|||
} |
|||
|
|||
/** |
|||
* @param $sku |
|||
* @param $type |
|||
* @param $goodsId |
|||
* @throws \Exception |
|||
* 添加或更新sku数据 |
|||
*/ |
|||
public static function AddOrUpdateData($sku, $type, $goodsId) |
|||
{ |
|||
$tra = Yii::$app->db->beginTransaction(); |
|||
try { |
|||
$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 \Exception('参数错误'); |
|||
} |
|||
if ($type == Goods::SKU_MODE_MANUAL) { |
|||
$attr->attr_value = $sku['value']; |
|||
if (!$attr->save()) { |
|||
throw new \Exception('手动属性修改失败'); |
|||
} |
|||
$goodsSku->goods_attr = (string)$attr->id; |
|||
$goodsSku->is_manual = 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']*1000; |
|||
$goodsSku->goods_sn = $goodsModel->sn; |
|||
if (!$goodsSku->save()) { |
|||
throw new \Exception('保存失败,请检查是否有重复规格'); |
|||
} |
|||
$goods = Goods::findOne($goodsId); |
|||
$goods->sku_mode = $type; |
|||
if (!$goods->save()) { |
|||
throw new \Exception('商品sku类型修改失败'); |
|||
} |
|||
$tra->commit(); |
|||
} catch (\Exception $e) { |
|||
$tra->rollBack(); |
|||
throw new \Exception($e->getMessage()); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @param $type |
|||
* @param $data |
|||
* @param $goodsId |
|||
* @return bool |
|||
* @throws Throwable |
|||
* @throws 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_manual' => 1]); |
|||
} else { |
|||
$query = GoodsSku::find() |
|||
->where(['is_manual' => 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(); |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
/** |
|||
* @param $data |
|||
* @return bool |
|||
* @throws \Exception |
|||
* 创建修改商品筛选属性操作 |
|||
*/ |
|||
private 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'); |
|||
} |
|||
} |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
/** |
|||
* @param $goodsFilterAttr |
|||
* @throws \Exception |
|||
* 删除商品筛选属性 |
|||
*/ |
|||
private 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 |
|||
* 保存商品筛选属性 |
|||
*/ |
|||
private 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 $goodsModel |
|||
* @return bool |
|||
* 判断该商品的sku是否存在已选属性,存在则返回true,表示不得删除 |
|||
*/ |
|||
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,表示后台分类可以修改
|
|||
} |
|||
|
|||
/** |
|||
* @param Attribute|$attrModel |
|||
* @return bool |
|||
* 编辑规格属性 |
|||
*/ |
|||
public static function updateAttribute($attrModel) |
|||
{ |
|||
$attrModel->value = str_replace(',', ',', $attrModel->value); |
|||
$attrValue = explode(',', $attrModel->value); |
|||
if (count($attrValue) != count(array_unique($attrValue))) { |
|||
Yii::$app->getSession()->setFlash('error', '不能有相同的属性值'); |
|||
return false; |
|||
} |
|||
if (!$attrModel->save()) { |
|||
Yii::$app->getSession()->setFlash('error', '保存失败'); |
|||
return false; |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
/** |
|||
* 根据pid的父级关系,给字段|___做层级标记 |
|||
* @param $data |
|||
* @param int $pid |
|||
* @param int $lev |
|||
* @return array |
|||
*/ |
|||
public static function btree($data, $pid = 0, $lev = 0) |
|||
{ |
|||
$tree = []; |
|||
foreach ($data as $k => $value) { |
|||
if ($value['pid'] == $pid) { |
|||
$value['name'] = str_repeat('|___', $lev) . $value['name']; |
|||
$tree[] = $value; |
|||
$tree = array_merge($tree, self::btree($data, $value['id'], $lev + 1)); |
|||
} |
|||
} |
|||
return $tree; |
|||
} |
|||
|
|||
/** |
|||
* 构建下拉数组 |
|||
* @param $dataArr |
|||
* @param int $needDefault |
|||
* @return array |
|||
*/ |
|||
public static function constructDropList($dataArr, $needDefault = 1) |
|||
{ |
|||
$data = []; |
|||
if ($needDefault) { |
|||
$data[0] = '一级分类'; |
|||
} |
|||
foreach ($dataArr as $k => $v) { |
|||
$data[$v['id']] = $v['name']; |
|||
} |
|||
return $data; |
|||
} |
|||
|
|||
/** |
|||
* 获取分类中所有下级id |
|||
* @param int $ownId |
|||
* @param array $idArr |
|||
* @return array |
|||
*/ |
|||
public static function subCategoryId($ownId = 0, $idArr = []) |
|||
{ |
|||
$idArr[] = $ownId; |
|||
if ($ownId) { |
|||
$subCategoryModel = Category::find()->where(['pid' => $ownId])->all(); |
|||
if ($subCategoryModel) { |
|||
foreach ($subCategoryModel as $subCategory) { |
|||
$idArr = self::subCategoryId($subCategory->id, $idArr); |
|||
} |
|||
} |
|||
} |
|||
return $idArr; |
|||
} |
|||
|
|||
/** |
|||
* 获取分类中所有下级id |
|||
* @param int $ownId |
|||
* @param array $idArr |
|||
* @return array |
|||
*/ |
|||
public static function subShopCategoryId($ownId = 0, $idArr = []) |
|||
{ |
|||
$idArr[] = $ownId; |
|||
if ($ownId) { |
|||
$subShopCategoryModel = ShopCategory::find()->where(['pid' => $ownId])->all(); |
|||
if ($subShopCategoryModel) { |
|||
foreach ($subShopCategoryModel as $subShopCategory) { |
|||
$idArr = self::subShopCategoryId($subShopCategory->id, $idArr); |
|||
} |
|||
} |
|||
} |
|||
return $idArr; |
|||
} |
|||
} |
@ -1,42 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191119_021851_create_table_atg_shop_category |
|||
*/ |
|||
class m191119_021851_create_table_atg_shop_category extends Migration |
|||
{ |
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function up() |
|||
{ |
|||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="前端商品类别表"'; |
|||
$this->createTable('atg_shop_category', [ |
|||
'id' => $this->primaryKey(), |
|||
'name'=>$this->string(60)->notNull()->comment('类别名称'), |
|||
'pid'=>$this->integer(11)->defaultValue(null)->comment('父级id'), |
|||
'goods_count'=>$this->integer(11)->defaultValue(0)->comment('商品数量'), |
|||
'keywords'=>$this->string(100)->defaultValue(null)->comment('关键字'), |
|||
'desc'=>$this->string(255)->defaultValue(null)->comment('描述'), |
|||
'sort_order'=>$this->smallInteger(3)->defaultValue(0)->comment('排序'), |
|||
'icon_type'=>$this->tinyInteger(1)->defaultValue(null)->comment('图标类型'), |
|||
'icon'=>$this->string(64)->defaultValue(null)->comment('图标'), |
|||
'filter_attr'=>$this->text()->comment('筛选属性'), |
|||
'is_show'=>$this->tinyInteger(1)->defaultValue(0)->comment('是否显示,1为不显示'), |
|||
'is_delete'=>$this->tinyInteger(1)->defaultValue(0)->comment('是否删除,1为已删除'), |
|||
'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'), |
|||
'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'), |
|||
],$tableOptions); |
|||
} |
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function down() |
|||
{ |
|||
$this->dropTable('atg_shop_category'); |
|||
return true; |
|||
} |
|||
} |
@ -1,39 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191119_022641_create_table_atg_category |
|||
*/ |
|||
class m191119_022641_create_table_atg_category extends Migration |
|||
{ |
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function up() |
|||
{ |
|||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="后台商品类别表"'; |
|||
$this->createTable('atg_category', [ |
|||
'id' => $this->primaryKey(), |
|||
'name'=>$this->string(60)->notNull()->comment('类别名称'), |
|||
'pid'=>$this->integer(11)->defaultValue(null)->comment('父级id'), |
|||
'goods_count'=>$this->integer(11)->defaultValue(0)->comment('商品数量'), |
|||
'sort_order'=>$this->smallInteger(3)->defaultValue(0)->comment('排序'), |
|||
'icon_type'=>$this->tinyInteger(1)->defaultValue(null)->comment('图标类型'), |
|||
'icon'=>$this->string(64)->defaultValue(null)->comment('图标'), |
|||
'is_show'=>$this->tinyInteger(1)->defaultValue(0)->comment('是否显示,1为不显示'), |
|||
'is_delete'=>$this->tinyInteger(1)->defaultValue(0)->comment('是否删除,1为已删除'), |
|||
'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'), |
|||
'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'), |
|||
],$tableOptions); |
|||
} |
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function down() |
|||
{ |
|||
$this->dropTable('atg_category'); |
|||
return true; |
|||
} |
|||
} |
@ -1,36 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191119_022939_create_table_atg_attribute |
|||
*/ |
|||
class m191119_022939_create_table_atg_attribute extends Migration |
|||
{ |
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function up() |
|||
{ |
|||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="属性表"'; |
|||
$this->createTable('atg_attribute', [ |
|||
'id' => $this->primaryKey(), |
|||
'name'=>$this->string(50)->notNull()->comment('属性名'), |
|||
'value'=>$this->text()->notNull()->comment('属性值'), |
|||
'type'=>$this->smallInteger(2)->defaultValue(null)->comment('类型'), |
|||
'sort_order'=>$this->smallInteger(3)->defaultValue(null)->comment('排序'), |
|||
'is_delete'=>$this->tinyInteger(1)->defaultValue(0)->comment('是否删除,1为已删除'), |
|||
'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'), |
|||
'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'), |
|||
],$tableOptions); |
|||
} |
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function down() |
|||
{ |
|||
$this->dropTable('atg_attribute'); |
|||
return true; |
|||
} |
|||
} |
@ -1,35 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191119_023115_create_table_atg_goods_attr |
|||
*/ |
|||
class m191119_023115_create_table_atg_goods_attr extends Migration |
|||
{ |
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function up() |
|||
{ |
|||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="商品属性表"'; |
|||
$this->createTable('atg_goods_attr', [ |
|||
'id' => $this->primaryKey(), |
|||
'goods_id'=>$this->integer(11)->notNull()->comment('商品id'), |
|||
'attr_id'=>$this->integer(11)->notNull()->comment('属性id'), |
|||
'attr_value'=>$this->string(50)->notNull()->comment('属性名'), |
|||
'is_delete'=>$this->tinyInteger(1)->defaultValue(0)->comment('是否删除,1为已删除'), |
|||
'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'), |
|||
'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'), |
|||
],$tableOptions); |
|||
} |
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function down() |
|||
{ |
|||
$this->dropTable('atg_goods_attr'); |
|||
return true; |
|||
} |
|||
} |
@ -1,33 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191119_024029_create_table_atg_brand |
|||
*/ |
|||
class m191119_024029_create_table_atg_brand extends Migration |
|||
{ |
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function up() |
|||
{ |
|||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="品牌表"'; |
|||
$this->createTable('atg_brand', [ |
|||
'id' => $this->primaryKey(), |
|||
'name'=>$this->string(50)->notNull()->comment('品牌名'), |
|||
'is_delete'=>$this->tinyInteger(1)->defaultValue(0)->comment('是否删除,1为已删除'), |
|||
'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'), |
|||
'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'), |
|||
],$tableOptions); |
|||
} |
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function down() |
|||
{ |
|||
$this->dropTable('atg_brand'); |
|||
return true; |
|||
} |
|||
} |
@ -1,27 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191119_024205_create_table_atg_goods |
|||
*/ |
|||
class m191119_024205_create_table_atg_goods extends Migration |
|||
{ |
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function up() |
|||
{ |
|||
$sql = file_get_contents(__DIR__."/sql/goods.sql"); |
|||
$this->execute($sql); |
|||
} |
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function down() |
|||
{ |
|||
$this->dropTable("atg_goods"); |
|||
return true; |
|||
} |
|||
} |
@ -1,27 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191119_024345_create_table_atg_goods_sku |
|||
*/ |
|||
class m191119_024345_create_table_atg_goods_sku extends Migration |
|||
{ |
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function up() |
|||
{ |
|||
$sql = file_get_contents(__DIR__."/sql/goods_sku.sql"); |
|||
$this->execute($sql); |
|||
} |
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function down() |
|||
{ |
|||
$this->dropTable("atg_goods_sku"); |
|||
return true; |
|||
} |
|||
} |
@ -1,36 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191119_025607_create_table_atg_supplier |
|||
*/ |
|||
class m191119_025607_create_table_atg_supplier extends Migration |
|||
{ |
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function up() |
|||
{ |
|||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="供应商表"'; |
|||
$this->createTable('atg_supplier', [ |
|||
'id' => $this->primaryKey(), |
|||
'name'=>$this->string(50)->notNull()->comment('供应商名称'), |
|||
'full_name'=>$this->string(50)->notNull()->comment('供应商全称'), |
|||
'phone'=>$this->string(20)->notNull()->comment('手机号码'), |
|||
'address'=>$this->string(50)->notNull()->comment('地址'), |
|||
'is_delete'=>$this->tinyInteger(1)->defaultValue(0)->comment('是否删除,1为已删除'), |
|||
'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'), |
|||
'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'), |
|||
],$tableOptions); |
|||
} |
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function down() |
|||
{ |
|||
$this->dropTable('atg_supplier'); |
|||
return true; |
|||
} |
|||
} |
@ -1,35 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191119_025843_create_table_atg_filter_attr |
|||
*/ |
|||
class m191119_025843_create_table_atg_filter_attr extends Migration |
|||
{ |
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function up() |
|||
{ |
|||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="筛选属性表"'; |
|||
$this->createTable('atg_filter_attr', [ |
|||
'id' => $this->primaryKey(), |
|||
'goods_id'=>$this->integer(11)->notNull()->comment('商品id'), |
|||
'attr_id'=>$this->integer(11)->notNull()->comment('属性id'), |
|||
'attr_value'=>$this->string(50)->notNull()->comment('属性值'), |
|||
'is_delete'=>$this->tinyInteger(1)->defaultValue(0)->comment('是否删除,1为已删除'), |
|||
'created_at'=>$this->integer(11)->defaultValue(null)->comment('创建时间'), |
|||
'updated_at'=>$this->integer(11)->defaultValue(null)->comment('更新时间'), |
|||
],$tableOptions); |
|||
} |
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function down() |
|||
{ |
|||
$this->dropTable('atg_filter_attr'); |
|||
return true; |
|||
} |
|||
} |
@ -1,22 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191125_012449_update_column_icon_type_in_atg_category |
|||
*/ |
|||
class m191125_012449_update_column_icon_type_in_atg_category extends Migration |
|||
{ |
|||
public function up() |
|||
{ |
|||
$this->dropColumn('atg_category', 'icon_type'); |
|||
$this->addColumn('atg_category', 'icon_type', $this->tinyInteger(1)->defaultValue(1)->comment('图标类型')); |
|||
} |
|||
|
|||
public function down() |
|||
{ |
|||
$this->dropColumn('atg_category', 'icon_type'); |
|||
$this->addColumn('atg_category', 'icon_type', $this->tinyInteger(1)->defaultValue(null)->comment('图标类型')); |
|||
return true; |
|||
} |
|||
} |
@ -1,20 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191125_083820_drop_column_icon_type_in_table_atg_category |
|||
*/ |
|||
class m191125_083820_drop_column_icon_type_in_table_atg_category extends Migration |
|||
{ |
|||
public function up() |
|||
{ |
|||
$this->dropColumn('atg_category', 'icon_type'); |
|||
} |
|||
|
|||
public function down() |
|||
{ |
|||
$this->addColumn('atg_category', 'icon_type', $this->tinyInteger(1)->defaultValue(null)->comment('图标类型')); |
|||
return true; |
|||
} |
|||
} |
@ -1,26 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191125_084547_update_column_pid_and_icon_in_table_atg_category |
|||
*/ |
|||
class m191125_084547_update_column_pid_and_icon_in_table_atg_category extends Migration |
|||
{ |
|||
public function up() |
|||
{ |
|||
$this->dropColumn('atg_category', 'icon'); |
|||
$this->addColumn('atg_category', 'icon', $this->integer(11)->defaultValue(null)->comment('图标')); |
|||
$this->dropColumn('atg_category', 'pid'); |
|||
$this->addColumn('atg_category', 'pid', $this->integer(11)->defaultValue(0)->comment('父级id')); |
|||
} |
|||
|
|||
public function down() |
|||
{ |
|||
$this->dropColumn('atg_category', 'icon'); |
|||
$this->addColumn('atg_category', 'icon', $this->string(64)->defaultValue(null)->comment('图标')); |
|||
$this->dropColumn('atg_category', 'pid'); |
|||
$this->addColumn('atg_category', 'pid', $this->integer(11)->defaultValue(null)->comment('父级id')); |
|||
return true; |
|||
} |
|||
} |
@ -1,20 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191125_104137_drop_column_icon_type_in_table_atg_shop_category |
|||
*/ |
|||
class m191125_104137_drop_column_icon_type_in_table_atg_shop_category extends Migration |
|||
{ |
|||
public function up() |
|||
{ |
|||
$this->dropColumn('atg_shop_category', 'icon_type'); |
|||
} |
|||
|
|||
public function down() |
|||
{ |
|||
$this->addColumn('atg_shop_category', 'icon_type', $this->tinyInteger(1)->defaultValue(null)->comment('图标类型')); |
|||
return true; |
|||
} |
|||
} |
@ -1,26 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191125_104510_update_column_pid_and_icon_in_table_atg_shop_category |
|||
*/ |
|||
class m191125_104510_update_column_pid_and_icon_in_table_atg_shop_category extends Migration |
|||
{ |
|||
public function up() |
|||
{ |
|||
$this->dropColumn('atg_shop_category', 'icon'); |
|||
$this->addColumn('atg_shop_category', 'icon', $this->integer(11)->defaultValue(null)->comment('图标')); |
|||
$this->dropColumn('atg_shop_category', 'pid'); |
|||
$this->addColumn('atg_shop_category', 'pid', $this->integer(11)->defaultValue(0)->comment('父级id')); |
|||
} |
|||
|
|||
public function down() |
|||
{ |
|||
$this->dropColumn('atg_shop_category', 'icon'); |
|||
$this->addColumn('atg_shop_category', 'icon', $this->string(64)->defaultValue(null)->comment('图标')); |
|||
$this->dropColumn('atg_shop_category', 'pid'); |
|||
$this->addColumn('atg_shop_category', 'pid', $this->integer(11)->defaultValue(null)->comment('父级id')); |
|||
return true; |
|||
} |
|||
} |
@ -1,20 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191127_114228_add_column_is_manaul_in_table_atg_goods_sku |
|||
*/ |
|||
class m191127_114228_add_column_is_manaul_in_table_atg_goods_sku extends Migration |
|||
{ |
|||
public function up() |
|||
{ |
|||
$this->addColumn('atg_goods_sku', 'is_manaul', $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否手动')); |
|||
} |
|||
|
|||
public function down() |
|||
{ |
|||
$this->dropColumn('atg_goods_sku', 'is_manaul'); |
|||
return true; |
|||
} |
|||
} |
@ -1,20 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191129_010349_add_column_sku_mode_in_atg_goods |
|||
*/ |
|||
class m191129_010349_add_column_sku_mode_in_atg_goods extends Migration |
|||
{ |
|||
public function up() |
|||
{ |
|||
$this->addColumn('atg_goods', 'sku_mode', $this->tinyInteger(1)->notNull()->defaultValue(1)->comment('sku类型')); |
|||
} |
|||
|
|||
public function down() |
|||
{ |
|||
$this->dropColumn('atg_goods', 'sku_mode'); |
|||
return true; |
|||
} |
|||
} |
@ -1,26 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191129_020131_add_columns_goods_id_and_attr_id_in_table_atg_goods_attr |
|||
*/ |
|||
class m191129_020131_add_columns_goods_id_and_attr_id_in_table_atg_goods_attr extends Migration |
|||
{ |
|||
public function up() |
|||
{ |
|||
$this->dropColumn('atg_goods_attr', 'goods_id'); |
|||
$this->dropColumn('atg_goods_attr', 'attr_id'); |
|||
$this->addColumn('atg_goods_attr', 'goods_id', $this->integer(11)->notNull()->defaultValue(0)->comment('商品id')); |
|||
$this->addColumn('atg_goods_attr', 'attr_id', $this->integer(11)->notNull()->defaultValue(0)->comment('属性id')); |
|||
} |
|||
|
|||
public function down() |
|||
{ |
|||
$this->dropColumn('atg_goods_attr', 'goods_id'); |
|||
$this->dropColumn('atg_goods_attr', 'attr_id'); |
|||
$this->addColumn('atg_goods_attr', 'goods_id', $this->integer(11)->notNull()->comment('商品id')); |
|||
$this->addColumn('atg_goods_attr', 'attr_id', $this->integer(11)->notNull()->comment('属性id')); |
|||
return true; |
|||
} |
|||
} |
@ -1,20 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191130_004933_add_column_cat_id_in_table_atg_attribute |
|||
*/ |
|||
class m191130_004933_add_column_cat_id_in_table_atg_attribute extends Migration |
|||
{ |
|||
public function up() |
|||
{ |
|||
$this->addColumn('atg_attribute', 'cat_id', $this->integer(11)->notNull()->defaultValue(0)->comment('后台商品分类id')); |
|||
} |
|||
|
|||
public function down() |
|||
{ |
|||
$this->dropColumn('atg_attribute', 'cat_id'); |
|||
return true; |
|||
} |
|||
} |
@ -1,27 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191202_082041_drop_columns_in_table_atg_goods_sku |
|||
*/ |
|||
class m191202_082041_drop_columns_in_table_atg_goods_sku extends Migration |
|||
{ |
|||
public function up() |
|||
{ |
|||
$this->dropColumn('atg_goods_sku', 'weight'); |
|||
$this->dropColumn('atg_goods_sku', 'length'); |
|||
$this->dropColumn('atg_goods_sku', 'width'); |
|||
$this->dropColumn('atg_goods_sku', 'height'); |
|||
$this->dropColumn('atg_goods_sku', 'diameter'); |
|||
} |
|||
|
|||
public function down() |
|||
{ |
|||
$this->addColumn('atg_goods_sku', 'weight', $this->integer(8)->defaultValue(null)->comment('重量')); |
|||
$this->addColumn('atg_goods_sku', 'length', $this->integer(8)->defaultValue(null)->comment('长度')); |
|||
$this->addColumn('atg_goods_sku', 'width', $this->integer(8)->defaultValue(null)->comment('宽度')); |
|||
$this->addColumn('atg_goods_sku', 'height', $this->integer(8)->defaultValue(null)->comment('高度')); |
|||
$this->addColumn('atg_goods_sku', 'diameter', $this->integer(8)->defaultValue(null)->comment('直径')); |
|||
} |
|||
} |
@ -1,26 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191207_004848_add_columns_is_taking_is_express_express_type_uniform_postage_in_table_atg_goods |
|||
*/ |
|||
class m191207_004848_add_columns_is_taking_is_express_express_type_uniform_postage_in_table_atg_goods extends Migration |
|||
{ |
|||
public function up() |
|||
{ |
|||
$this->addColumn('atg_goods', 'is_taking', $this->tinyInteger(1)->defaultValue(0)->notNull()->comment('是否自提')); |
|||
$this->addColumn('atg_goods', 'is_express', $this->tinyInteger(1)->defaultValue(0)->notNull()->comment('是否快递发货')); |
|||
$this->addColumn('atg_goods', 'express_type', $this->tinyInteger(2)->defaultValue(0)->comment('快递运费方式')); |
|||
$this->addColumn('atg_goods', 'uniform_postage', $this->integer(20)->defaultValue(0)->comment('统一邮费')); |
|||
} |
|||
|
|||
public function down() |
|||
{ |
|||
$this->dropColumn('atg_goods', 'is_taking'); |
|||
$this->dropColumn('atg_goods', 'is_express'); |
|||
$this->dropColumn('atg_goods', 'express_type'); |
|||
$this->dropColumn('atg_goods', 'uniform_postage'); |
|||
return true; |
|||
} |
|||
} |
@ -1,23 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191209_091129_update_columns_in_table_atg_goods |
|||
*/ |
|||
class m191209_091129_update_columns_in_table_atg_goods extends Migration |
|||
{ |
|||
public function up() |
|||
{ |
|||
$sql = file_get_contents(__DIR__."/sql/update_goods.sql"); |
|||
$this->execute($sql); |
|||
} |
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function down() |
|||
{ |
|||
return true; |
|||
} |
|||
} |
@ -1,20 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191209_091524_add_column_weight_in_table_atg_goods_sku |
|||
*/ |
|||
class m191209_091524_add_column_weight_in_table_atg_goods_sku extends Migration |
|||
{ |
|||
public function up() |
|||
{ |
|||
$this->addColumn('atg_goods_sku', 'weight', $this->integer(8)->defaultValue("0")->unsigned()->comment('重量')); |
|||
} |
|||
|
|||
public function down() |
|||
{ |
|||
$this->dropColumn('atg_goods_sku', 'weight'); |
|||
return true; |
|||
} |
|||
} |
@ -1,22 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191211_060934_update_column_limit_count_in_table_atg_goods |
|||
*/ |
|||
class m191211_060934_update_column_limit_count_in_table_atg_goods extends Migration |
|||
{ |
|||
public function up() |
|||
{ |
|||
$this->dropColumn('atg_goods', 'limit_count'); |
|||
$this->addColumn('atg_goods', 'limit_count', $this->integer(11)->defaultValue("0")->comment("限购数量")); |
|||
} |
|||
|
|||
public function down() |
|||
{ |
|||
$this->dropColumn('atg_goods', 'limit_count'); |
|||
$this->addColumn('atg_goods', 'limit_count', $this->integer(11)->defaultValue(null)->comment("限购数量")); |
|||
return true; |
|||
} |
|||
} |
@ -1,22 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191211_092335_update_column_sort_order_in_table_atg_goods |
|||
*/ |
|||
class m191211_092335_update_column_sort_order_in_table_atg_goods extends Migration |
|||
{ |
|||
public function up() |
|||
{ |
|||
$this->dropColumn('atg_goods', 'sort_order'); |
|||
$this->addColumn('atg_goods', 'sort_order', $this->smallInteger(3)->defaultValue("999")->comment('排序')); |
|||
} |
|||
|
|||
public function down() |
|||
{ |
|||
$this->dropColumn('atg_goods', 'sort_order'); |
|||
$this->addColumn('atg_goods', 'sort_order', $this->smallInteger(3)->defaultValue(null)->comment('排序')); |
|||
return true; |
|||
} |
|||
} |
@ -1,41 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191217_091658_update_column_is_manual_in_table_atg_goods_sku |
|||
*/ |
|||
class m191217_091658_update_column_is_manual_in_table_atg_goods_sku extends Migration |
|||
{ |
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function safeUp() |
|||
{ |
|||
$this->dropColumn('atg_goods_sku', 'is_manaul'); |
|||
$this->addColumn('atg_goods_sku', 'is_manual', $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否手动')); |
|||
} |
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function safeDown() |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
/* |
|||
// Use up()/down() to run migration code without a transaction.
|
|||
public function up() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public function down() |
|||
{ |
|||
echo "m191217_091658_update_column_is_manual_in_table_atg_goods_sku cannot be reverted.\n"; |
|||
|
|||
return false; |
|||
} |
|||
*/ |
|||
} |
@ -1,26 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\db\Migration; |
|||
|
|||
/** |
|||
* Class m191217_092101_add_column_sku_image_in_table_atg_goods_sku |
|||
*/ |
|||
class m191217_092101_add_column_sku_image_in_table_atg_goods_sku extends Migration |
|||
{ |
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function safeUp() |
|||
{ |
|||
$this->addColumn('atg_goods_sku', 'sku_image', $this->integer(11)->notNull()->defaultValue("0")->comment('sku图片id')); |
|||
} |
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function safeDown() |
|||
{ |
|||
$this->dropColumn('atg_goods_sku', 'sku_image'); |
|||
return true; |
|||
} |
|||
} |
@ -1,37 +0,0 @@ |
|||
DROP TABLE IF EXISTS `atg_goods`; |
|||
CREATE TABLE `atg_goods` ( |
|||
`id` int(11) NOT NULL AUTO_INCREMENT, |
|||
`pid` int(11) DEFAULT NULL COMMENT '父级id', |
|||
`cat_id` int(11) NOT NULL COMMENT '后台商品类别id', |
|||
`brand_id` int(11) NOT NULL COMMENT '品牌id', |
|||
`shop_cat_id` int(11) NOT NULL COMMENT '前端商品类别id', |
|||
`name` varchar(120) NOT NULL COMMENT '商品名称', |
|||
`sn` varchar(60) DEFAULT NULL COMMENT '商品唯一货号', |
|||
`code` varchar(50) DEFAULT NULL COMMENT '商品货码', |
|||
`supplier_id` int(11) DEFAULT NULL COMMENT '供应商id', |
|||
`weight` mediumint(8) DEFAULT NULL unique COMMENT '重量', |
|||
`length` mediumint(8) DEFAULT NULL unique COMMENT '长度', |
|||
`width` mediumint(8) DEFAULT NULL unique COMMENT '宽度', |
|||
`height` mediumint(8) DEFAULT NULL unique COMMENT '高度', |
|||
`diameter` mediumint(8) DEFAULT NULL unique COMMENT '直径', |
|||
`unit` varchar(16) DEFAULT NULL COMMENT '单位', |
|||
`sold_count` int(10) DEFAULT NULL unique COMMENT '已售数量', |
|||
`limit_count` int(10) DEFAULT NULL COMMENT '限购数量', |
|||
`stock` int(10) DEFAULT NULL COMMENT '库存', |
|||
`stock_warn` int(10) DEFAULT NULL COMMENT '库存警告', |
|||
`market_price` int(20) DEFAULT NULL unique COMMENT '市场价', |
|||
`price` int(20) DEFAULT NULL unique COMMENT '销售价', |
|||
`brief` varchar(255) DEFAULT NULL COMMENT '简介', |
|||
`description` text COMMENT '详细介绍', |
|||
`image` int(11) DEFAULT NULL COMMENT '图片id', |
|||
`model_id` int(11) DEFAULT NULL COMMENT '模型id', |
|||
`is_sale` tinyint(1) DEFAULT '0' COMMENT '该商品是否开放销售,1为是,0为否', |
|||
`sort_order` smallint(3) DEFAULT NULL COMMENT '排序', |
|||
`bouns_points` mediumint(8) DEFAULT NULL COMMENT '奖励积分', |
|||
`experience_points` mediumint(8) DEFAULT NULL COMMENT '经验值', |
|||
`is_delete` tinyint(1) DEFAULT '0' COMMENT '是否删除,1为已删除', |
|||
`express_template` int(11) DEFAULT NULL COMMENT '配送详情id', |
|||
`created_at` int(10) DEFAULT '0' COMMENT '创建时间', |
|||
`updated_at` int(10) DEFAULT '0' COMMENT '更新时间', |
|||
PRIMARY KEY (`id`) |
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='商品表'; |
@ -1,24 +0,0 @@ |
|||
DROP TABLE IF EXISTS `atg_goods_sku`; |
|||
CREATE TABLE `atg_goods_sku` ( |
|||
`id` int(11) NOT NULL AUTO_INCREMENT, |
|||
`goods_id` int(11) NOT NULL COMMENT '商品id', |
|||
`goods_code` varchar(50) DEFAULT NULL COMMENT '商品条码', |
|||
`goods_sn` varchar(60) NOT NULL COMMENT '商品唯一货号', |
|||
`goods_attr` varchar(60) DEFAULT NULL COMMENT '属性匹配', |
|||
`weight` mediumint(8) DEFAULT NULL COMMENT '重量', |
|||
`length` mediumint(8) DEFAULT NULL COMMENT '长度', |
|||
`width` mediumint(8) DEFAULT NULL COMMENT '宽度', |
|||
`height` mediumint(8) DEFAULT NULL COMMENT '高度', |
|||
`diameter` mediumint(8) DEFAULT NULL COMMENT '直径', |
|||
`sold_count` int(10) DEFAULT NULL COMMENT '已售数量', |
|||
`stock` int(10) DEFAULT NULL COMMENT '库存', |
|||
`market_price` int(20) DEFAULT NULL COMMENT '市场价', |
|||
`price` int(20) DEFAULT NULL COMMENT '销售价', |
|||
`model_id` int(11) DEFAULT NULL COMMENT '模型id', |
|||
`is_sale` tinyint(1) DEFAULT '0' COMMENT '该商品是否开放销售,1为是,0为否', |
|||
`sort_order` smallint(3) DEFAULT '0' COMMENT '排序', |
|||
`is_delete` tinyint(1) DEFAULT '0' COMMENT '是否删除,1为已删除', |
|||
`created_at` int(10) DEFAULT '0' COMMENT '创建时间', |
|||
`updated_at` int(10) DEFAULT '0' COMMENT '更新时间', |
|||
PRIMARY KEY (`id`) |
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='商品sku表'; |
@ -1,17 +0,0 @@ |
|||
ALTER TABLE `atg_goods` DROP `weight`; |
|||
ALTER TABLE `atg_goods` DROP `length`; |
|||
ALTER TABLE `atg_goods` DROP `width`; |
|||
ALTER TABLE `atg_goods` DROP `height`; |
|||
ALTER TABLE `atg_goods` DROP `diameter`; |
|||
ALTER TABLE `atg_goods` DROP `sold_count`; |
|||
ALTER TABLE `atg_goods` DROP `market_price`; |
|||
ALTER TABLE `atg_goods` DROP `price`; |
|||
|
|||
ALTER TABLE `atg_goods` ADD COLUMN `weight` mediumint(8) UNSIGNED DEFAULT NULL COMMENT '重量'; |
|||
ALTER TABLE `atg_goods` ADD COLUMN `length` mediumint(8) UNSIGNED DEFAULT NULL COMMENT '长度'; |
|||
ALTER TABLE `atg_goods` ADD COLUMN `width` mediumint(8) UNSIGNED DEFAULT NULL COMMENT '宽度'; |
|||
ALTER TABLE `atg_goods` ADD COLUMN `height` mediumint(8) UNSIGNED DEFAULT NULL COMMENT '高度'; |
|||
ALTER TABLE `atg_goods` ADD COLUMN `diameter` mediumint(8) UNSIGNED DEFAULT NULL COMMENT '直径'; |
|||
ALTER TABLE `atg_goods` ADD COLUMN `sold_count` int(10) UNSIGNED DEFAULT NULL COMMENT '已售数量'; |
|||
ALTER TABLE `atg_goods` ADD COLUMN `market_price` int(20) UNSIGNED DEFAULT NULL COMMENT '市场价'; |
|||
ALTER TABLE `atg_goods` ADD COLUMN `price` int(20) UNSIGNED DEFAULT NULL COMMENT '销售价'; |
@ -1,114 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\goods\models\ars; |
|||
|
|||
use Yii; |
|||
use yii\behaviors\TimestampBehavior; |
|||
use backend\modules\goods\models\ars\Category; |
|||
|
|||
/** |
|||
* This is the model class for table "atg_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 'atg_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; |
|||
} |
|||
if (!$this->sort_order) { |
|||
$this->sort_order = "999"; |
|||
} |
|||
return parent::beforeSave($insert); // TODO: Change the autogenerated stub
|
|||
} |
|||
|
|||
public function getCategory() |
|||
{ |
|||
return $this->hasOne(Category::className(), ['id' => 'cat_id']); |
|||
} |
|||
} |
@ -1,82 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\goods\models\ars; |
|||
|
|||
use Yii; |
|||
use yii\behaviors\TimestampBehavior; |
|||
|
|||
/** |
|||
* This is the model class for table "atg_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 'atg_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(); |
|||
} |
|||
} |
@ -1,132 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\goods\models\ars; |
|||
|
|||
use Yii; |
|||
use yii\behaviors\TimestampBehavior; |
|||
use backend\modules\file\models\ars\File; |
|||
use backend\modules\goods\logic\goods\GoodsManager; |
|||
|
|||
/** |
|||
* This is the model class for table "atg_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 'atg_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::class, |
|||
'createdAtAttribute' => 'created_at', |
|||
'updatedAtAttribute' => 'updated_at', |
|||
'value' => function() { |
|||
return time(); |
|||
}, |
|||
], |
|||
]; |
|||
} |
|||
|
|||
/** |
|||
* @param int $ownId |
|||
* @param int $needDefault |
|||
* @return array |
|||
* 数据键值对 |
|||
*/ |
|||
public static function modelColumn($ownId = 0, $needDefault = 1) |
|||
{ |
|||
$query = self::find()->where(['is_delete' => self::IS_DELETE_NO]); |
|||
if ($ownId) { |
|||
$query->andWhere(['not in', 'id', GoodsManager::subCategoryId($ownId)]); |
|||
} |
|||
$data = $query->asArray()->all(); |
|||
$data = GoodsManager::btree($data); |
|||
$data = GoodsManager::constructDropList($data, $needDefault); |
|||
return $data; |
|||
} |
|||
|
|||
public function getIconFile() |
|||
{ |
|||
return $this->hasOne(File::className(), ['id' => 'icon']); |
|||
} |
|||
|
|||
public function beforeSave($insert) |
|||
{ |
|||
if (!$this->sort_order) { |
|||
$this->sort_order = "999"; |
|||
} |
|||
return parent::beforeSave($insert); // TODO: Change the autogenerated stub
|
|||
} |
|||
} |
@ -1,81 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\goods\models\ars; |
|||
|
|||
use Yii; |
|||
use yii\behaviors\TimestampBehavior; |
|||
|
|||
/** |
|||
* This is the model class for table "atg_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 'atg_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(); |
|||
}, |
|||
], |
|||
]; |
|||
} |
|||
} |
@ -1,288 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\goods\models\ars; |
|||
|
|||
use Yii; |
|||
use yii\behaviors\TimestampBehavior; |
|||
use backend\modules\goods\models\ars\Category; |
|||
use backend\modules\goods\models\ars\ShopCategory; |
|||
use backend\modules\file\models\ars\File; |
|||
use backend\modules\goods\models\ars\Brand; |
|||
use backend\modules\goods\models\ars\Supplier; |
|||
|
|||
/** |
|||
* This is the model class for table "atg_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类型 |
|||
* @property int $is_taking 是否自提 |
|||
* @property int $is_express 是否快递发货 |
|||
* @property int $express_type 快递运费方式 |
|||
* @property int $uniform_postage 统一邮费 |
|||
*/ |
|||
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类型手写
|
|||
//是否自提is_taking
|
|||
const IS_TAKING_NO = 0; //否
|
|||
const IS_TAKING_YES = 1; //是
|
|||
//是否快递发货is_express
|
|||
const IS_EXPRESS_NO = 0; //否
|
|||
const IS_EXPRESS_YES = 1; //是
|
|||
//快递运费计算方式express_type
|
|||
const EXPRESS_TYPE_UNIFORM_POSTAGE = 1; //统一邮费
|
|||
const EXPRESS_TYPE_EXPRESS_TEMPLATE = 2; //运费模板
|
|||
|
|||
public static $isTaking = [ |
|||
self::IS_TAKING_NO => '否', |
|||
self::IS_TAKING_YES => '是' |
|||
]; |
|||
public static $isExpress = [ |
|||
self::IS_EXPRESS_NO => '否', |
|||
self::IS_EXPRESS_YES => '是' |
|||
]; |
|||
public static $expressType = [ |
|||
self::EXPRESS_TYPE_UNIFORM_POSTAGE => '统一邮费', |
|||
self::EXPRESS_TYPE_EXPRESS_TEMPLATE => '运费模板' |
|||
]; |
|||
public static $isSale = [ |
|||
self::IS_SALE_NO => '不在售', |
|||
self::IS_SALE_YES => '在售' |
|||
]; |
|||
//无限库存
|
|||
const UNLIMITED_STOCK = -1; |
|||
|
|||
public $ruleVerify = 0;//规则验证是否通过
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public static function tableName() |
|||
{ |
|||
return 'atg_goods'; |
|||
} |
|||
|
|||
public function fields() |
|||
{ |
|||
$fields = parent::fields(); |
|||
unset($fields['is_sale']); |
|||
unset($fields['sort_order']); |
|||
unset($fields['pid']); |
|||
unset($fields['cat_id']); |
|||
unset($fields['brand_id']); |
|||
unset($fields['shop_cat_id']); |
|||
unset($fields['is_delete']); |
|||
unset($fields['express_template']); |
|||
unset($fields['model_id']); |
|||
return $fields; |
|||
} |
|||
|
|||
/** |
|||
* {@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', 'image', 'model_id', 'is_sale', 'sort_order', 'bouns_points', 'experience_points', 'is_delete', 'express_template', 'sku_mode', 'is_taking', 'is_express', 'express_type'], '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', 'uniform_postage'], 'checkNegative'], |
|||
[['uniform_postage', 'market_price', 'price'], 'safe'] |
|||
]; |
|||
} |
|||
|
|||
/** |
|||
* @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' => '配送详情', |
|||
'created_at' => '创建时间', |
|||
'updated_at' => '更新时间', |
|||
'sku_mode' => 'sku类型', |
|||
'is_taking' => '是否自提', |
|||
'is_express' => '是否快递发货', |
|||
'express_type' => '快递运费方式', |
|||
'uniform_postage' => '统一邮费', |
|||
]; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* @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); |
|||
} |
|||
if (!$this->limit_count) { |
|||
$this->limit_count = 0; |
|||
} |
|||
if (!$this->sort_order) { |
|||
$this->sort_order = "999"; |
|||
} |
|||
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']); |
|||
} |
|||
} |
@ -1,81 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\goods\models\ars; |
|||
|
|||
use Yii; |
|||
use yii\behaviors\TimestampBehavior; |
|||
|
|||
/** |
|||
* This is the model class for table "atg_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 'atg_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(); |
|||
}, |
|||
], |
|||
]; |
|||
} |
|||
} |
@ -1,107 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\goods\models\ars; |
|||
|
|||
use Yii; |
|||
use yii\behaviors\TimestampBehavior; |
|||
|
|||
/** |
|||
* This is the model class for table "atg_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_manual 是否手动 |
|||
* @property int $weight 重量 |
|||
* @property int $sku_image sku图片id |
|||
*/ |
|||
class GoodsSku extends \yii\db\ActiveRecord |
|||
{ |
|||
//是否手动is_manual
|
|||
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 'atg_goods_sku'; |
|||
} |
|||
|
|||
/** |
|||
* {@inheritdoc} |
|||
*/ |
|||
public function rules() |
|||
{ |
|||
return [ |
|||
[['goods_id', 'goods_sn'], 'required'], |
|||
[['goods_id', 'sold_count', 'stock', 'market_price', 'price', 'model_id', 'is_sale', 'sort_order', 'is_delete', 'is_manual', 'sku_image'], 'integer'], |
|||
[['goods_code'], 'string', 'max' => 50], |
|||
[['goods_sn', 'goods_attr'], 'string', 'max' => 60], |
|||
[['weight'], 'safe'] |
|||
]; |
|||
} |
|||
|
|||
/** |
|||
* {@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' => '更新时间', |
|||
'weight' => '重量', |
|||
'sku_image' => 'sku图片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(); |
|||
}, |
|||
], |
|||
]; |
|||
} |
|||
} |
@ -1,144 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\goods\models\ars; |
|||
|
|||
use backend\modules\goods\logic\goods\GoodsManager; |
|||
use Yii; |
|||
use yii\behaviors\TimestampBehavior; |
|||
use backend\modules\file\models\ars\File; |
|||
use yii\db\ActiveQuery; |
|||
|
|||
/** |
|||
* This is the model class for table "atg_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 'atg_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(); |
|||
}, |
|||
], |
|||
]; |
|||
} |
|||
|
|||
/** |
|||
* @param int $ownId |
|||
* @param int $needDefault |
|||
* @return array 数据键值对 |
|||
* 数据键值对 |
|||
*/ |
|||
public static function modelColumn($ownId = 0, $needDefault = 1) |
|||
{ |
|||
$query = self::find()->where(['is_delete' => self::IS_DELETE_NO]); |
|||
if ($ownId) { |
|||
$query->andWhere(['not in', 'id', GoodsManager::subShopCategoryId($ownId)]); |
|||
} |
|||
$data = $query->asArray()->all(); |
|||
$data = GoodsManager::btree($data); |
|||
$data = GoodsManager::constructDropList($data, $needDefault); |
|||
return $data; |
|||
} |
|||
|
|||
public function getIconFile() |
|||
{ |
|||
return $this->hasOne(File::className(), ['id' => 'icon']); |
|||
} |
|||
|
|||
public function beforeSave($insert) |
|||
{ |
|||
if ($this->filter_attr != null && is_array($this->filter_attr)) { |
|||
$this->filter_attr = implode(',', $this->filter_attr); |
|||
} |
|||
if (!$this->sort_order) { |
|||
$this->sort_order = "999"; |
|||
} |
|||
return parent::beforeSave($insert); // TODO: Change the autogenerated stub
|
|||
} |
|||
} |
@ -1,96 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\goods\models\ars; |
|||
|
|||
use Yii; |
|||
use yii\behaviors\TimestampBehavior; |
|||
|
|||
/** |
|||
* This is the model class for table "atg_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 'atg_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' => '\backend\modules\goods\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(); |
|||
} |
|||
} |
@ -1,162 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\goods\models\searchs; |
|||
|
|||
use yii\base\Model; |
|||
use yii\data\ActiveDataProvider; |
|||
use yii\helpers\ArrayHelper; |
|||
use backend\modules\goods\models\ars\Attribute; |
|||
|
|||
/** |
|||
* AttributeSearch represents the model behind the search form of `backend\modules\goods\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; |
|||
} |
|||
} |
@ -1,152 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\goods\models\searchs; |
|||
|
|||
use yii\base\Model; |
|||
use yii\data\ActiveDataProvider; |
|||
use yii\helpers\ArrayHelper; |
|||
use backend\modules\goods\models\ars\Brand; |
|||
|
|||
/** |
|||
* BrandSearch represents the model behind the search form of `backend\modules\goods\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; |
|||
} |
|||
} |
@ -1,184 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\goods\models\searchs; |
|||
|
|||
use yii\base\Model; |
|||
use yii\data\ActiveDataProvider; |
|||
use yii\helpers\ArrayHelper; |
|||
use backend\modules\goods\models\ars\Category; |
|||
use yii\bootstrap4\Html; |
|||
|
|||
/** |
|||
* CategorySearch represents the model behind the search form of `backend\modules\goods\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', |
|||
'pid', |
|||
[ |
|||
'attribute' => 'pid', |
|||
'value' => function ($model) { |
|||
$parentsCategory = Category::findOne($model->pid); |
|||
if ($parentsCategory) { |
|||
return $parentsCategory->name; |
|||
} else { |
|||
return '一级分类'; |
|||
} |
|||
} |
|||
], |
|||
['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; |
|||
} |
|||
} |
@ -1,231 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\goods\models\searchs; |
|||
|
|||
use yii\base\Model; |
|||
use yii\data\ActiveDataProvider; |
|||
use yii\helpers\ArrayHelper; |
|||
use backend\modules\goods\models\ars\Goods; |
|||
use yii\bootstrap4\Html; |
|||
use backend\modules\shop\logic\ShopManager; |
|||
|
|||
/** |
|||
* GoodsSearch represents the model behind the search form of `backend\modules\goods\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' |
|||
], |
|||
['attribute' => 'image', |
|||
'contentOptions' => [ |
|||
'align' => 'center', |
|||
], |
|||
'width'=>'10%', |
|||
'format' => 'raw', |
|||
'value' => function ($model) { |
|||
return $model->imageFile ? |
|||
Html::img(['/'.$model->imageFile->path], ['style' => 'width:80px']) |
|||
: '<div class="table_not_setting">未设置</div>'; |
|||
|
|||
} |
|||
], |
|||
'id', |
|||
'name', |
|||
[ |
|||
'attribute' => 'market_price', |
|||
'value' => function ($model) { |
|||
return sprintf("%1\$.2f",$model->market_price / ShopManager::proportionalConversion(ShopManager::UNIT_TYPE_MONEY)); |
|||
} |
|||
], |
|||
[ |
|||
'attribute' => 'price', |
|||
'value' => function ($model) { |
|||
return sprintf("%1\$.2f",$model->price / ShopManager::proportionalConversion(ShopManager::UNIT_TYPE_MONEY)); |
|||
} |
|||
], |
|||
[ |
|||
'attribute' => 'stock', |
|||
'width' => '5%', |
|||
'value' => function ($model) { |
|||
if ($model->stock == -1) { |
|||
return '未开启'; |
|||
} else { |
|||
return $model->stock; |
|||
} |
|||
}, |
|||
], |
|||
['attribute' => 'is_sale', |
|||
'width' => '5%', |
|||
'value' => |
|||
function ($model) { |
|||
return $model->is_sale==Goods::IS_SALE_YES ? '在售' : '不在售'; |
|||
|
|||
}, |
|||
], |
|||
'sort_order', |
|||
[ |
|||
'class' => 'iron\grid\ActionColumn', |
|||
'align' => 'center', |
|||
'config' => [ |
|||
[ |
|||
'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; |
|||
} |
|||
} |
@ -1,162 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\goods\models\searchs; |
|||
|
|||
use yii\base\Model; |
|||
use yii\bootstrap4\Html; |
|||
use yii\data\ActiveDataProvider; |
|||
use yii\helpers\ArrayHelper; |
|||
use backend\modules\goods\models\ars\ShopCategory; |
|||
|
|||
/** |
|||
* ShopCategorySearch represents the model behind the search form of `backend\modules\goods\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; |
|||
} |
|||
} |
@ -1,161 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace backend\modules\goods\models\searchs; |
|||
|
|||
use yii\base\Model; |
|||
use yii\data\ActiveDataProvider; |
|||
use yii\helpers\ArrayHelper; |
|||
use backend\modules\goods\models\ars\Supplier; |
|||
|
|||
/** |
|||
* SupplierSearch represents the model behind the search form of `backend\modules\goods\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; |
|||
} |
|||
} |
@ -1,32 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\helpers\Html; |
|||
use yii\bootstrap4\ActiveForm; |
|||
use linyao\widgets\Select2; |
|||
use backend\modules\goods\models\ars\Category; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\goods\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> |
@ -1,62 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\helpers\Html; |
|||
use yii\widgets\ActiveForm; |
|||
use \blobt\widgets\DateRangePicker; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model common\models\searchs\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, 'name', [ |
|||
"template" => "{input}{error}", |
|||
"inputOptions" => [ |
|||
"placeholder" => "规格名称", |
|||
"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(); ?>
|
@ -1,18 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\helpers\Html; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\goods\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> |
@ -1,28 +0,0 @@ |
|||
<?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> |
@ -1,19 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\helpers\Html; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\goods\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> |
@ -1,33 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\helpers\Html; |
|||
use yii\widgets\DetailView; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\goods\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> |
@ -1,24 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\helpers\Html; |
|||
use yii\bootstrap4\ActiveForm; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\goods\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> |
@ -1,62 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\helpers\Html; |
|||
use yii\widgets\ActiveForm; |
|||
use \blobt\widgets\DateRangePicker; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model common\models\searchs\BrandSearch */ |
|||
/* @var $form yii\widgets\ActiveForm */ |
|||
?>
|
|||
|
|||
<?php $form = ActiveForm::begin([ |
|||
'action' => ['index'], |
|||
'method' => 'get', |
|||
'validateOnType' => true, |
|||
]); |
|||
?>
|
|||
<div class="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, 'name', [ |
|||
"template" => "{input}{error}", |
|||
"inputOptions" => [ |
|||
"placeholder" => "品牌名", |
|||
"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(); ?>
|
@ -1,18 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\helpers\Html; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\goods\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> |
@ -1,28 +0,0 @@ |
|||
<?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> |
@ -1,19 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\helpers\Html; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\goods\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> |
@ -1,30 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\helpers\Html; |
|||
use yii\widgets\DetailView; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\goods\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> |
@ -1,47 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\helpers\Html; |
|||
use yii\bootstrap4\ActiveForm; |
|||
use blobt\widgets\Icheck; |
|||
use yii\helpers\Url; |
|||
use backend\modules\goods\models\ars\Category; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\goods\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(Category::modelColumn($model->id)) ?>
|
|||
|
|||
<?= $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> |
@ -1,62 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\helpers\Html; |
|||
use yii\widgets\ActiveForm; |
|||
use \blobt\widgets\DateRangePicker; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model common\models\searchs\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, 'name', [ |
|||
"template" => "{input}{error}", |
|||
"inputOptions" => [ |
|||
"placeholder" => "类别名称", |
|||
"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(); ?>
|
@ -1,18 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\helpers\Html; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\goods\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> |
@ -1,28 +0,0 @@ |
|||
<?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> |
@ -1,19 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\helpers\Html; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\goods\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> |
@ -1,41 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\helpers\Html; |
|||
use yii\widgets\DetailView; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\goods\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 == \backend\modules\goods\models\ars\Category::IS_SHOW_DISPLAY ? '显示':'隐藏'; |
|||
} |
|||
], |
|||
'created_at:datetime', |
|||
'updated_at:datetime', |
|||
], |
|||
]) ?>
|
|||
|
|||
</div> |
@ -1,27 +0,0 @@ |
|||
<?php |
|||
/* |
|||
* The MIT License |
|||
* |
|||
* Copyright 2019 Blobt. |
|||
* |
|||
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|||
* of this software and associated documentation files (the "Software"), to deal |
|||
* in the Software without restriction, including without limitation the rights |
|||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|||
* copies of the Software, and to permit persons to whom the Software is |
|||
* furnished to do so, subject to the following conditions: |
|||
* |
|||
* The above copyright notice and this permission notice shall be included in |
|||
* all copies or substantial portions of the Software. |
|||
* |
|||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|||
* THE SOFTWARE. |
|||
*/ |
|||
?>
|
|||
|
|||
配置页 |
@ -1,107 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\helpers\Html; |
|||
use yii\bootstrap4\ActiveForm; |
|||
use backend\modules\goods\models\ars\Category; |
|||
use backend\modules\goods\models\ars\Brand; |
|||
use backend\modules\goods\models\ars\ShopCategory; |
|||
use backend\modules\goods\models\ars\Supplier; |
|||
use yii\helpers\Url; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\goods\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> |
@ -1,104 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\helpers\Html; |
|||
use yii\widgets\ActiveForm; |
|||
use \blobt\widgets\DateRangePicker; |
|||
use linyao\widgets\Select2; |
|||
use backend\modules\goods\models\ars\Category; |
|||
use backend\modules\goods\models\ars\ShopCategory; |
|||
|
|||
/* @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, 'name', [ |
|||
"template" => "{input}{error}", |
|||
"inputOptions" => [ |
|||
"placeholder" => "商品名称", |
|||
"class" => "form-control", |
|||
], |
|||
"errorOptions" => [ |
|||
"class" => "error-tips" |
|||
] |
|||
]) |
|||
?>
|
|||
</div> |
|||
<div class="col"> |
|||
<?= $form->field($model, 'sn', [ |
|||
"template" => "{input}{error}", |
|||
"inputOptions" => [ |
|||
"placeholder" => "商品唯一货号", |
|||
"class" => "form-control", |
|||
], |
|||
"errorOptions" => [ |
|||
"class" => "error-tips" |
|||
] |
|||
]) |
|||
?>
|
|||
</div> |
|||
<div class="col"> |
|||
<?= $form->field($model, 'cat_id', [ |
|||
"template" => "{input}{error}", |
|||
"inputOptions" => [ |
|||
"placeholder" => "后台商品类别", |
|||
"class" => "form-control", |
|||
], |
|||
"errorOptions" => [ |
|||
"class" => "error-tips" |
|||
] |
|||
])->dropDownList(Category::modelColumn(0, 0), ['prompt' => '后台商品类别']); |
|||
?>
|
|||
</div> |
|||
<div class="col"> |
|||
<?= $form->field($model, 'shop_cat_id', [ |
|||
"template" => "{input}{error}", |
|||
"inputOptions" => [ |
|||
"placeholder" => "前端商品类别", |
|||
"class" => "form-control", |
|||
], |
|||
"errorOptions" => [ |
|||
"class" => "error-tips" |
|||
] |
|||
])->dropDownList(ShopCategory::modelColumn(0,0), ['prompt' => '前端商品类别']); |
|||
?>
|
|||
</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(); ?>
|
@ -1,22 +0,0 @@ |
|||
<?php |
|||
|
|||
use backend\modules\goods\models\ars\Attribute; |
|||
use backend\modules\goods\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> |
@ -1,112 +0,0 @@ |
|||
<?php |
|||
|
|||
use kartik\tabs\TabsX; |
|||
use yii\bootstrap4\ActiveForm; |
|||
use yii\bootstrap4\Html; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\goods\models\ars\Goods */ |
|||
|
|||
$this->title = '创建商品'; |
|||
$this->params['breadcrumbs'][] = ['label' => '商品列表', 'url' => ['index']]; |
|||
$this->params['breadcrumbs'][] = $this->title; |
|||
Yii::$app->params['bsVersion'] = '4.x'; |
|||
?>
|
|||
<style> |
|||
.btn-success, .btn-float { |
|||
bottom: 120px; |
|||
} |
|||
.btn-success { |
|||
position: fixed; |
|||
display: block; |
|||
top: unset; |
|||
right: 50px; |
|||
bottom: 60px; |
|||
width: 60px; |
|||
height: 60px; |
|||
line-height: 60px; |
|||
padding: 0; |
|||
border-radius: 50%; |
|||
font-size: 1.6em; |
|||
box-shadow: 0 0 20px 5px rgba(0, 0, 0, .2); |
|||
z-index: 10000; |
|||
} |
|||
.btn-info { |
|||
position: fixed; |
|||
display: block; |
|||
top: unset; |
|||
right: 50px; |
|||
bottom: 130px; |
|||
width: 60px; |
|||
height: 60px; |
|||
line-height: 60px; |
|||
padding: 0; |
|||
border-radius: 50%; |
|||
font-size: 1.6em; |
|||
box-shadow: 0 0 20px 5px rgba(0, 0, 0, .2); |
|||
z-index: 10000; |
|||
} |
|||
</style> |
|||
<div class="goods-create"> |
|||
|
|||
<?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-shipping-fast"></i> 物流信息', |
|||
'content' => $this->render('express', ['model' => $model, |
|||
'form' => $form, |
|||
]), |
|||
], |
|||
[ |
|||
'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> |
|||
</div> |
|||
<div class="form-group"> |
|||
<?= Html::submitButton('<i class="fa fa-check"></i>', ['class' => 'btn-float btn btn-success']) ?>
|
|||
<?= Html::a('<i class="fa fa-times"></i>', ['index'], ['class' => 'btn-float btn btn-info']) ?>
|
|||
</div> |
|||
|
|||
<?php ActiveForm::end(); ?>
|
|||
|
|||
</div> |
@ -1,90 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\helpers\Url; |
|||
use blobt\widgets\Icheck; |
|||
use backend\modules\goods\models\ars\Goods; |
|||
use linyao\widgets\Select2; |
|||
use backend\modules\shop\models\ars\ExpressTemplate; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\goods\models\ars\Goods */ |
|||
/* @var $form yii\widgets\ActiveForm */ |
|||
?>
|
|||
<?= $form->field($model, 'is_taking')->widget(Icheck::className(), ['items' => Goods::$isTaking, 'type' => 'radio']) ?>
|
|||
|
|||
<?= $form->field($model, 'is_express')->widget(Icheck::className(), ['items' => Goods::$isExpress, 'type' => 'radio']) ?>
|
|||
|
|||
<fieldset id="isExpress" style="display: <?= $model->is_express == Goods::IS_EXPRESS_NO ? 'none' : 'block' ?>"> |
|||
<?= $form->field($model, 'express_type')->widget(Icheck::className(), ['items' => Goods::$expressType, 'type' => 'radio']) ?>
|
|||
|
|||
<fieldset id="uniformPostage" style="display: <?= $model->express_type == Goods::EXPRESS_TYPE_UNIFORM_POSTAGE ? 'block' : 'none' ?>"> |
|||
<?= $form->field($model, 'uniform_postage')->textInput() ?>
|
|||
</fieldset> |
|||
|
|||
<fieldset id="expressTemplate" style="display: <?= $model->express_type == Goods::EXPRESS_TYPE_EXPRESS_TEMPLATE ? 'block' : 'none' ?>"> |
|||
<?= $form->field($model, 'express_template')->widget(Select2::className(), ["items" => ExpressTemplate::modelColumn()]) ?>
|
|||
</fieldset> |
|||
</fieldset> |
|||
|
|||
<?php |
|||
$js =<<<JS |
|||
$(document).ready(function(){ |
|||
if(!$("#goods-uniform_postage").val()){ |
|||
$("#goods-uniform_postage").val("0.00") |
|||
}else{ |
|||
$("#goods-uniform_postage").val(toFixeds($("#goods-uniform_postage").val(), 2)); |
|||
} |
|||
$("input:radio[name='Goods[is_express]']").on('ifChecked', function(event){ |
|||
if ($(this).val() === '1') { |
|||
$("#isExpress").show(); |
|||
} else { |
|||
$("#isExpress").hide(); |
|||
} |
|||
}) |
|||
$("input:radio[name='Goods[express_type]']").on('ifChecked', function(event){ |
|||
if ($(this).val() === '1') { |
|||
$("#uniformPostage").show(); |
|||
$("#expressTemplate").hide(); |
|||
} else { |
|||
$("#expressTemplate").show(); |
|||
$("#uniformPostage").hide(); |
|||
} |
|||
}) |
|||
$("#goods-uniform_postage").blur(function(){ |
|||
if(!$(this).val()){ |
|||
$(this).val("0.00") |
|||
} |
|||
if(isNaN($(this).val())){ |
|||
$(this).val("0.00") |
|||
} |
|||
if($(this).val().indexOf('-') != -1){ |
|||
$(this).val("0.00") |
|||
} |
|||
var basicPrice = $(this).val(); |
|||
$(this).val(toFixeds($(this).val(), 2)); |
|||
}) |
|||
//金额补全
|
|||
function toFixeds(val, pre) { |
|||
const num = parseFloat(val); |
|||
// eslint-disable-next-line no-restricted-globals
|
|||
if (isNaN(num)) { |
|||
return false; |
|||
} |
|||
const p = 10 ** pre; |
|||
const value = num * p; |
|||
let f = (Math.round(value) / p).toString(); |
|||
let rs = f.indexOf('.'); |
|||
if (rs < 0) { |
|||
rs = f.length; |
|||
f += '.'; |
|||
} |
|||
while (f.length <= rs + pre) { |
|||
f += '0'; |
|||
} |
|||
return f; |
|||
} |
|||
}) |
|||
JS; |
|||
$this->registerJs($js); |
|||
|
|||
?>
|
@ -1,22 +0,0 @@ |
|||
<?php |
|||
|
|||
use backend\modules\goods\models\ars\Attribute; |
|||
use backend\modules\goods\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> |
@ -1,139 +0,0 @@ |
|||
<?php |
|||
|
|||
use backend\modules\goods\models\ars\Category; |
|||
use backend\modules\goods\models\ars\Brand; |
|||
use backend\modules\goods\models\ars\ShopCategory; |
|||
use backend\modules\goods\models\ars\Supplier; |
|||
use yii\bootstrap4\Html; |
|||
use backend\modules\goods\models\ars\Goods; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\goods\models\ars\Goods */ |
|||
/* @var $form yii\widgets\ActiveForm */ |
|||
/* @var $judgeGoodsCategory //判断是否能够修改 */ |
|||
?>
|
|||
<style> |
|||
.form-group { |
|||
margin-right: 40px; |
|||
} |
|||
.goods-base-info { |
|||
display: flex; |
|||
} |
|||
</style> |
|||
<div class="goods-base-info"> |
|||
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
|
|||
|
|||
<?= $form->field($model, 'sn')->textInput(['maxlength' => true]) ?>
|
|||
|
|||
<?= $form->field($model, 'code')->textInput(['maxlength' => true]) ?>
|
|||
|
|||
<?= $form->field($model, 'market_price')->textInput() ?>
|
|||
|
|||
<?= $form->field($model, 'price')->textInput() ?>
|
|||
</div> |
|||
|
|||
<div class="goods-base-info"> |
|||
<?= $form->field($model, 'cat_id')->dropDownList(Category::modelColumn(0,0), ['prompt' => '请选择', 'disabled' => $judgeGoodsCategory]) ?>
|
|||
|
|||
<?= $form->field($model, 'brand_id')->dropDownList(Brand::modelColumn(0,0), ['prompt' => '请选择']) ?>
|
|||
|
|||
<?= $form->field($model, 'shop_cat_id')->dropDownList(ShopCategory::modelColumn(), ['prompt' => '请选择']) ?>
|
|||
|
|||
<?= $form->field($model, 'supplier_id')->dropDownList(Supplier::modelColumn(), ['prompt' => '请选择']) ?>
|
|||
|
|||
<?= $form->field($model, 'is_sale')->radioList(Goods::$isSale) ?>
|
|||
</div> |
|||
|
|||
<div class="goods-base-info"> |
|||
<?= $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() ?>
|
|||
</div> |
|||
|
|||
<div class="goods-base-info"> |
|||
<?= $form->field($model, 'sort_order')->textInput() ?>
|
|||
|
|||
<?= $form->field($model, 'bouns_points')->textInput() ?>
|
|||
|
|||
<?= $form->field($model, 'experience_points')->textInput() ?>
|
|||
|
|||
<?= $form->field($model, 'unit')->textInput(['maxlength' => true]) ?>
|
|||
|
|||
<?= $form->field($model, 'limit_count')->textInput() ?>
|
|||
</div> |
|||
|
|||
<div class="goods-base-info"> |
|||
<?= $form->field($model, 'stock')->textInput()->label('库存(-1为不限制)') ?>
|
|||
|
|||
<?= $form->field($model, 'stock_warn')->textInput(['placeholder' => '低于该值警告库存不足']) ?>
|
|||
</div> |
|||
|
|||
<?= $form->field($model, 'brief')->textInput(['maxlength' => true]) ?>
|
|||
<?php |
|||
$js =<<<JS |
|||
$(document).ready(function(){ |
|||
if(!$("#goods-market_price").val()){ |
|||
$("#goods-market_price").val("0.00") |
|||
}else{ |
|||
$("#goods-market_price").val(toFixeds($("#goods-market_price").val(), 2)); |
|||
} |
|||
if(!$("#goods-price").val()){ |
|||
$("#goods-price").val("0.00") |
|||
}else{ |
|||
$("#goods-price").val(toFixeds($("#goods-price").val(), 2)); |
|||
} |
|||
$("#goods-market_price").blur(function(){ |
|||
if(!$(this).val()){ |
|||
$(this).val("0.00") |
|||
} |
|||
if(isNaN($(this).val())){ |
|||
$(this).val("0.00") |
|||
} |
|||
if($(this).val().indexOf('-') != -1){ |
|||
$(this).val("0.00") |
|||
} |
|||
$(this).val(toFixeds($(this).val(), 2)); |
|||
}) |
|||
$("#goods-price").blur(function(){ |
|||
if(!$(this).val()){ |
|||
$(this).val("0.00") |
|||
} |
|||
if(isNaN($(this).val())){ |
|||
$(this).val("0.00") |
|||
} |
|||
if($(this).val().indexOf('-') != -1){ |
|||
$(this).val("0.00") |
|||
} |
|||
$(this).val(toFixeds($(this).val(), 2)); |
|||
}) |
|||
//金额补全
|
|||
function toFixeds(val, pre) { |
|||
const num = parseFloat(val); |
|||
// eslint-disable-next-line no-restricted-globals
|
|||
if (isNaN(num)) { |
|||
return false; |
|||
} |
|||
const p = 10 ** pre; |
|||
const value = num * p; |
|||
let f = (Math.round(value) / p).toString(); |
|||
let rs = f.indexOf('.'); |
|||
if (rs < 0) { |
|||
rs = f.length; |
|||
f += '.'; |
|||
} |
|||
while (f.length <= rs + pre) { |
|||
f += '0'; |
|||
} |
|||
return f; |
|||
} |
|||
}) |
|||
JS; |
|||
$this->registerJs($js); |
|||
|
|||
?>
|
@ -1,28 +0,0 @@ |
|||
<?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> |
@ -1,25 +0,0 @@ |
|||
<?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> |
|||
|
@ -1,35 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\helpers\Url; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\goods\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, |
|||
'previewConfig' => [ |
|||
'url' => Url::to(['image-file', 'fileIdStr' => $model->coverImageId, 'ruleverify' => $model->ruleVerify]), |
|||
], |
|||
])->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('商品详情图') ?>
|
@ -1,15 +0,0 @@ |
|||
<?php |
|||
|
|||
use backend\modules\goods\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> |
@ -1,123 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\bootstrap4\Html; |
|||
use yii\bootstrap4\ActiveForm; |
|||
use kartik\tabs\TabsX; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\goods\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'; |
|||
?>
|
|||
<style> |
|||
.btn-success, .btn-float { |
|||
bottom: 120px; |
|||
} |
|||
.btn-success { |
|||
position: fixed; |
|||
display: block; |
|||
top: unset; |
|||
right: 50px; |
|||
bottom: 60px; |
|||
width: 60px; |
|||
height: 60px; |
|||
line-height: 60px; |
|||
padding: 0; |
|||
border-radius: 50%; |
|||
font-size: 1.6em; |
|||
box-shadow: 0 0 20px 5px rgba(0, 0, 0, .2); |
|||
z-index: 10000; |
|||
} |
|||
.btn-info { |
|||
position: fixed; |
|||
display: block; |
|||
top: unset; |
|||
right: 50px; |
|||
bottom: 130px; |
|||
width: 60px; |
|||
height: 60px; |
|||
line-height: 60px; |
|||
padding: 0; |
|||
border-radius: 50%; |
|||
font-size: 1.6em; |
|||
box-shadow: 0 0 20px 5px rgba(0, 0, 0, .2); |
|||
z-index: 10000; |
|||
} |
|||
</style> |
|||
<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-shipping-fast"></i> 物流信息', |
|||
'content' => $this->render('express', ['model' => $model, |
|||
'form' => $form, |
|||
]), |
|||
], |
|||
[ |
|||
'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> |
|||
</div> |
|||
|
|||
<div class="form-group"> |
|||
<?= Html::submitButton('<i class="fa fa-check"></i>', ['class' => 'btn-float btn btn-success']) ?>
|
|||
<?= Html::a('<i class="fa fa-times"></i>', ['index'], ['class' => 'btn-float btn btn-info']) ?>
|
|||
</div> |
|||
|
|||
<?php ActiveForm::end(); ?>
|
|||
</div> |
|||
|
|||
<?php |
|||
// $this->render('_form', [
|
|||
// 'model' => $model,
|
|||
// ])
|
|||
?>
|
|||
|
|||
</div> |
@ -1,113 +0,0 @@ |
|||
<?php |
|||
|
|||
use backend\modules\goods\models\ars\Goods; |
|||
use yii\bootstrap4\Html; |
|||
use yii\widgets\DetailView; |
|||
use backend\modules\file\models\ars\File; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\goods\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->imageFile ? |
|||
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> |
@ -1,55 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\helpers\Html; |
|||
use yii\bootstrap4\ActiveForm; |
|||
use blobt\widgets\Icheck; |
|||
use yii\helpers\Url; |
|||
use backend\modules\goods\models\ars\Attribute; |
|||
use linyao\widgets\Select2; |
|||
use backend\modules\goods\models\ars\ShopCategory; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\goods\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(ShopCategory::modelColumn($model->id)) ?>
|
|||
|
|||
<?= $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> |
@ -1,62 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\helpers\Html; |
|||
use yii\widgets\ActiveForm; |
|||
use \blobt\widgets\DateRangePicker; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model common\models\searchs\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, 'name', [ |
|||
"template" => "{input}{error}", |
|||
"inputOptions" => [ |
|||
"placeholder" => "类别名称", |
|||
"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(); ?>
|
@ -1,18 +0,0 @@ |
|||
<?php |
|||
|
|||
use yii\helpers\Html; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\goods\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> |
@ -1,28 +0,0 @@ |
|||
<?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> |
Some files were not shown because too many files changed in this diff
Write
Preview
Loading…
Cancel
Save
Reference in new issue