From c66598010c6aa5e21a5a4aaed4eeae7cc7b57741 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 1 Jun 2024 11:42:28 +0800 Subject: [PATCH] =?UTF-8?q?(=E5=88=9B=E5=BB=BA=E9=97=A8=E5=BA=97=E5=95=86?= =?UTF-8?q?=E5=93=81=E9=80=BB=E8=BE=91=E7=B1=BB=E6=96=B9=E6=B3=95)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store_category/StoreCategoryLists.php | 3 +- .../logic/store_product/StoreProductLogic.php | 50 ++++++++++++++++--- app/api/controller/IndexController.php | 7 +-- .../StoreBranchProduct.php | 2 +- .../StoreBranchProductAttrValue.php | 2 +- 5 files changed, 49 insertions(+), 15 deletions(-) diff --git a/app/admin/lists/store_category/StoreCategoryLists.php b/app/admin/lists/store_category/StoreCategoryLists.php index 614a72197..00ba1ef1a 100644 --- a/app/admin/lists/store_category/StoreCategoryLists.php +++ b/app/admin/lists/store_category/StoreCategoryLists.php @@ -26,7 +26,8 @@ class StoreCategoryLists extends BaseAdminDataLists implements ListsSearchInterf public function setSearch(): array { return [ - '=' => ['name','pid'], + '=' => ['pid'], + '%like%' => ['name'], ]; } diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index 42ac6365c..b11f3d0ac 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -5,6 +5,8 @@ namespace app\admin\logic\store_product; use app\common\model\store_product\StoreProduct; use app\common\logic\BaseLogic; +use app\common\model\store_branch_product\StoreBranchProduct; +use app\common\model\store_branch_product_attr_value\StoreBranchProductAttrValue; use app\common\model\store_category\StoreCategory; use app\common\model\store_product_attr_value\StoreProductAttrValue; use think\facade\Db; @@ -85,7 +87,15 @@ class StoreProductLogic extends BaseLogic StoreCategory::where('id', $StoreProduct['cate_id'])->dec('three')->update(); } StoreProduct::where('id', $params['id'])->update([ - 'store_name' => $params['store_name'] + 'store_name' => $params['store_name'], + 'image' => $params['image'], + 'bar_code' => $params['bar_code'] ?? '', + 'cate_id' => $params['cate_id'], + 'unit' => $params['unit'], + 'stock' => $params['stock'], + 'cost' => $params['cost'], + 'purchase' => $params['purchase'], + 'rose' => $params['rose'], ]); Db::commit(); @@ -120,7 +130,7 @@ class StoreProductLogic extends BaseLogic */ public static function detail($params): array { - return StoreProduct::findOrEmpty($params['id'])->toArray(); + return StoreProduct::where('id',$params['id'])->findOrEmpty()->toArray(); } /** @@ -146,10 +156,38 @@ class StoreProductLogic extends BaseLogic } } - public static function copy($id){ - $find= StoreProduct::findOrEmpty($id); - if($find){ - + /** + * 复制商品到门店 + */ + public static function copy($id,$store_id){ + $find= StoreProduct::where('id',$id)->findOrEmpty(); + $store_find= StoreProduct::where(['source_id',$id,'store_id'=>$store_id])->findOrEmpty(); + if($find && !$store_find){ + $attr_value=StoreProductAttrValue::where('product_id',$id)->findOrEmpty(); + $res=StoreProduct::create($find); + $product=[ + 'product_id'=>$res['id'], + 'image'=>$res['image'], + 'store_name'=>$res['store_name'], + 'store_info'=>$res['store_info'], + 'keyword'=>$res['keyword'], + 'bar_code'=>$res['bar_code'], + 'cate_id'=>$res['cate_id'], + 'store_id'=>$store_id, + 'sales'=>$res['sales'], + 'stock'=>$res['stock'], + ]; + StoreBranchProduct::create($product); + $arr=[ + 'product_id'=>$id, + 'store_id'=>$store_id, + 'unique'=>$attr_value['unique'], + 'sales'=>0, + 'stock'=>0, + 'type'=>0, + 'bar_code'=>$attr_value['bar_code'] + ]; + StoreBranchProductAttrValue::create($arr); } } diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index 7a6c8432f..8b50d624f 100644 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -32,6 +32,7 @@ class IndexController extends BaseApiController public function index() { + d(uniqid(1 . '_', true)); return json(['msg' =>create_password(123456, '11d3')]); } @@ -56,10 +57,4 @@ class IndexController extends BaseApiController return $this->success('ok',$find); } - /** - * @notes 获取快递列表 - */ - public function express_list(){ - return $this->dataLists(new ExpressLists()); - } } diff --git a/app/common/model/store_branch_product/StoreBranchProduct.php b/app/common/model/store_branch_product/StoreBranchProduct.php index c4981c55e..4f988320e 100644 --- a/app/common/model/store_branch_product/StoreBranchProduct.php +++ b/app/common/model/store_branch_product/StoreBranchProduct.php @@ -12,7 +12,7 @@ use think\model\concern\SoftDelete; * Class StoreBranchProduct * @package app\common\model\store_branch_product */ -class StoreProduct extends BaseModel +class StoreBranchProduct extends BaseModel { use SoftDelete; protected $name = 'store_branch_product'; diff --git a/app/common/model/store_branch_product_attr_value/StoreBranchProductAttrValue.php b/app/common/model/store_branch_product_attr_value/StoreBranchProductAttrValue.php index 7ed216d6f..a9bf63c95 100644 --- a/app/common/model/store_branch_product_attr_value/StoreBranchProductAttrValue.php +++ b/app/common/model/store_branch_product_attr_value/StoreBranchProductAttrValue.php @@ -12,7 +12,7 @@ use think\model\concern\SoftDelete; * Class StoreBranchProduct * @package app\common\model\store_branch_product_attr_value */ -class StoreProduct extends BaseModel +class StoreBranchProductAttrValue extends BaseModel { use SoftDelete; protected $name = 'store_branch_product_attr_value';