From 42a9130a7aa775c0bc2726d37572f4b3ceb0eeea Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 12 Jul 2024 11:09:16 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=85=85=E5=80=BCAPI=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E9=80=BB=E8=BE=91=E5=92=8C=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=AD=BE=E5=88=B0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/UserRechargeController.php | 94 ++++++++----------- app/api/logic/order/OrderLogic.php | 38 +++++++- app/common/logic/UserSignLogic.php | 27 +++++- 3 files changed, 96 insertions(+), 63 deletions(-) diff --git a/app/api/controller/user/UserRechargeController.php b/app/api/controller/user/UserRechargeController.php index 3e3c9e46c..e7610d94e 100644 --- a/app/api/controller/user/UserRechargeController.php +++ b/app/api/controller/user/UserRechargeController.php @@ -1,60 +1,46 @@ dataLists(new UserRechargeLists()); - } +class UserRechargeController extends BaseApiController +{ + /** + * @notes 获取用户充值 + * @return \support\Response + * @author likeadmin + * @date 2024/05/13 16:56 + */ + public function lists() + { + return $this->dataLists(new UserRechargeLists()); + } - public function recharge_list() - { - $buy_bar = "元采购包"; - $send_bar = "品牌礼品券"; - $arr = [ - [ - 'money'=>1000,//采购包 -// 'money'=>1,//采购包 - 'send'=>249,//礼品券 - 'money_string'=>$buy_bar, - 'send_string'=>$send_bar, - ], - [ - 'money'=>2000,//采购包 - 'send'=>560,//礼品券 - 'money_string'=>$buy_bar, - 'send_string'=>$send_bar, - ], - [ - 'money'=>5000,//采购包 - 'send'=>1550,//礼品券 - 'money_string'=>$buy_bar, - 'send_string'=>$send_bar, - ], - [ - 'money'=>10000,//采购包 - 'send'=>3500,//礼品券 - 'money_string'=>$buy_bar, - 'send_string'=>$send_bar, - ] - ]; - return $this->success('ok',$arr); - - - } - - } + public function recharge_list() + { + $buy_bar = "元采购包"; + $send_bar = "品牌礼品券"; + $list = DictData::where('type_value', 'recharge')->select() + ->each(function($item)use($buy_bar,$send_bar){ + $item['money'] = $item['value']; + $item['money_string'] = $buy_bar; + $item['send_string'] = $send_bar; + if($item['name']=='level_one'){ + $item['send'] = 249; + }elseif($item['name']=='level_two'){ + $item['send'] = 560; + }elseif($item['name']=='level_three'){ + $item['send'] = 1550; + }elseif($item['name']=='level_four'){ + $item['send'] = 3500; + } + }); + return $this->success('ok', $list?->toArray()); + } +} diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index e57deb270..2c5c0664b 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -16,6 +16,7 @@ use app\common\model\dict\DictData; use app\common\model\dict\DictType; use app\common\model\order\Cart; use app\common\model\store_branch_product\StoreBranchProduct; +use app\common\model\store_category\StoreCategory; use app\common\model\store_finance_flow\StoreFinanceFlow; use app\common\model\store_order\StoreOrder; use app\common\model\store_order_cart_info\StoreOrderCartInfo; @@ -62,7 +63,7 @@ class OrderLogic extends BaseLogic * @param $params * @return array|bool */ - static public function cartIdByOrderInfo($cartId, $addressId, $user = null, $params = []) + static public function cartIdByOrderInfo($cartId, $addressId, $user = null, $params = [], $createOrder = 0) { $where = ['is_pay' => 0]; $cart_select = Cart::whereIn('id', $cartId)->where($where)->field('id,product_id,cart_num')->select()->toArray(); @@ -80,16 +81,29 @@ class OrderLogic extends BaseLogic self::$deduction_price = 0; self::$frozen_money = 0; //返还金额 $deduction_price = 0; //抵扣金额 + $fresh_price = 0; //生鲜金额 /** 计算价格 */ $off_activity = Config::where('name', 'off_activity')->value('value'); - $field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id'; + $field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id,top_cate_id'; foreach ($cart_select as $k => $v) { $find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->find(); if (!$find) { // unset($cart_select[$k]); // continue; - $field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase, id product_id'; + $field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase, id product_id,cate_id'; $find = StoreProduct::where(['id' => $v['product_id']])->field($field)->find(); + if ($find) { + $cate_id = StoreCategory::where('id', $find['cate_id'])->value('pid'); + if ($cate_id > 0) { + $cate_id = StoreCategory::where('id', $cate_id)->value('pid'); + if ($cate_id > 0) { + $cate_id = StoreCategory::where('id', $cate_id)->value('pid'); + $find['top_cate_id'] = $cate_id; + } else { + $find['top_cate_id'] = $cate_id; + } + } + } $cart_select[$k]['status'] = 1; //缺货标识 } unset($cart_select[$k]['id']); @@ -114,6 +128,10 @@ class OrderLogic extends BaseLogic $deduction_price = bcsub($cart_select[$k]['total_price'], $cart_select[$k]['pay_price'], 2); $cart_select[$k]['deduction_price'] = $deduction_price; //抵扣金额 } + //计算生鲜 + if ($createOrder == 1 && $find['top_cate_id'] == 15201) { + $fresh_price=bcadd($fresh_price,$cart_select[$k]['pay_price']); + } $cart_select[$k]['product_id'] = $find['product_id']; $cart_select[$k]['old_cart_id'] = $v['id']; $cart_select[$k]['cart_num'] = $v['cart_num']; @@ -153,6 +171,14 @@ class OrderLogic extends BaseLogic // if ($user && $user['user_ship'] == 1 && $pay_type != 17) { // $pay_price = self::$pay_price; // } else { + + //判断生鲜是否大于200 + if($createOrder==1 && $fresh_price>0){ + if($fresh_price<200){ + self::setError('订单里的生鲜必须大于金额200元'); + return false; + } + } $pay_price = bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额 // } //成本价 收益 @@ -236,7 +262,11 @@ class OrderLogic extends BaseLogic $verify_code = createCode($code); $params['order_id'] = $order_id; $params['verify_code'] = $verify_code; - $orderInfo = self::cartIdByOrderInfo($cartId, $addressId, $user, $params); + $orderInfo = self::cartIdByOrderInfo($cartId, $addressId, $user, $params, 1); + if($orderInfo==false){ + self::setError(self::getError()); + return false; + } if (!$orderInfo) { return false; } diff --git a/app/common/logic/UserSignLogic.php b/app/common/logic/UserSignLogic.php index 85955a9ef..b4f66ba65 100644 --- a/app/common/logic/UserSignLogic.php +++ b/app/common/logic/UserSignLogic.php @@ -5,6 +5,7 @@ namespace app\common\logic; use app\common\enum\YesNoEnum; use app\common\logic\BaseLogic; +use app\common\model\dict\DictData; use app\common\model\user\User; use app\common\model\user_recharge\UserRecharge; use app\common\model\user_sign\UserSign; @@ -23,22 +24,38 @@ class UserSignLogic extends BaseLogic */ public static function dealRechargeFrozen($user, $order, $user_ship = 0) { + $total_vip = 0; + $level_one = 1000; + $level_two = 2000; + $level_three = 5000; + $level_four = 10000; + $list = DictData::where('type_value', 'recharge')->select(); + foreach( $list as $k=>$v){ + if($v['name']=='level_one'){ + $level_one = $v['value']; + }elseif($v['name']=='level_two'){ + $level_two = $v['value']; + }elseif($v['name']=='level_three' ){ + $level_three = $v['value']; + }elseif($v['name']=='level_four'){ + $level_four = $v['value']; + } + } $price=(int)$order['price']; switch ($price) { - case 1000: + case $level_one: $total_vip = 249; break; - case 2000: + case $level_two: $total_vip = 560; break; - case 5000: + case $level_three: $total_vip = 1550; break; - case 10000: + case $level_four: $total_vip = 3500; break; default: - $total_vip = 0; break; } if($total_vip==0){ From f3e83cda79a5590ae7138a8f1ad0617b674f3d10 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 12 Jul 2024 13:52:12 +0800 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E9=80=BB=E8=BE=91=EF=BC=8C=E5=A2=9E=E5=8A=A0=E7=94=9F?= =?UTF-8?q?=E9=B2=9C=E4=BA=A7=E5=93=81=E8=AE=A2=E5=8D=95=E9=87=91=E9=A2=9D?= =?UTF-8?q?=E5=A4=A7=E4=BA=8E200=E5=85=83=E7=9A=84=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 2c5c0664b..f5e24b890 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -130,7 +130,7 @@ class OrderLogic extends BaseLogic } //计算生鲜 if ($createOrder == 1 && $find['top_cate_id'] == 15201) { - $fresh_price=bcadd($fresh_price,$cart_select[$k]['pay_price']); + $fresh_price = bcadd($fresh_price, $cart_select[$k]['pay_price']); } $cart_select[$k]['product_id'] = $find['product_id']; $cart_select[$k]['old_cart_id'] = $v['id']; @@ -172,14 +172,15 @@ class OrderLogic extends BaseLogic // $pay_price = self::$pay_price; // } else { + + $pay_price = bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额 //判断生鲜是否大于200 - if($createOrder==1 && $fresh_price>0){ - if($fresh_price<200){ - self::setError('订单里的生鲜必须大于金额200元'); + if ($createOrder == 1 && $fresh_price > 0) { + if ($pay_price < 200) { + self::setError('订单包含生鲜产品,订单金额必须大于200元,才能下单'); return false; } } - $pay_price = bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额 // } //成本价 收益 $order = [ @@ -263,7 +264,7 @@ class OrderLogic extends BaseLogic $params['order_id'] = $order_id; $params['verify_code'] = $verify_code; $orderInfo = self::cartIdByOrderInfo($cartId, $addressId, $user, $params, 1); - if($orderInfo==false){ + if ($orderInfo == false) { self::setError(self::getError()); return false; } From 2601a18a6b79cb9727e0e960cd4834d0ccdf8eca Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 13 Jul 2024 09:25:33 +0800 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20=E5=95=86=E5=93=81=E5=88=97?= =?UTF-8?q?=E8=A1=A8API=E6=B7=BB=E5=8A=A0=E5=BA=97=E9=93=BA=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/product/ProductController.php | 16 ++- app/api/lists/product/ProductLists.php | 9 +- app/api/lists/product/StoreProductLists.php | 111 ++++++++++++++++++ 3 files changed, 133 insertions(+), 3 deletions(-) create mode 100644 app/api/lists/product/StoreProductLists.php diff --git a/app/api/controller/product/ProductController.php b/app/api/controller/product/ProductController.php index c10aeaceb..2d2e94f13 100644 --- a/app/api/controller/product/ProductController.php +++ b/app/api/controller/product/ProductController.php @@ -3,7 +3,8 @@ namespace app\api\controller\product; use app\api\controller\BaseApiController; use app\api\lists\product\ProductLists; - +use app\api\lists\product\StoreProductLists; +use app\common\model\system_store\SystemStoreStaff; class ProductController extends BaseApiController{ public $notNeedLogin = ['lists']; @@ -22,5 +23,18 @@ class ProductController extends BaseApiController{ $this->request->__set('store_id',$this->request->userInfo['store_id']??0); return $this->dataLists(new ProductLists()); } + /** + * 商品列表 + */ + public function store_lists(){ + + $store_id=SystemStoreStaff::where('uid',$this->userId)->where('is_admin',1)->value('store_id'); + if($store_id>0){ + $this->request->__set('store_id',$store_id); + return $this->dataLists(new StoreProductLists()); + }else{ + return $this->dataLists(); + } + } } diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php index 13015627a..f1a8e3126 100644 --- a/app/api/lists/product/ProductLists.php +++ b/app/api/lists/product/ProductLists.php @@ -81,6 +81,11 @@ class ProductLists extends BaseApiDataLists implements ListsSearchInterface, Lis } $fields = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock'; $off_activity = Config::where('name', 'off_activity')->value('value'); + if($off_activity==1){ + $tag='赠10%品牌礼品券'; + }else{ + $tag=''; + } $uid=0; if($this->request->get('uid',0)>0){ $uid=$this->request->get('uid',0); @@ -102,8 +107,8 @@ class ProductLists extends BaseApiDataLists implements ListsSearchInterface, Lis ->limit($this->limitOffset, $this->limitLength) ->order($order) // ->page($this->limitOffset +1,$this->limitLength) - ->select()->each(function ($item) { - $item['tag']=' 赠10%品牌礼品券 '; + ->select()->each(function ($item) use($tag){ + $item['tag']=$tag; return $item; }) ->toArray(); diff --git a/app/api/lists/product/StoreProductLists.php b/app/api/lists/product/StoreProductLists.php new file mode 100644 index 000000000..8bb568d05 --- /dev/null +++ b/app/api/lists/product/StoreProductLists.php @@ -0,0 +1,111 @@ + ['store_id', 'cate_id', 'top_cate_id', 'two_cate_id'], + '%like%' => ['store_name' => 'store_name'], + ]; + } + /** + * @notes 设置支持排序字段 + * @return string[] + * @date 2021/12/29 10:07 + * @remark 格式: ['前端传过来的字段名' => '数据库中的字段名']; + */ + public function setSortFields(): array + { + return ['sell' => 'price', 'sales' => 'sales',]; + } + + + /** + * @notes 设置默认排序 + * @return string[] + * @date 2021/12/29 10:06 + */ + public function setDefaultOrder(): array + { + return ['price' => 'asc', 'id' => 'desc']; + } + + /** + * @notes 获取商品列表列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/04/23 11:28 + */ + public function lists(): array + { + $store_id= $this->request->__get('store_id'); + if($store_id){ + $this->searchWhere[] = ['store_id', '=', $store_id]; + } + + $fields = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock'; + $type=$this->request->get('type',0); + if($type==1){ + $fields = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,cost price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock'; + }elseif($type==2){ + $fields = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,vip_price price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock'; + } + $this->searchWhere[] = ['status', '=', 1]; + + // $this->searchWhere[] = ['stock', '>', 0]; + return StoreBranchProduct::where($this->searchWhere) + ->field($fields) + ->with(['className', 'unitName']) + ->limit($this->limitOffset, $this->limitLength) + ->order('id desc') + ->select() + ->toArray(); + } + + + /** + * @notes 获取商品列表数量 + * @return int + * @author likeadmin + * @date 2024/04/23 11:28 + */ + public function count(): int + { + return StoreBranchProduct::where($this->searchWhere) + ->count(); + } +} From 75c6e3b05a4823458003a3abee08573e84ef6314 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 13 Jul 2024 11:22:12 +0800 Subject: [PATCH 4/6] =?UTF-8?q?feat(UserLogic):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=9C=B0=E5=9D=80=E6=9F=A5=E8=AF=A2=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/user/UserLogic.php | 16 +++++----------- app/api/controller/store/StoreController.php | 13 ++++++++++--- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/app/admin/logic/user/UserLogic.php b/app/admin/logic/user/UserLogic.php index 50a6ef4ac..309d4ddc1 100644 --- a/app/admin/logic/user/UserLogic.php +++ b/app/admin/logic/user/UserLogic.php @@ -84,26 +84,20 @@ class UserLogic extends BaseLogic self::setError('请设置村参数'); return false; } - $arr=User::where('user_ship',$user_ship)->column('id'); - if($arr){ - $find=UserAddress::where('uid','in',$arr)->where('village',$params['village'])->find(); - if($find){ + $arr=User::where('user_ship',$user_ship)->alias('user')->join('user_address address','user.id=address.uid and village='.$params['village'])->find(); + if ($arr) { self::setError('该区域已有村长请重新选择'); return false; - } } }elseif($user_ship==3){ if(!isset($params['brigade'])){ self::setError('请设置队参数'); return false; } - $arr=User::where('user_ship',$user_ship)->column('id'); + $arr=User::where('user_ship',$user_ship)->alias('user')->join('user_address address','user.id=address.uid and village='.$params['village'] .' and brigade='.$params['brigade'])->find(); if($arr){ - $find=UserAddress::where('uid','in',$arr)->where('village',$params['village'])->where('brigade',$params['brigade'])->find(); - if($find){ - self::setError('该区域已有队长请重新选择'); - return false; - } + self::setError('该区域已有队长请重新选择'); + return false; } } return true; diff --git a/app/api/controller/store/StoreController.php b/app/api/controller/store/StoreController.php index 81c64b52a..0c53a9303 100644 --- a/app/api/controller/store/StoreController.php +++ b/app/api/controller/store/StoreController.php @@ -66,8 +66,8 @@ class StoreController extends BaseApiController $params = (new UserValidate())->post()->goCheck('rechargeStoreMoney'); $auth_code = $this->request->post('auth_code'); //微信支付条码 $recharge_type = $this->request->post('recharge_type',''); //微信支付条码 - $code = $this->request->post('code','');//验证码 - $phone = $params['mobile']; + // $code = $this->request->post('code','');//验证码 + // $phone = $params['mobile']; // if($code && $phone){ // $remark = $phone.'_reporting'; // $codeCache = Cache::get($remark); @@ -84,12 +84,18 @@ class StoreController extends BaseApiController $find=User::where('account|mobile',$params['mobile'])->find(); if(!$find){ $params['create_uid']=$this->userId; + if(isset($params['user_ship']) && in_array($params['user_ship'],[2,3])){ + UserUserLogic::checkAddress($params); + if(UserUserLogic::hasError()){ + return $this->fail(UserUserLogic::getError()); + } + } $find=UserUserLogic::StoreAdd($params); if(UserUserLogic::hasError()){ return $this->fail(UserUserLogic::getError()); } }else{ - if(isset($params['type']) && $params['type'] != 2){ + if($find['user_ship']!=$params['user_ship'] && in_array($params['user_ship'],[2,3])){ UserUserLogic::checkAddress($params); if(UserUserLogic::hasError()){ return $this->fail(UserUserLogic::getError()); @@ -130,6 +136,7 @@ class StoreController extends BaseApiController 'recharge_type'=>'INDUSTRYMEMBERS', 'user_ship'=>$params['user_ship']??0, ]; + d(123123); $order = UserRecharge::create($data); $order['pay_price']=$order['price']; From 242f125dc4f60668e82b26c282a4148c052e48a0 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 13 Jul 2024 11:29:15 +0800 Subject: [PATCH 5/6] =?UTF-8?q?feat(OrderList):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=95=86=E5=93=81=E4=BF=A1=E6=81=AF=E6=9F=A5=E8=AF=A2=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/order/OrderList.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/api/lists/order/OrderList.php b/app/api/lists/order/OrderList.php index 77d7d0ebe..26548a45b 100644 --- a/app/api/lists/order/OrderList.php +++ b/app/api/lists/order/OrderList.php @@ -60,11 +60,14 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface if(empty($find)){ $find = StoreProduct::where('id', $v['product_id'])->withTrashed()->find(); } - $v['store_name'] = $find['store_name']; - $v['image'] = $find['image']; + $v['store_name'] = $find['store_name']??''; + $v['image'] = $find['image']??''; // $v['price'] = $find['price']; $v['price'] = $v['cart_info']['price']; - $v['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name') ?? ''; + $v['unit_name']=''; + if(isset($find['unit']) && $find['unit'] !=''){ + $v['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name') ?? ''; + } }); $item['goods_count'] = count(explode(',', $item['cart_id'])); if ($item['refund_reason_time']) { From 59d56ff9c7fb2fe0d249c01f57f19b24886a4714 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 13 Jul 2024 11:44:19 +0800 Subject: [PATCH 6/6] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BA=86?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=88=97=E8=A1=A8=E7=9A=84=E5=95=86=E5=93=81?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E8=8E=B7=E5=8F=96=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/order/OrderList.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/app/api/lists/order/OrderList.php b/app/api/lists/order/OrderList.php index 26548a45b..f30f4e1f8 100644 --- a/app/api/lists/order/OrderList.php +++ b/app/api/lists/order/OrderList.php @@ -56,17 +56,18 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface $item['goods_list'] = StoreOrderCartInfo::where('oid', $item['id']) ->field('product_id,cart_num,verify_code,is_writeoff,writeoff_time,old_cart_id,cart_info')->limit(3)->select() ->each(function ($v) use ($item) { - $find = StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $item['store_id'])->withTrashed()->find(); - if(empty($find)){ - $find = StoreProduct::where('id', $v['product_id'])->withTrashed()->find(); - } - $v['store_name'] = $find['store_name']??''; - $v['image'] = $find['image']??''; -// $v['price'] = $find['price']; - $v['price'] = $v['cart_info']['price']; + $v['store_name'] = ''; + $v['image'] = ''; + $v['price'] = ''; $v['unit_name']=''; - if(isset($find['unit']) && $find['unit'] !=''){ - $v['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name') ?? ''; + if(isset($v['cart_info'])){ + // foreach( $v['cart_info'] as $k=>$vv){ + $v['store_name'] =$v['cart_info']['name']; + $v['image'] =$v['cart_info'] ['image']; + $v['price'] = $v['cart_info']['price']; + $v['unit_name']=$v['cart_info']['unit_name']??''; + // } + } }); $item['goods_count'] = count(explode(',', $item['cart_id']));