From 68971ca5f807871386cf38b84f7f188dbd628e4c Mon Sep 17 00:00:00 2001 From: linyaostalker <602604991@qq.com> Date: Mon, 9 Dec 2019 15:30:50 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=87=91=E9=A2=9Djs?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E9=AA=8C=E8=AF=81=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/modules/goods/views/goods/goods.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/backend/modules/goods/views/goods/goods.php b/backend/modules/goods/views/goods/goods.php index 1f9bf09..ade0fa9 100755 --- a/backend/modules/goods/views/goods/goods.php +++ b/backend/modules/goods/views/goods/goods.php @@ -64,24 +64,35 @@ use backend\modules\goods\models\ars\Goods; registerJs($js); From bfebc37a95e4dc4d23dfaa697ba095c6654742ba Mon Sep 17 00:00:00 2001 From: linyaostalker <602604991@qq.com> Date: Mon, 9 Dec 2019 15:34:16 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=95=86=E5=93=81?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E7=89=A9=E6=B5=81=E4=BF=A1=E6=81=AF=E6=A8=A1?= =?UTF-8?q?=E5=9D=97js=E8=A1=A8=E5=8D=95=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/modules/goods/views/goods/express.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/modules/goods/views/goods/express.php b/backend/modules/goods/views/goods/express.php index df9ecb9..3db8668 100755 --- a/backend/modules/goods/views/goods/express.php +++ b/backend/modules/goods/views/goods/express.php @@ -28,6 +28,10 @@ use backend\modules\shop\models\ars\ExpressTemplate; registerJs($js); From db7374f12f615be0b31e1a70924375505c399955 Mon Sep 17 00:00:00 2001 From: linyaostalker <602604991@qq.com> Date: Mon, 9 Dec 2019 15:42:52 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=95=86=E5=93=81?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E4=BF=AE=E6=94=B9=E6=97=B6=E4=BB=B7=E6=A0=BC?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/modules/goods/views/goods/express.php | 2 ++ backend/modules/goods/views/goods/goods.php | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/backend/modules/goods/views/goods/express.php b/backend/modules/goods/views/goods/express.php index 3db8668..66682cb 100755 --- a/backend/modules/goods/views/goods/express.php +++ b/backend/modules/goods/views/goods/express.php @@ -31,6 +31,8 @@ use backend\modules\shop\models\ars\ExpressTemplate; $(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') { diff --git a/backend/modules/goods/views/goods/goods.php b/backend/modules/goods/views/goods/goods.php index ade0fa9..c94a5f4 100755 --- a/backend/modules/goods/views/goods/goods.php +++ b/backend/modules/goods/views/goods/goods.php @@ -67,9 +67,13 @@ $js =<< Date: Mon, 9 Dec 2019 15:43:52 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=BC=80=E5=8F=91=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E4=BB=B7=E6=A0=BC=E4=BF=9D=E5=AD=98=E6=9C=BA?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/modules/goods/controllers/GoodsController.php | 8 ++------ backend/modules/goods/logic/goods/GoodsManager.php | 3 +++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/backend/modules/goods/controllers/GoodsController.php b/backend/modules/goods/controllers/GoodsController.php index ee91963..91d07c6 100755 --- a/backend/modules/goods/controllers/GoodsController.php +++ b/backend/modules/goods/controllers/GoodsController.php @@ -101,9 +101,6 @@ class GoodsController extends Controller $model->is_express = Goods::IS_EXPRESS_YES; $model->express_type = Goods::EXPRESS_TYPE_EXPRESS_TEMPLATE; if ($model->load(Yii::$app->request->post()) && $model->validate()) { - if ($model->uniform_postage) { - $model->uniform_postage *= 100; - } //商品封面图和商品详情图上传保存处理 $res = GoodsManager::updateGoods(Yii::$app->request->post(), $model); if ($res['status']) { @@ -133,9 +130,6 @@ class GoodsController extends Controller $cover_image_old_id_str = $model->image; $detail_image_old_id_str = $model->detailImageId; if ($model->load(Yii::$app->request->post()) && $model->validate()) { - if ($model->uniform_postage) { - $model->uniform_postage *= 100; - } //商品封面图和商品详情图上传保存处理 $res = GoodsManager::updateGoods(Yii::$app->request->post(), $model, $cover_image_old_id_str, $detail_image_old_id_str); if ($res['status']) { @@ -143,6 +137,8 @@ class GoodsController extends Controller } } $model->uniform_postage /= 100; + $model->market_price /= 100; + $model->price /= 100; $attributeModel = GoodsManager::getAttribute($id); $checkAttr = GoodsManager::getSkuInfo($id); $filterAttributeModel = GoodsManager::getFilterAttribute($id); diff --git a/backend/modules/goods/logic/goods/GoodsManager.php b/backend/modules/goods/logic/goods/GoodsManager.php index eb0de2f..e5f7e8c 100755 --- a/backend/modules/goods/logic/goods/GoodsManager.php +++ b/backend/modules/goods/logic/goods/GoodsManager.php @@ -73,6 +73,9 @@ class GoodsManager { $attribute = $data['attribute']; $filterAttribute = $data['filterattribute']; + $model->uniform_postage *= 100; + $model->market_price *= 100; + $model->price *= 100; $tra = Yii::$app->db->beginTransaction(); try { if (!$model->save()) { From 57db2fc18b6e363cb14689db513fcb077b36603e Mon Sep 17 00:00:00 2001 From: linyaostalker <602604991@qq.com> Date: Mon, 9 Dec 2019 17:13:44 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81?= =?UTF-8?q?=E8=A1=A8=E5=AD=97=E6=AE=B5=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...1129_update_columns_in_table_atg_goods.php | 23 ++++++++++++ .../goods/migrations/sql/update_goods.sql | 37 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 backend/modules/goods/migrations/m191209_091129_update_columns_in_table_atg_goods.php create mode 100644 backend/modules/goods/migrations/sql/update_goods.sql diff --git a/backend/modules/goods/migrations/m191209_091129_update_columns_in_table_atg_goods.php b/backend/modules/goods/migrations/m191209_091129_update_columns_in_table_atg_goods.php new file mode 100644 index 0000000..c13bf75 --- /dev/null +++ b/backend/modules/goods/migrations/m191209_091129_update_columns_in_table_atg_goods.php @@ -0,0 +1,23 @@ +execute($sql); + } + + /** + * {@inheritdoc} + */ + public function down() + { + return true; + } +} diff --git a/backend/modules/goods/migrations/sql/update_goods.sql b/backend/modules/goods/migrations/sql/update_goods.sql new file mode 100644 index 0000000..35e72bf --- /dev/null +++ b/backend/modules/goods/migrations/sql/update_goods.sql @@ -0,0 +1,37 @@ +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='商品表'; \ No newline at end of file From 19978a553f482ee14a37d693cc07f899f38f296f Mon Sep 17 00:00:00 2001 From: linyaostalker <602604991@qq.com> Date: Mon, 9 Dec 2019 17:31:54 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81?= =?UTF-8?q?=E8=A1=A8=E9=83=A8=E5=88=86=E6=9C=89=E9=97=AE=E9=A2=98=E7=9A=84?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=EF=BC=8C=E5=95=86=E5=93=81sku=E8=A1=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=87=8D=E9=87=8F=E5=AD=97=E6=AE=B5=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=87=8D=E9=87=8F=E5=AD=97=E6=AE=B5=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods/logic/goods/GoodsManager.php | 5 +- ...d_column_weight_in_table_atg_goods_sku.php | 20 +++++++ .../goods/migrations/sql/update_goods.sql | 54 ++++++------------- backend/modules/goods/models/ars/GoodsSku.php | 5 +- .../controllers/ExpressTemplateController.php | 8 +-- 5 files changed, 48 insertions(+), 44 deletions(-) create mode 100644 backend/modules/goods/migrations/m191209_091524_add_column_weight_in_table_atg_goods_sku.php diff --git a/backend/modules/goods/logic/goods/GoodsManager.php b/backend/modules/goods/logic/goods/GoodsManager.php index e5f7e8c..ea4d990 100755 --- a/backend/modules/goods/logic/goods/GoodsManager.php +++ b/backend/modules/goods/logic/goods/GoodsManager.php @@ -303,7 +303,7 @@ class GoodsManager $data['id'] = $sku->id; $data['price'] = $sku->price; $data['stock'] = $sku->stock; - $data['weight'] = $sku->weight; + $data['weight'] = $sku->weight/1000; return $data; } @@ -398,7 +398,7 @@ class GoodsManager $goodsSku->goods_id = $goodsId; $goodsSku->price = $sku['price']; $goodsSku->stock = $sku['stock']; - $goodsSku->weight = $sku['weight']; + $goodsSku->weight = $sku['weight']*1000; $goodsSku->goods_sn = $goodsModel->sn; if (!$goodsSku->save()) { throw new \Exception('保存失败,请检查是否有重复规格'); @@ -408,6 +408,7 @@ class GoodsManager if (!$goods->save()) { throw new \Exception('商品sku类型修改失败'); } + $tra->commit(); } catch (\Exception $e) { $tra->rollBack(); throw new \Exception($e->getMessage()); diff --git a/backend/modules/goods/migrations/m191209_091524_add_column_weight_in_table_atg_goods_sku.php b/backend/modules/goods/migrations/m191209_091524_add_column_weight_in_table_atg_goods_sku.php new file mode 100644 index 0000000..73eb933 --- /dev/null +++ b/backend/modules/goods/migrations/m191209_091524_add_column_weight_in_table_atg_goods_sku.php @@ -0,0 +1,20 @@ +addColumn('atg_goods_sku', 'weight', $this->integer(8)->defaultValue("0")->unsigned()->comment('重量')); + } + + public function down() + { + $this->dropColumn('atg_goods_sku', 'weight'); + return true; + } +} diff --git a/backend/modules/goods/migrations/sql/update_goods.sql b/backend/modules/goods/migrations/sql/update_goods.sql index 35e72bf..04b4213 100644 --- a/backend/modules/goods/migrations/sql/update_goods.sql +++ b/backend/modules/goods/migrations/sql/update_goods.sql @@ -1,37 +1,17 @@ -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='商品表'; \ No newline at end of file +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 '销售价'; \ No newline at end of file diff --git a/backend/modules/goods/models/ars/GoodsSku.php b/backend/modules/goods/models/ars/GoodsSku.php index ab0b17d..68bf7e9 100755 --- a/backend/modules/goods/models/ars/GoodsSku.php +++ b/backend/modules/goods/models/ars/GoodsSku.php @@ -24,6 +24,7 @@ use yii\behaviors\TimestampBehavior; * @property int $created_at 创建时间 * @property int $updated_at 更新时间 * @property int $is_manaul 是否手动 + * @property int $weight 重量 */ class GoodsSku extends \yii\db\ActiveRecord { @@ -48,9 +49,10 @@ class GoodsSku extends \yii\db\ActiveRecord { return [ [['goods_id', 'goods_sn'], 'required'], - [['goods_id', 'diameter', 'sold_count', 'stock', 'market_price', 'price', 'model_id', 'is_sale', 'sort_order', 'is_delete', 'is_manaul'], 'integer'], + [['goods_id', 'sold_count', 'stock', 'market_price', 'price', 'model_id', 'is_sale', 'sort_order', 'is_delete', 'is_manaul'], 'integer'], [['goods_code'], 'string', 'max' => 50], [['goods_sn', 'goods_attr'], 'string', 'max' => 60], + [['weight'], 'safe'] ]; } @@ -75,6 +77,7 @@ class GoodsSku extends \yii\db\ActiveRecord 'is_delete' => '是否删除,1为已删除', 'created_at' => '创建时间', 'updated_at' => '更新时间', + 'weight' => '重量', ]; } diff --git a/backend/modules/shop/controllers/ExpressTemplateController.php b/backend/modules/shop/controllers/ExpressTemplateController.php index 7b712cb..454bbb5 100755 --- a/backend/modules/shop/controllers/ExpressTemplateController.php +++ b/backend/modules/shop/controllers/ExpressTemplateController.php @@ -210,8 +210,8 @@ class ExpressTemplateController extends Controller $model->basic_price *= 100; $model->extra_price *= 100; if ($expressTemplateModel->calculation_type == ExpressTemplate::CALCULATION_TYPE_WEIGHT) { - $model->basic_count *= 10; - $model->extra_count *= 10; + $model->basic_count *= 1000; + $model->extra_count *= 1000; } else { $model->basic_count *= 1; $model->extra_count *= 1; @@ -279,8 +279,8 @@ class ExpressTemplateController extends Controller $model->basic_price *= 100; $model->extra_price *= 100; if ($expressTemplateModel->calculation_type == ExpressTemplate::CALCULATION_TYPE_WEIGHT) { - $model->basic_count *= 10; - $model->extra_count *= 10; + $model->basic_count *= 1000; + $model->extra_count *= 1000; } else { $model->basic_count *= 1; $model->extra_count *= 1;