From b579dc6e771660202581a2fe16f729a22e356a1f Mon Sep 17 00:00:00 2001 From: devil Date: Wed, 29 Jul 2020 15:54:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=AD=E7=89=A9=E8=BD=A6=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/form/Goods.php | 72 +++++++++---------- .../admin/view/default/site/attachment.html | 21 +++++- application/admin/view/default/site/base.html | 11 ++- .../admin/view/default/site/verify.html | 14 +++- application/api/controller/Devtest.php | 23 ++++++ application/service/BuyService.php | 5 ++ 6 files changed, 102 insertions(+), 44 deletions(-) diff --git a/application/admin/form/Goods.php b/application/admin/form/Goods.php index 2e3f8c808..b931694fd 100644 --- a/application/admin/form/Goods.php +++ b/application/admin/form/Goods.php @@ -86,18 +86,30 @@ class Goods ], ], [ - 'label' => '商品类型', + 'label' => '商品分类', 'view_type' => 'field', - 'view_key' => 'site_type', - 'view_data_key' => 'name', - 'view_data' => lang('common_site_type_list'), + 'view_key' => 'category_text', 'search_config' => [ - 'form_type' => 'select', - 'where_type' => 'in', - 'data' => lang('common_site_type_list'), - 'data_key' => 'value', + 'form_type' => 'module', + 'template' => 'lib/module/goods_category', + 'form_name' => 'id', + 'where_type' => 'in', + 'where_handle_custom' => 'WhereValueGoodsCategory', + 'data' => GoodsService::GoodsCategoryAll(), + ], + ], + [ + 'label' => '品牌', + 'view_type' => 'field', + 'view_key' => 'brand_name', + 'search_config' => [ + 'form_type' => 'module', + 'template' => 'lib/module/category_brand', + 'form_name' => 'brand_id', + 'data' => BrandService::CategoryBrand(), + 'data_key' => 'id', 'data_name' => 'name', - 'is_multiple' => 1, + 'where_type' => 'in', ], ], [ @@ -176,6 +188,21 @@ class Goods 'is_multiple' => 1, ], ], + [ + 'label' => '商品类型', + 'view_type' => 'field', + 'view_key' => 'site_type', + 'view_data_key' => 'name', + 'view_data' => lang('common_site_type_list'), + 'search_config' => [ + 'form_type' => 'select', + 'where_type' => 'in', + 'data' => lang('common_site_type_list'), + 'data_key' => 'value', + 'data_name' => 'name', + 'is_multiple' => 1, + ], + ], [ 'label' => '商品型号', 'view_type' => 'field', @@ -185,33 +212,6 @@ class Goods 'where_type' => 'like', ], ], - [ - 'label' => '商品分类', - 'view_type' => 'field', - 'view_key' => 'category_text', - 'search_config' => [ - 'form_type' => 'module', - 'template' => 'lib/module/goods_category', - 'form_name' => 'id', - 'where_type' => 'in', - 'where_handle_custom' => 'WhereValueGoodsCategory', - 'data' => GoodsService::GoodsCategoryAll(), - ], - ], - [ - 'label' => '品牌', - 'view_type' => 'field', - 'view_key' => 'brand_name', - 'search_config' => [ - 'form_type' => 'module', - 'template' => 'lib/module/category_brand', - 'form_name' => 'brand_id', - 'data' => BrandService::CategoryBrand(), - 'data_key' => 'id', - 'data_name' => 'name', - 'where_type' => 'in', - ], - ], [ 'label' => '生产地', 'view_type' => 'field', diff --git a/application/admin/view/default/site/attachment.html b/application/admin/view/default/site/attachment.html index 43e3a0fdc..e857ecbe6 100644 --- a/application/admin/view/default/site/attachment.html +++ b/application/admin/view/default/site/attachment.html @@ -11,15 +11,30 @@
- +
+ + + + +
- +
+ + + + +
- +
+ + + + +
diff --git a/application/admin/view/default/site/base.html b/application/admin/view/default/site/base.html index ae47d8885..08bac2a13 100755 --- a/application/admin/view/default/site/base.html +++ b/application/admin/view/default/site/base.html @@ -75,9 +75,14 @@
- - -
+ +
+ + + + +
+
diff --git a/application/admin/view/default/site/verify.html b/application/admin/view/default/site/verify.html index a98bb08ef..e773359ba 100644 --- a/application/admin/view/default/site/verify.html +++ b/application/admin/view/default/site/verify.html @@ -11,11 +11,21 @@
- +
+ + + + +
- +
+ + + + +
diff --git a/application/api/controller/Devtest.php b/application/api/controller/Devtest.php index ca8a83f2f..347089fc2 100644 --- a/application/api/controller/Devtest.php +++ b/application/api/controller/Devtest.php @@ -131,6 +131,29 @@ class Devtest extends Common echo 'count:'.count($result).', success:'.$success.', fail:'.$fail; } + /** + * 商品库存初始化 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2020-07-29 + * @desc description + */ + public function GoodsInventoryHandle() + { + $warehouse_id = 1; + $warehouse = Db::name('Warehouse')->where(['id'=>$warehouse_id])->find(); + if(empty($warehouse)) + { + $data = [ + 'name' => '默认仓库', + 'is_default' => 1, + 'add_time' => time(), + ]; + $warehouse_id = Db::name('Warehouse')->insertGetId($data); + } + } + /** * 支付日志处理 * @author Devil diff --git a/application/service/BuyService.php b/application/service/BuyService.php index 82847e9ea..850a10c39 100755 --- a/application/service/BuyService.php +++ b/application/service/BuyService.php @@ -272,6 +272,11 @@ class BuyService $v['is_error'] = 1; $v['error_msg'] = '商品已下架'; } + if(empty($v['error_msg']) && $v['inventory'] <= 0) + { + $v['is_error'] = 1; + $v['error_msg'] = '商品卖没货了'; + } $ret = GoodsService::IsGoodsSiteTypeConsistent($v['goods_id'], $v['site_type']); if(empty($v['error_msg']) && $ret['code'] != 0) {