From a15ad48e4cf3b950fe83c12ebcca7ef13ae52233 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Thu, 9 Jan 2025 16:33:28 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/lists/user/UserLists.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/store/lists/user/UserLists.php b/app/store/lists/user/UserLists.php index 43fcf955d..70aa1a4f5 100644 --- a/app/store/lists/user/UserLists.php +++ b/app/store/lists/user/UserLists.php @@ -26,7 +26,6 @@ class UserLists extends BaseAdminDataLists implements ListsSearchInterface { return [ '=' => ['id','user_ship','store_id'], - '%like%' => ['mobile'], ]; } @@ -50,9 +49,12 @@ class UserLists extends BaseAdminDataLists implements ListsSearchInterface return []; } } + $query = User::where($this->searchWhere); + if (!empty($this->params['nickname'])) { + $query->whereLike('nickname|mobile', "%{$this->params['nickname']}%"); + } $field = "id,nickname,real_name,sex,avatar,account,mobile,now_money,user_ship,create_time,purchase_funds,integral"; - $lists = User::where($this->searchWhere) - ->limit($this->limitOffset, $this->limitLength) + $lists = $query->limit($this->limitOffset, $this->limitLength) ->field($field) ->order('id desc') ->select()->each(function($data){ From 214f1f86394fef59fe09ba3537f994a5b6721f31 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Thu, 9 Jan 2025 16:34:40 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/lists/user/UserLists.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/store/lists/user/UserLists.php b/app/store/lists/user/UserLists.php index 70aa1a4f5..b3816dbf8 100644 --- a/app/store/lists/user/UserLists.php +++ b/app/store/lists/user/UserLists.php @@ -51,7 +51,7 @@ class UserLists extends BaseAdminDataLists implements ListsSearchInterface } $query = User::where($this->searchWhere); if (!empty($this->params['nickname'])) { - $query->whereLike('nickname|mobile', "%{$this->params['nickname']}%"); + $query->whereLike('real_name|mobile', "%{$this->params['nickname']}%"); } $field = "id,nickname,real_name,sex,avatar,account,mobile,now_money,user_ship,create_time,purchase_funds,integral"; $lists = $query->limit($this->limitOffset, $this->limitLength) From 0b26b8cfb2ed2211c6ce0e9a9190b67140f364a7 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Thu, 9 Jan 2025 17:40:11 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=87=BA=E5=BA=93=E5=95=86=E5=93=81=E4=BE=9B?= =?UTF-8?q?=E8=B4=A7=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../beforehand_order/BeforehandOrderLogic.php | 1 + .../WarehouseProductLogic.php | 1 + process/Task.php | 29 +++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index c9bb6ffe8..f45fc4131 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -391,6 +391,7 @@ class BeforehandOrderLogic extends BaseLogic 'financial_pm' => 0, 'batch' => 0, 'mark' => $mark, + 'order_type' => $order['order_type'] ?? '', ]; $arr['delivery_time'] = strtotime($delivery_time); $res = WarehouseOrder::create($arr); diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index b7fc65f92..a1aa5a254 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -180,6 +180,7 @@ class WarehouseProductLogic extends BaseLogic 'unit' => $params['unit'] ?? 0, 'status' => 1, 'mark' => $params['mark'] ?? '', + 'order_type' => $params['order_type'] ?? '', ]; $res = WarehouseProduct::create($data); SqlChannelLog('WarehouseProduct', $res->id, $params['nums'], $params['financial_pm'] == 1 ? 1 : -1, Request()->url(),$admin_id); diff --git a/process/Task.php b/process/Task.php index fec68c71a..3206a152b 100644 --- a/process/Task.php +++ b/process/Task.php @@ -11,6 +11,7 @@ use app\common\model\store_order_cart_info\StoreOrderCartInfo; use app\common\model\store_product\StoreProduct; use app\common\model\store_product_price\StoreProductPrice; use app\common\model\user_recharge\UserRecharge; +use app\common\model\warehouse_product\WarehouseProduct; use support\Cache; use think\facade\Db; use Webman\RedisQueue\Redis; @@ -68,6 +69,7 @@ class Task $this->updateProductPrice(); $this->confirmProductPrice(); + $this->setPurchase(); } /** @@ -127,4 +129,31 @@ class Task }); } + /** + * 设置出库商品的供货价 + * @return void + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function setPurchase() + { + $list = WarehouseProduct::where('purchase', 0)->order('id desc')->limit(100)->select()->toArray(); + $productIds = array_unique(array_column($list, 'product_id')); + $products = StoreProduct::whereIn('id', $productIds)->field('id,purchase')->select()->toArray(); + $products = reset_index($products, 'id'); + $update = []; + foreach ($list as $item) { + $product = $products[$item['product_id']] ?? []; + if (empty($product) || empty($product['purchase'])) { + continue; + } + $update[] = [ + 'id' => $item['id'], + 'purchase' => min($product['purchase'], $item['price']), + ]; + } + (new WarehouseProduct())->saveAll($update); + } + } From 222dcbfcbb62a7a92b08e343d481de77d3f09bbd Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 9 Jan 2025 17:58:39 +0800 Subject: [PATCH 4/4] =?UTF-8?q?feat(admin):=20=E6=B7=BB=E5=8A=A0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=88=97=E8=A1=A8=E7=BB=9F=E8=AE=A1=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 BeforehandOrderController 中添加 statistics_count 方法处理统计请求 - 在 BeforehandOrderLogic 中实现 statisticsCount 方法进行订单统计 - 统计内容包括不同状态的订单数量,如未出库、已出库、未入库、已入库等 - 优化了代码格式,调整了部分缩进和空格 --- .../BeforehandOrderController.php | 10 +- .../beforehand_order/BeforehandOrderLogic.php | 112 +++++++++++++----- app/api/logic/DemoLogic.php | 8 +- 3 files changed, 97 insertions(+), 33 deletions(-) diff --git a/app/admin/controller/beforehand_order/BeforehandOrderController.php b/app/admin/controller/beforehand_order/BeforehandOrderController.php index 4c7b97832..ee50f728f 100644 --- a/app/admin/controller/beforehand_order/BeforehandOrderController.php +++ b/app/admin/controller/beforehand_order/BeforehandOrderController.php @@ -37,7 +37,15 @@ class BeforehandOrderController extends BaseAdminController { return $this->dataLists(new BeforehandOrderLists()); } - + /** + * 列表统计 + */ + public function statistics_count() + { + $params=$this->request->get(); + $data=BeforehandOrderLogic::statisticsCount($params); + return $this->data($data); + } public function warehousing_lists() { return $this->dataLists(new BeforehandOrderTwoLists()); diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index c9bb6ffe8..855a3e332 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -202,14 +202,14 @@ class BeforehandOrderLogic extends BaseLogic } $cart_select[$k]['price'] = $v['price']; -// //判断如果零售价小于供货价,则零售价等于供货价 -// if ($v['price'] < $find['purchase'] && $find['purchase'] != 0) { -// $cart_select[$k]['price'] = $find['purchase']; -// } -// if ($user['user_ship'] == 4 && $find['cost'] != 0) { -// $cart_select[$k]['price'] = $find['cost']; -// $total_prices = bcmul($find['cost'], $v['cart_num'], 2); -// } + // //判断如果零售价小于供货价,则零售价等于供货价 + // if ($v['price'] < $find['purchase'] && $find['purchase'] != 0) { + // $cart_select[$k]['price'] = $find['purchase']; + // } + // if ($user['user_ship'] == 4 && $find['cost'] != 0) { + // $cart_select[$k]['price'] = $find['cost']; + // $total_prices = bcmul($find['cost'], $v['cart_num'], 2); + // } $cart_select[$k]['cost'] = $find['cost']; $cart_select[$k]['purchase'] = $find['purchase']; $cart_select[$k]['vip'] = 0; @@ -375,9 +375,9 @@ class BeforehandOrderLogic extends BaseLogic if ($count > 0) { throw new BusinessException('订单中有数量为0的商品,请先处理'); } - $user_ship=0; - if($order['uid']>0){ - $user_ship=User::where('id', $order['uid'])->value('user_ship')??0; + $user_ship = 0; + if ($order['uid'] > 0) { + $user_ship = User::where('id', $order['uid'])->value('user_ship') ?? 0; } Db::startTrans(); try { @@ -395,10 +395,10 @@ class BeforehandOrderLogic extends BaseLogic $arr['delivery_time'] = strtotime($delivery_time); $res = WarehouseOrder::create($arr); foreach ($info as $key => $arr) { - if($user_ship==0){ - $price=0; - }else{ - $price=StoreProductGroupPrice::where('product_id',$arr['product_id'])->where('group_id',$user_ship)->value('price')??0; + if ($user_ship == 0) { + $price = 0; + } else { + $price = StoreProductGroupPrice::where('product_id', $arr['product_id'])->where('group_id', $user_ship)->value('price') ?? 0; } $data = [ 'warehouse_id' => $warehouse_id, @@ -418,7 +418,7 @@ class BeforehandOrderLogic extends BaseLogic 'code' => $res['code'], 'unit' => $arr['unit'] ?? 0, ]; - WarehouseProductLogic::setOutbound($data,1,$admin_id); + WarehouseProductLogic::setOutbound($data, 1, $admin_id); } $finds = WarehouseProduct::where('oid', $res['id'])->field('sum(nums) as nums,sum(total_price) as total_price')->find(); WarehouseOrder::where('id', $res['id'])->update(['total_price' => $finds['total_price'], 'nums' => $finds['nums']]); @@ -431,7 +431,7 @@ class BeforehandOrderLogic extends BaseLogic } } - /** + /** * @notes 一键报损出库 * @param array $params * @return bool @@ -492,7 +492,7 @@ class BeforehandOrderLogic extends BaseLogic 'code' => $res['code'], 'unit' => $arr['unit'] ?? 0, ]; - WarehouseProductLogic::setOutbound($data,1,$admin_id); + WarehouseProductLogic::setOutbound($data, 1, $admin_id); } $finds = WarehouseProduct::where('oid', $res['id'])->field('sum(nums) as nums,sum(total_price) as total_price')->find(); WarehouseOrder::where('id', $res['id'])->update(['total_price' => $finds['total_price'], 'nums' => $finds['nums']]); @@ -734,7 +734,7 @@ class BeforehandOrderLogic extends BaseLogic $find = WarehouseOrder::where('id', $order['outbound_id'])->find(); $order['order_id'] = $find['code']; $order['pay_price'] = $find['total_price']; - if (!empty($params['type']) &&$params['type'] == 3) { + if (!empty($params['type']) && $params['type'] == 3) { $file_path = $order_info->exportWithoutPrice($data, $order, $other_data); } else { $file_path = $order_info->export($data, $order, $other_data); @@ -839,7 +839,7 @@ class BeforehandOrderLogic extends BaseLogic $v['store_name'] = $find['store_name']; $v['mark'] = $find['after_sales']; $v['pay_price'] = bcmul($v['purchase'], $v['nums'], 2); - $v['profit']= bcsub($v['total_price'], $v['pay_price'], 2); + $v['profit'] = bcsub($v['total_price'], $v['pay_price'], 2); $total_profit = bcadd($total_profit, $v['profit'], 2); $pay_price = bcadd($pay_price, $v['pay_price'], 2); $total_price = bcadd($total_price, $v['total_price'], 2); @@ -868,12 +868,12 @@ class BeforehandOrderLogic extends BaseLogic } $order['admin_name'] = Admin::where('id', $order['admin_id'])->value('name'); $data = WarehouseProduct::where('oid', $order['outbound_id'])->where('nums', '>', 0)->select(); - if($order['uid']>0){ + if ($order['uid'] > 0) { $user_ship = User::where('id', $order['uid'])->value('user_ship'); - if($user_ship==0){ + if ($user_ship == 0) { throw new BusinessException('用户角色id不能为0'); } - }else{ + } else { throw new BusinessException('该订单没选择会员用户'); } $total_price = 0; @@ -884,13 +884,13 @@ class BeforehandOrderLogic extends BaseLogic $v['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name'); $v['store_name'] = $find['store_name']; $v['mark'] = $find['after_sales']; - $v['purchase']=StoreProductGroupPrice::where('product_id',$v['product_id'])->where('group_id',$user_ship)->value('price'); - if($v['purchase']){ + $v['purchase'] = StoreProductGroupPrice::where('product_id', $v['product_id'])->where('group_id', $user_ship)->value('price'); + if ($v['purchase']) { $v['pay_price'] = bcmul($v['purchase'], $v['nums'], 2); - }else{ - $v['pay_price']=0; + } else { + $v['pay_price'] = 0; } - $v['profit']= bcsub($v['total_price'], $v['pay_price'], 2); + $v['profit'] = bcsub($v['total_price'], $v['pay_price'], 2); $total_profit = bcadd($total_profit, $v['profit'], 2); $pay_price = bcadd($pay_price, $v['pay_price'], 2); $total_price = bcadd($total_price, $v['total_price'], 2); @@ -904,8 +904,8 @@ class BeforehandOrderLogic extends BaseLogic $order['total_profit'] = $total_profit; $order['total_price'] = $total_price; $order['group_title'] = ''; - if($user_ship){ - $order['group_title'] = UserShip::where('id',$user_ship)->value('title'); + if ($user_ship) { + $order['group_title'] = UserShip::where('id', $user_ship)->value('title'); } $file_path = $order_info->export($data, $order, $other_data, 2); return $file_path; @@ -948,4 +948,56 @@ class BeforehandOrderLogic extends BaseLogic $model->save(); } + /** + * 统计 + */ + public static function statisticsCount($params) + { + $where = []; + if ($params['warehouse_type'] > 0) { + switch ($params['warehouse_type']) { + case 1: + $where[] = ['is_outbound', '=', 0]; + $where[] = ['order_type', '<>', 5]; + break; + case 2: + $where[] = ['is_outbound', '=', 1]; + break; + case 3: + $where[] = ['is_warehousing', '=', 0]; + break; + case 4: + $where[] = ['is_warehousing', '=', 1]; + break; + default: + break; + } + } + $orderCounts = BeforehandOrder::where('order_type', 'in', [1, 2, 3, 4, 5, 7, 8]) + ->group('order_type') + ->where(['order_type', Db::raw('count(*) as count')]) + ->column('count', 'order_type'); + d($orderCounts); + $order_type_1 = BeforehandOrder::where([['order_type', '=', 1]])->count(); + $order_type_2 = BeforehandOrder::where([['order_type', '=', 2]])->count(); + $order_type_3 = BeforehandOrder::where([['order_type', '=', 3]])->count(); + $order_type_4 = BeforehandOrder::where([['order_type', '=', 4]])->count(); + $order_type_5 = BeforehandOrder::where([['order_type', '=', 5]])->count(); + $order_type_7 = BeforehandOrder::where([['order_type', '=', 7]])->count(); + $order_type_8 = BeforehandOrder::where([['order_type', '=', 8]])->count(); + + + + $outbound_0 = BeforehandOrder::where([['is_outbound', '=', 0], ['order_type', '<>', 5]])->count(); + $outbound_1 = BeforehandOrder::where([['is_outbound', '=', 1]])->count(); + $warehousing_0 = BeforehandOrder::where([['is_warehousing', '=', 0]])->count(); + $warehousing_1 = BeforehandOrder::where([['is_warehousing', '=', 1]])->count(); + + return [ + 'outbound_0' => $outbound_0, + 'outbound_1' => $outbound_1, + 'warehousing_0' => $warehousing_0, + 'warehousing_1' => $warehousing_1, + ]; + } } diff --git a/app/api/logic/DemoLogic.php b/app/api/logic/DemoLogic.php index 83e01edb2..8964cdeeb 100644 --- a/app/api/logic/DemoLogic.php +++ b/app/api/logic/DemoLogic.php @@ -71,9 +71,13 @@ class DemoLogic extends BaseLogic //活动价 $find42 = StoreProductGroupPrice::where('product_id', $v['product_id'])->where('group_id', 42)->find(); if ($find42) { - $find42->save(['price' => bcadd($v['price4'], 0, 2)]); + if($v['price9']>0){ + $find42->save(['price' => bcadd($v['price9'], 0, 2)]); + } } else { - StoreProductGroupPrice::insert(['product_id' => $v['product_id'], 'group_id' => 42, 'price' => bcadd($v['price9'], 0, 2), 'price_type' => 3, 'base_rate' =>0]); + if($v['price9']>0){ + StoreProductGroupPrice::insert(['product_id' => $v['product_id'], 'group_id' => 42, 'price' => bcadd($v['price9'], 0, 2), 'price_type' => 3, 'base_rate' =>0]); + } } } }