From cbeb06426d05002dccd7e5b3aa8133f4c9fcc60e Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 3 Sep 2024 17:55:14 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=89=B9?= =?UTF-8?q?=E5=8F=91=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/order/CartController.php | 7 ++ .../controller/product/ProductController.php | 10 ++ app/api/lists/cate/CateLists.php | 4 + app/api/lists/order/CartWholesaleList.php | 109 ++++++++++++++++ .../lists/product/ProductWholesaleLists.php | 117 ++++++++++++++++++ app/api/logic/order/CartLogic.php | 7 +- app/api/logic/order/OrderLogic.php | 61 ++++----- app/common/validate/BaseValidate.php | 7 +- 8 files changed, 288 insertions(+), 34 deletions(-) create mode 100644 app/api/lists/order/CartWholesaleList.php create mode 100644 app/api/lists/product/ProductWholesaleLists.php diff --git a/app/api/controller/order/CartController.php b/app/api/controller/order/CartController.php index 5810409fa..90b370357 100644 --- a/app/api/controller/order/CartController.php +++ b/app/api/controller/order/CartController.php @@ -6,6 +6,7 @@ use app\api\logic\order\CartLogic; use app\api\validate\CartValidate; use app\api\controller\BaseApiController; use app\api\lists\order\CartList; +use app\api\lists\order\CartWholesaleList; use app\common\model\order\Cart; use app\common\model\store_product\StoreProduct; use app\common\model\store_product_unit\StoreProductUnit; @@ -16,7 +17,13 @@ class CartController extends BaseApiController { return $this->dataLists(new CartList()); } + /** + * 批发商品列表 + */ + public function wholesale_lists(){ + return $this->dataLists(new CartWholesaleList()); + } /** * @notes 添加购物车 */ diff --git a/app/api/controller/product/ProductController.php b/app/api/controller/product/ProductController.php index b7f5af617..2b4c4f771 100644 --- a/app/api/controller/product/ProductController.php +++ b/app/api/controller/product/ProductController.php @@ -3,11 +3,14 @@ namespace app\api\controller\product; use app\api\controller\BaseApiController; use app\api\lists\product\ProductLists; +use app\api\lists\product\ProductWholesaleLists; use app\api\lists\product\StoreProductLists; use app\common\model\system_store\SystemStoreStaff; class ProductController extends BaseApiController{ + public $notNeedLogin = ['lists']; + /** * 商品列表 */ @@ -16,6 +19,13 @@ class ProductController extends BaseApiController{ return $this->dataLists(new ProductLists()); } + /** + * 批发商品列表 + */ + public function wholesale_lists(){ + + return $this->dataLists(new ProductWholesaleLists()); + } /** * 商品列表 */ diff --git a/app/api/lists/cate/CateLists.php b/app/api/lists/cate/CateLists.php index 21c52e4be..87644e174 100644 --- a/app/api/lists/cate/CateLists.php +++ b/app/api/lists/cate/CateLists.php @@ -45,9 +45,13 @@ class CateLists extends BaseAdminDataLists implements ListsSearchInterface public function lists(): array { $level = Request()->get('level', 1); + $source = Request()->get('source'); $pid = $this->request->get('pid',0); // $this->searchWhere[] = ['stock', '>', 0]; $this->searchWhere[] = ['is_show', '=', 1]; + if($source && $source==4){ + $this->searchWhere[] = ['product_type', '=', 5]; + } if($pid && $level ==2){ $this->searchWhere[] = ['top_cate_id','=',$pid]; $cate_arr = StoreProduct::where($this->searchWhere)->distinct() diff --git a/app/api/lists/order/CartWholesaleList.php b/app/api/lists/order/CartWholesaleList.php new file mode 100644 index 000000000..766785d8d --- /dev/null +++ b/app/api/lists/order/CartWholesaleList.php @@ -0,0 +1,109 @@ +['store_id','source']]; + } + + + /** + * @notes 购物车列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @date 2024/04/27 11:26 + */ + public function lists($where = []): array + { + $userId = $this->request->userId; + if (!$userId) return []; + $where = [ + 'uid' => $userId, + 'is_pay' => 0 + ]; + $list = Cart::where($this->searchWhere)->where($where) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + $field = 'id,id product_id,image,price,cost,store_name,unit,delete_time,vip_price,top_cate_id,batch'; + foreach ($list as $key => &$item) { + $find = StoreProduct::where(['id' => $item['product_id']]) + ->field($field) + ->find(); + if ($find) { + $item['goods_total_price'] = bcmul($item['cart_num'], $find['price'], 2); + $this->total_price = bcadd($this->total_price, $item['goods_total_price'], 2); + $item['batch'] = $find['batch']; + $item['imgs'] = $find['image']; + $item['price'] = $find['price']; + $item['cost'] = $find['cost']; + $item['goods_name'] = $find['store_name']; + $item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name'); + } + } + return $list; + } + + + /** + * @notes 购物车数量 + * @return int + * @date 2024/04/27 11:26 + */ + public function count(): int + { + $userId = $this->request->userId; + if (!$userId) return 0; + $where = [ + 'uid' => $userId, + 'is_pay' => 0 + ]; + return Cart::where($this->searchWhere)->where($where)->count(); + } + + public function extend() + { + $data = [ + 'off_activity' => $this->off_activity, + 'total_price' => $this->total_price, + 'msg' => '', + 'pay_price' => $this->total_price + ]; + return $data; + } +} diff --git a/app/api/lists/product/ProductWholesaleLists.php b/app/api/lists/product/ProductWholesaleLists.php new file mode 100644 index 000000000..75f3b58c4 --- /dev/null +++ b/app/api/lists/product/ProductWholesaleLists.php @@ -0,0 +1,117 @@ + [ 'cate_id', 'top_cate_id', 'two_cate_id'], + '%pipe_like%' => ['store_name' => 'store_name|bar_code'], + ]; + } + /** + * @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 + { + + $order = $this->request->get('order', ''); + $field = $this->request->get('field', ''); + if (empty($order) || empty($field)) { + $order = $this->sortOrder; + } else { + $order = [$field => $order]; + } + $fields = 'id,id product_id,top_cate_id,cate_id,store_name,cost,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock'; + + $this->searchWhere[] = ['is_show', '=', 1]; + $this->searchWhere[] = ['product_type', '=', 5]; + // $this->searchWhere[] = ['stock', '>', 0]; + return StoreProduct::where($this->searchWhere) + ->field($fields) + ->with(['className', 'unitName']) + ->limit($this->limitOffset, $this->limitLength) + ->order($order) + ->select() + ->toArray(); + } + + + /** + * @notes 获取商品列表数量 + * @return int + * @author likeadmin + * @date 2024/04/23 11:28 + */ + public function count(): int + { + return StoreProduct::where($this->searchWhere) + ->count(); + } + public function extend() + { + $price = 'price'; + $op_price = 'price'; + $data = [ + 'off_activity' => $this->off_activity, + 'price' => $price, + 'op_price' => $op_price, + ]; + return $data; + } +} diff --git a/app/api/logic/order/CartLogic.php b/app/api/logic/order/CartLogic.php index 2ad0c6107..67ad68b47 100644 --- a/app/api/logic/order/CartLogic.php +++ b/app/api/logic/order/CartLogic.php @@ -28,9 +28,10 @@ class CartLogic extends BaseLogic */ public static function add(array $params) { - if ($params['store_id'] <= 0) { + if ($params['store_id'] < 0) { throw new BusinessException('门店ID不能为空'); } + $source=$params['source'] ?? 0; Db::startTrans(); try { //check @@ -38,7 +39,8 @@ class CartLogic extends BaseLogic 'uid' => $params['uid'], 'store_id' => $params['store_id'], 'product_id' => $params['product_id'], - 'is_pay' => 0 + 'is_pay' => 0, + 'source' => $source, ])->field('id')->find(); if ($check) { Cart::where('id', $check['id'])->inc('cart_num', $params['cart_num']) @@ -53,6 +55,7 @@ class CartLogic extends BaseLogic 'staff_id' => $params['staff_id'] ?? 0, 'cart_num' => $params['cart_num'], 'is_new' => $params['is_new'] ?? 0, + 'source' =>$source, ]); } StoreProductLog::create([ diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 5993d6eb1..3779f81c7 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -66,12 +66,15 @@ class OrderLogic extends BaseLogic */ static public function cartIdByOrderInfo($cartId, $addressId, $user = null, $params = [], $createOrder = 0) { - if(empty($params['store_id']) || $params['store_id'] <= 0){ + if (empty($params['store_id']) || $params['store_id'] <= 0) { throw new BusinessException('请选择门店'); } - + $source=0; + if (isset($params['source']) && $params['source'] >0) { + $source=$params['source']; + } $where = ['is_pay' => 0]; - $cart_select = Cart::whereIn('id', $cartId)->where($where)->field('id,product_id,cart_num')->select()->toArray(); + $cart_select = Cart::whereIn('id', $cartId)->where($where)->field('id,product_id,cart_num,source')->select()->toArray(); if (empty($cart_select)) { throw new BusinessException('购物车为空'); } @@ -89,10 +92,10 @@ class OrderLogic extends BaseLogic $off_activity = Config::where('name', 'off_activity')->value('value'); $field = 'id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose'; foreach ($cart_select as $k => $v) { - if (isset($params['source']) && $params['source'] == 2) { + if ($source == 2) { $field = 'product_id,product_id id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose'; - $find = StoreBranchProduct::where(['product_id' => $v['product_id'],'store_id'=>$params['store_id']])->field($field)->find(); - }else{ + $find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->find(); + } else { $find = StoreProduct::where(['id' => $v['product_id']])->field($field)->find(); } if (!$find) { @@ -116,21 +119,26 @@ class OrderLogic extends BaseLogic } unset($cart_select[$k]['id']); $cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价 - if ($off_activity == 1 || ($user != null && in_array($user['user_ship'], [4, 6, 7]))) { - $price = $find['cost']; - } else { - $price = $find['price']; - //单门店活动判断 - if ($params['store_id'] == getenv('ACTIVITY_STORE_ID')) { - $storeBranchPrice = StoreBranchProduct::where('store_id', getenv('ACTIVITY_STORE_ID'))->where('product_id', $v['product_id'])->value('price'); - if ($storeBranchPrice) { - $price = $storeBranchPrice; + if ($v['source'] != 4) { + if ($off_activity == 1 || ($user != null && in_array($user['user_ship'], [4, 6, 7]))) { + $price = $find['cost']; + } else { + $price = $find['price']; + //单门店活动判断 + if ($params['store_id'] == getenv('ACTIVITY_STORE_ID')) { + $storeBranchPrice = StoreBranchProduct::where('store_id', getenv('ACTIVITY_STORE_ID'))->where('product_id', $v['product_id'])->value('price'); + if ($storeBranchPrice) { + $price = $storeBranchPrice; + } } } + if ($off_activity == 0 && $find['top_cate_id'] == 15189 && $user && $user['user_ship'] == 5) { + $price = $find['cost']; + } + } else { + $price = $find['price']; } - if ($off_activity == 0 && $find['top_cate_id'] == 15189 && $user && $user['user_ship'] == 5) { - $price = $find['cost']; - } + $cart_select[$k]['price'] = $price; $cart_select[$k]['cost'] = $find['cost']; $cart_select[$k]['vip'] = 0; @@ -173,7 +181,7 @@ class OrderLogic extends BaseLogic $cart_select[$k]['imgs'] = $find['image']; $cart_select[$k]['store_id'] = $params['store_id'] ?? 0; $cart_select[$k]['unit_name'] = StoreProductUnit::where(['id' => $find['unit']])->value('name'); - $cart_select[$k]['total_price'] =$cart_select[$k]['pay_price']; + $cart_select[$k]['total_price'] = $cart_select[$k]['pay_price']; self::$total_price = bcadd(self::$total_price, $cart_select[$k]['total_price'], 2); self::$pay_price = bcadd(self::$pay_price, $cart_select[$k]['pay_price'], 2); self::$cost = bcadd(self::$cost, $cart_select[$k]['purchase'], 2); @@ -195,7 +203,7 @@ class OrderLogic extends BaseLogic $pay_price = self::$pay_price; // bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额 //判断生鲜是否大于200 - if ($createOrder == 1 && self::$fresh_price > 0) { + if ($createOrder == 1 && self::$fresh_price > 0 &&$source!=2) { if (self::$pay_price < 200) { throw new BusinessException('订单包含生鲜产品,订单金额必须大于200元,才能下单'); } @@ -223,7 +231,7 @@ class OrderLogic extends BaseLogic 'activities' => $off_activity, 'deduction_price' => self::$deduction_price, //抵扣金额 'frozen_money' => 0, //self::$frozen_money, //返还金额(活动关闭得时候有) - 'source' => 0, + 'source' => $source, 'is_storage' => $params['is_storage'] ?? 0, 'address_id' => 0, ]; @@ -231,9 +239,6 @@ class OrderLogic extends BaseLogic if ($params['store_id']) { $order['default_delivery'] = SystemStore::where('id', $params['store_id'])->value('is_send'); } - if (isset($params['source']) && $params['source'] > 0) { - $order['source'] = $params['source']; - } if (isset($params['store_id']) && $params['store_id'] > 0) { $store_id = $params['store_id']; @@ -259,8 +264,6 @@ class OrderLogic extends BaseLogic } } catch (\Throwable $e) { throw new BusinessException($e->getMessage()); - - } return ['order' => $order, 'cart_list' => $cart_select, 'shopInfo' => $store['near_store'], 'alert' => $alert]; } @@ -335,7 +338,7 @@ class OrderLogic extends BaseLogic $order = StoreOrder::create($_order); $goods_list = $orderInfo['cart_list']; - + foreach ($goods_list as $k => $v) { $goods_list[$k]['oid'] = $order->id; $goods_list[$k]['uid'] = $uid; @@ -443,7 +446,7 @@ class OrderLogic extends BaseLogic // 回滚事务 Db::rollback(); Log::error('支付失败' . $e->getMessage() . '。like:' . $e->getLine()); - throw new BusinessException('支付失败'. $e->getMessage()); + throw new BusinessException('支付失败' . $e->getMessage()); } } @@ -499,7 +502,7 @@ class OrderLogic extends BaseLogic $find['goods_list'] = StoreOrderCartInfo::where('oid', $find['id']) ->field('product_id,cart_num nums,store_id')->select()->each(function ($item) use ($find) { $find = StoreProduct::where('id', $item['product_id'])->withTrashed()->find(); - + $item['store_name'] = $find['store_name']; $item['nums'] = floatval($item['nums']); $item['image'] = $find['image']; diff --git a/app/common/validate/BaseValidate.php b/app/common/validate/BaseValidate.php index 92bf44e7a..e5c1fd36b 100644 --- a/app/common/validate/BaseValidate.php +++ b/app/common/validate/BaseValidate.php @@ -17,6 +17,7 @@ declare(strict_types=1); namespace app\common\validate; use app\common\service\JsonService; +use support\exception\BusinessException; use taoser\Validate; class BaseValidate extends Validate @@ -31,7 +32,7 @@ class BaseValidate extends Validate public function post() { if (!(request()->method() == 'POST')) { - JsonService::throw('请求方式错误,请使用post请求方式'); + throw new BusinessException('请求方式错误,请使用post请求方式'); } $this->method = 'POST'; return $this; @@ -45,7 +46,7 @@ class BaseValidate extends Validate public function get() { if (!(request()->method() == 'GET')) { - JsonService::throw('请求方式错误,请使用get请求方式'); + throw new BusinessException('请求方式错误,请使用get请求方式'); } return $this; } @@ -79,7 +80,7 @@ class BaseValidate extends Validate if (!$result) { $exception = is_array($this->error) ? implode(';', $this->error) : $this->error; - JsonService::throw($exception); + throw new BusinessException($exception); } // 3.成功返回数据 return $params; From c2a617aca88d4cd15cd82a915abec279013d0af9 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 3 Sep 2024 22:53:26 +0800 Subject: [PATCH 2/5] =?UTF-8?q?feat(CapitalFlowLogic,=20CommissionProductL?= =?UTF-8?q?ogic):=20=E6=96=B0=E5=A2=9E/=E4=BF=AE=E6=94=B9=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BB=A5=E5=A4=84=E7=90=86=E8=AE=A2=E5=8D=95=E6=94=AF?= =?UTF-8?q?=E4=BB=98/=E9=80=80=E6=AC=BE=E5=8F=8A=E5=95=86=E5=93=81?= =?UTF-8?q?=E4=BD=A3=E9=87=91=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/CapitalFlowLogic.php | 3 +++ app/common/logic/CommissionProductLogic.php | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/common/logic/CapitalFlowLogic.php b/app/common/logic/CapitalFlowLogic.php index 3898b55c8..6590a2759 100644 --- a/app/common/logic/CapitalFlowLogic.php +++ b/app/common/logic/CapitalFlowLogic.php @@ -166,6 +166,7 @@ class CapitalFlowLogic extends BaseLogic case 'store_order_refund': return "店铺订单退款{$amount}元"; case 'store_margin_refund': + case 'store_paid_deposit_refund': return "店铺退还保证金{$amount}元"; case 'user_order_promotion': return "订单推广佣金{$amount}元"; @@ -185,6 +186,8 @@ class CapitalFlowLogic extends BaseLogic return "订单退回到余额{$amount}元"; case 'purchase_refund': return "订单退回到采购款{$amount}元"; + case 'store_paid_deposit_add': + return "门店增加保证金{$amount}元"; default: return "订单支付{$amount}元"; } diff --git a/app/common/logic/CommissionProductLogic.php b/app/common/logic/CommissionProductLogic.php index 74173ac8d..f6e1688f8 100644 --- a/app/common/logic/CommissionProductLogic.php +++ b/app/common/logic/CommissionProductLogic.php @@ -250,9 +250,9 @@ class CommissionProductLogic extends BaseLogic $total_price = bcmul($product['price'], $find['cart_num']); $purchase_price = bcmul($product['purchase'], $find['cart_num']); $price=$product['price']; - $brigade_number = bcmul($total_price, 0.02, 2); - $village_number = bcmul($brigade_number, 0.1, 2); - $platform_number = bcmul($total_price, 0.02, 2); + $brigade_number = bcmul($total_price, 0.02, 2);//队长 + $village_number = bcmul($brigade_number, 0.1, 2);//村长 + $platform_number = bcmul($total_price, 0.02, 2);//平台 $number1 = bcadd($brigade_number, $village_number, 2); $number2 = bcadd($number1, $platform_number, 2); From 1fbc0b6ceec1ec77310d2ea705855635382694be Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 5 Sep 2024 10:31:29 +0800 Subject: [PATCH 3/5] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E7=8A=B6=E6=80=81=E4=BF=9D=E5=AD=98=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index eb296badd..bb1ddb59e 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -76,6 +76,7 @@ class PayNotifyLogic extends BaseLogic } // $order->money = $order['pay_price']; $order->paid = 1; + $order->status = 1; $order->pay_time = time(); if (!$order->save()) { throw new BusinessException('订单保存出错'); @@ -185,6 +186,7 @@ class PayNotifyLogic extends BaseLogic } $order->money = $order['pay_price']; $order->paid = 1; + $order->status = 1; $order->pay_time = time(); if (!$order->save()) { throw new \Exception('订单保存出错'); From c57c73b40eaa330e503708ea2dde51b9cd0d5e28 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 5 Sep 2024 11:37:01 +0800 Subject: [PATCH 4/5] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=95=86?= =?UTF-8?q?=E5=93=81ID=E5=88=97=E5=88=B0Excel=E5=AF=BC=E5=87=BA=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/lists/store_product/StoreProductLists.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index 11b086cf3..382d7d46b 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -122,6 +122,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa public function setExcelFields(): array { $data = [ + 'id' => '商品id', 'store_name' => '商品名称', 'cate_name'=>'分类', 'unit_name'=>'单位', From 9b6bf999c0be5f6106b789dd86130b0308156be7 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 5 Sep 2024 16:10:59 +0800 Subject: [PATCH 5/5] =?UTF-8?q?feat(warehouse=5Forder):=20=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E4=BB=93=E5=BA=93=E8=AE=A2=E5=8D=95=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=9F=A5=E8=AF=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../warehouse_order/WarehouseOrderController.php | 6 +++++- .../StoreOrderCartInfoTwoLists.php | 11 ++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/admin/controller/warehouse_order/WarehouseOrderController.php b/app/admin/controller/warehouse_order/WarehouseOrderController.php index a4dabf8e8..787347de1 100644 --- a/app/admin/controller/warehouse_order/WarehouseOrderController.php +++ b/app/admin/controller/warehouse_order/WarehouseOrderController.php @@ -227,7 +227,11 @@ class WarehouseOrderController extends BaseAdminController $order['total_num'] = 0; $total_price=0; foreach ($data as $key => &$value) { - $find = StoreProduct::where('id', $value->product_id)->find(); + if(in_array($order['store_id'],[17,18])){ + $find = StoreBranchProduct::where('product_id', $value->product_id)->where('store_id',$order['store_id'])->find(); + }else{ + $find = StoreProduct::where('id', $value->product_id)->find(); + } $value->store_name = $find['store_name'] ?? ''; $value->store_info = $find['store_info'] ?? ''; if($type==2){ diff --git a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php index 313b20ff0..6d5716796 100644 --- a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php +++ b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php @@ -63,20 +63,25 @@ class StoreOrderCartInfoTwoLists extends BaseAdminDataLists implements ListsSear if ($this->request->get('start_time') == '') { $this->searchWhere[] = ['create_time', 'between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]]; } + $is_group=$this->request->get('is_group'); $this->searchWhere[] = ['is_pay', '=', 1]; $this->searchWhere[] = ['status', '>=', 0]; $query = StoreOrderCartInfo::where($this->searchWhere); - if ($this->request->get('is_group') == 1) { + if ($is_group == 1) { $query->field('store_id,product_id,price,SUM(total_price) as total_price,SUM(cart_num) as cart_num')->group(['store_id', 'product_id']); } else { $query->field('store_id,product_id,price,total_price,cart_num,create_time'); } return $query->limit($this->limitOffset, $this->limitLength) - ->select()->each(function ($item) { + ->select()->each(function ($item) use($is_group){ $find = StoreProduct::where('id', $item['product_id'])->field('image,unit,cate_id,store_name,store_info')->find(); if ($find) { $item['image'] = $find['image']; //商品图片 - $item['store_name'] = $find['store_name']; //商品名称 + if($is_group==1){ + $item['store_name'] = $find['store_name'].'-'.$item['create_time']; //商品名称 + }else{ + $item['store_name'] = $find['store_name']; //商品名称 + } $item['store_info'] = $find['store_info']; //商品规格 $item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name') ?? ''; $item['cate_name'] = StoreCategory::where('id', $find['cate_id'])->value('name') ?? '';