From e2a3472a11ed77e743461f7cf5efb9ba47cc1f09 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Fri, 10 Jan 2025 14:21:40 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=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 --- process/Task.php | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/process/Task.php b/process/Task.php index 3206a152b..fb94be224 100644 --- a/process/Task.php +++ b/process/Task.php @@ -138,22 +138,24 @@ class Task */ 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; + new Crontab('0 0 * * * *', function () { + $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']), + ]; } - $update[] = [ - 'id' => $item['id'], - 'purchase' => min($product['purchase'], $item['price']), - ]; - } - (new WarehouseProduct())->saveAll($update); + (new WarehouseProduct())->saveAll($update); + }); } } From 26b26768c6650e9b967f8a644f5bc00653989883 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Fri, 10 Jan 2025 15:49:46 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=80=80=E6=AC=BE?= =?UTF-8?q?=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/store_order/StoreOrderController.php | 4 ++-- app/common/service/RefundOrderService.php | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/admin/controller/store_order/StoreOrderController.php b/app/admin/controller/store_order/StoreOrderController.php index e900c08a2..28b6ab613 100644 --- a/app/admin/controller/store_order/StoreOrderController.php +++ b/app/admin/controller/store_order/StoreOrderController.php @@ -133,8 +133,8 @@ class StoreOrderController extends BaseAdminController return $this->fail('无该订单请检查'); } $params['id'] = $detail['id']; - if (empty($params['product_arr'])) { - $params['old_cart_id'] = StoreOrderCartInfo::where('oid', $detail['id'])->where('status', '<>', 2)->column('id'); + if (!isset($params['product_arr'])) { + $params['product_arr'] = StoreOrderCartInfo::where('oid', $detail['id'])->where('status', '<>', 2)->field('product_id,cart_num')->select()->toArray(); } $refundOrderService->refund($detail['uid'], $params); return $this->success('退款成功',[],1,1); diff --git a/app/common/service/RefundOrderService.php b/app/common/service/RefundOrderService.php index 67a57b27b..59b57184e 100644 --- a/app/common/service/RefundOrderService.php +++ b/app/common/service/RefundOrderService.php @@ -37,14 +37,15 @@ class RefundOrderService } $orderCartInfoWhere = ['oid' => $order['id']]; $refundNum = 0; - if (!empty($params['old_cart_id'])) { - $orderCartInfoWhere['id'] = $params['old_cart_id']; - $refundNum = count($params['old_cart_id']); - } if (!empty($params['product_arr'])) { $orderCartInfoWhere['product_id'] = array_column($params['product_arr'], 'product_id'); $refundNum = count($params['product_arr']); } + if (!empty($params['old_cart_id'])) { + $orderCartInfoWhere['id'] = $params['old_cart_id']; + $refundNum = count($params['old_cart_id']); + $params['product_arr'] = StoreOrderCartInfo::field('product_id,cart_num')->where($orderCartInfoWhere)->select()->toArray(); + } $orderCartProducts = StoreOrderCartInfo::where($orderCartInfoWhere)->select(); if (isset($params['refund_price'])) { $refundAmount = $params['refund_price']; @@ -223,7 +224,7 @@ class RefundOrderService } } $productIds = array_unique(array_column($storeOrderProducts->toArray(), 'product_id')); - StoreFinanceFlowProduct::where('oid', $order['id'])->whereIn('product_id', $productIds)->update(['number' => 0, 'update_time' => strtotime(time())]); + StoreFinanceFlowProduct::where('oid', $order['id'])->whereIn('product_id', $productIds)->update(['number' => 0, 'update_time' => time()]); $village_uid = StoreFinanceFlow::where('order_id', $order['id'])->where('financial_type', 14)->value('other_uid'); $brigade_uid = StoreFinanceFlow::where('order_id', $order['id'])->where('financial_type', 15)->value('other_uid'); $transaction_id = StoreFinanceFlow::where('order_id', $order['id'])->value('transaction_id'); From 33e4dd43f281b3b6a3ac6518595bede78d7b9309 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Fri, 10 Jan 2025 16:18:26 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=80=80=E6=AC=BE?= =?UTF-8?q?=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/service/RefundOrderService.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/common/service/RefundOrderService.php b/app/common/service/RefundOrderService.php index 59b57184e..59eb7c418 100644 --- a/app/common/service/RefundOrderService.php +++ b/app/common/service/RefundOrderService.php @@ -84,7 +84,8 @@ class RefundOrderService { $amount = '0.00'; foreach ($orderCartProducts as $orderCartProduct) { - $amount = bcadd($amount, $orderCartProduct['total_price'], 2); + $totalAmount = bcsub($orderCartProduct['total_price'], $orderCartProduct['refund_amount'], 2); + $amount = bcadd($amount, $totalAmount, 2); } return $amount; } From 28cdc83da041a1718a9c3e14bdcb8bc6b9ec45e5 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Fri, 10 Jan 2025 16:37:46 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=80=80=E6=AC=BE?= =?UTF-8?q?=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/service/RefundOrderService.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/common/service/RefundOrderService.php b/app/common/service/RefundOrderService.php index 59eb7c418..6807cbbcf 100644 --- a/app/common/service/RefundOrderService.php +++ b/app/common/service/RefundOrderService.php @@ -36,14 +36,11 @@ class RefundOrderService throw new BusinessException('订单不能退款'); } $orderCartInfoWhere = ['oid' => $order['id']]; - $refundNum = 0; if (!empty($params['product_arr'])) { $orderCartInfoWhere['product_id'] = array_column($params['product_arr'], 'product_id'); - $refundNum = count($params['product_arr']); } if (!empty($params['old_cart_id'])) { $orderCartInfoWhere['id'] = $params['old_cart_id']; - $refundNum = count($params['old_cart_id']); $params['product_arr'] = StoreOrderCartInfo::field('product_id,cart_num')->where($orderCartInfoWhere)->select()->toArray(); } $orderCartProducts = StoreOrderCartInfo::where($orderCartInfoWhere)->select(); @@ -63,7 +60,7 @@ class RefundOrderService $this->refundMoney($order, $refundAmount); $this->updateProductStock($orderCartProducts, $productInfo); $this->updateOrderCartInfo($order, $orderCartProducts, $refundAmount, $productInfo); - $this->updateOrderStatus($order, $refundAmount, $refundNum); + $this->updateOrderStatus($order, $refundAmount); $this->resetStoreFinanceFlow($order, $orderCartProducts, $productInfo); // if ($order->status == 2 && $order->is_writeoff == 1) { // $this->financeSettle($order); @@ -116,6 +113,8 @@ class RefundOrderService continue; } $number = $productInfo[$product['product_id']]['cart_num']; + $maxNumber = bcsub($product['cart_num'], $product['refund_num'], 2); + $number = min($number, $maxNumber); $storeBranchProductId = StoreBranchProduct::where('store_id', $product['store_id']) ->where('product_id', $product['product_id']) ->withTrashed()->value('id'); @@ -133,7 +132,8 @@ class RefundOrderService /** * 更新订单商品状态 * @param $order - * @param $orderCartIds + * @param $orderCartProducts + * @param $refundAmount * @param $productInfo * @return void * @throws DbException @@ -178,14 +178,13 @@ class RefundOrderService * 更新订单状态 * @param $order * @param $refundAmount - * @param $refundNum * @return void * @throws DbException */ - public function updateOrderStatus($order, $refundAmount, $refundNum): void + public function updateOrderStatus($order, $refundAmount): void { $order->refund_price = bcadd($order['refund_price'], $refundAmount, 2); - $order->refund_num += $refundNum; + $order->refund_num = StoreOrderCartInfo::where('oid', $order['id'])->where('refund_num', '>', 0)->count(); if ($order->pay_price == $order->refund_price) { // 全部退款完成,订单状态改为已退款 $order->refund_status = OrderEnum::REFUND_STATUS_FINISH; From 52e7ac5e2bb720a4960b5b797d7d197911ee949e Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 10 Jan 2025 17:24:07 +0800 Subject: [PATCH 05/12] =?UTF-8?q?refactor(api):=20=E8=A7=A3=E9=99=A4=20Dem?= =?UTF-8?q?oLogic::test()=20=E7=9A=84=E6=B3=A8=E9=87=8A=E5=B9=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=B0=83=E8=AF=95=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除了 DemoLogic::test() 方法调用的注释 - 在方法调用后添加了调试输出 d(1) - 保留了原有的查询和循环逻辑 --- app/api/controller/IndexController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index 1cded3f70..e5ee0b415 100644 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -68,7 +68,7 @@ class IndexController extends BaseApiController // } // $a=StoreOrderCartInfo::where('store_id',2)->whereBetweenTime('create_time','2025-01-01','2025-01-8')->select()->toArray(); // d($a); - // DemoLogic::test(); + DemoLogic::test(); d(1); $arr = Db::name('ceshi_copy')->select(); foreach ($arr as $k => $v) { From dbb7b9e4c8a9eb0b4a8174d625582a2383420294 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 10 Jan 2025 17:24:37 +0800 Subject: [PATCH 06/12] =?UTF-8?q?feat(store):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E5=8F=98=E6=9B=B4=E6=97=A5=E5=BF=97=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增价格变更日志模型、控制器、列表、逻辑和验证器 - 在商品编辑时记录价格变更日志 - 实现价格变更日志的添加、编辑、删除和详情功能 --- .../logic/store_product/StoreProductLogic.php | 14 ++- app/api/controller/IndexController.php | 2 +- app/common/logic/ChangePriceLogLogic.php | 20 ++++ .../model/change_price_log/ChangePriceLog.php | 23 +++++ app/functions.php | 11 +++ .../ChangePriceLogController.php | 95 ++++++++++++++++++ .../change_price_log/ChangePriceLogLists.php | 80 +++++++++++++++ .../change_price_log/ChangePriceLogLogic.php | 99 +++++++++++++++++++ .../ChangePriceLogValidate.php | 82 +++++++++++++++ 9 files changed, 423 insertions(+), 3 deletions(-) create mode 100644 app/common/logic/ChangePriceLogLogic.php create mode 100644 app/common/model/change_price_log/ChangePriceLog.php create mode 100644 app/store/controller/change_price_log/ChangePriceLogController.php create mode 100644 app/store/lists/change_price_log/ChangePriceLogLists.php create mode 100644 app/store/logic/change_price_log/ChangePriceLogLogic.php create mode 100644 app/store/validate/change_price_log/ChangePriceLogValidate.php diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index 9f4495c53..bdb51a290 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -237,10 +237,19 @@ class StoreProductLogic extends BaseLogic $rose=bcmul($price_div, 100, 2); } $data['rose']=$rose; - StoreProduct::update($data, ['id' => $params['id']]); + $find=StoreProduct::where(['id' => $params['id']])->find(); + if($find['purchase']!=$params['purchase']){ + SqlChannelPriceLog($params['id'],21,$find['purchase'],$params['purchase'],); + } + if($find['cost']!=$params['cost']){ + SqlChannelPriceLog($params['id'],4,$find['cost'],$params['cost'],); + } + if($find['price']!=$params['price']){ + SqlChannelPriceLog($params['id'],22,$find['price'],$params['price'],); + } + $find->save($data); // 修改活动专区商品 (new ActivityZoneLogic())->updateProduct($params['id'], $data); - // $dealCate = self::dealChangeCate($params['cate_id']); //修改 StoreBranchProduct::where('product_id', $params['id'])->whereNotIn('store_id', [17, 18])->update([ @@ -268,6 +277,7 @@ class StoreProductLogic extends BaseLogic return true; } catch (\Throwable $e) { Db::rollback(); + d($e); throw new BusinessException('编辑商品失败' . $e->getMessage()); } } diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index e5ee0b415..1cded3f70 100644 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -68,7 +68,7 @@ class IndexController extends BaseApiController // } // $a=StoreOrderCartInfo::where('store_id',2)->whereBetweenTime('create_time','2025-01-01','2025-01-8')->select()->toArray(); // d($a); - DemoLogic::test(); + // DemoLogic::test(); d(1); $arr = Db::name('ceshi_copy')->select(); foreach ($arr as $k => $v) { diff --git a/app/common/logic/ChangePriceLogLogic.php b/app/common/logic/ChangePriceLogLogic.php new file mode 100644 index 000000000..fb82ea2df --- /dev/null +++ b/app/common/logic/ChangePriceLogLogic.php @@ -0,0 +1,20 @@ + $product_id, + 'group_id' => $group_id, + 'before_price' => $before_price, + 'after_price' => $after_price, + 'create_time' => time() + ]); + } +} diff --git a/app/common/model/change_price_log/ChangePriceLog.php b/app/common/model/change_price_log/ChangePriceLog.php new file mode 100644 index 000000000..dc60a6236 --- /dev/null +++ b/app/common/model/change_price_log/ChangePriceLog.php @@ -0,0 +1,23 @@ +insert($model, $id, $nums, $pm, $url,$admin_id); } +/** + * 价格日志记录 + * @param model 模型 + * @param id 更新的模型组件id + * @param nums 更新的数量 + */ +function SqlChannelPriceLog($product_id=0, $group_id=0, $before_price=0,$after_price=0):void +{ + (new ChangePriceLogLogic())->insert($product_id, $group_id, $before_price, $after_price); +} // if (!function_exists('getNewOrderSn')) { // /** diff --git a/app/store/controller/change_price_log/ChangePriceLogController.php b/app/store/controller/change_price_log/ChangePriceLogController.php new file mode 100644 index 000000000..deb0ff18e --- /dev/null +++ b/app/store/controller/change_price_log/ChangePriceLogController.php @@ -0,0 +1,95 @@ +dataLists(new ChangePriceLogLists()); + } + + + /** + * @notes 添加价格变更记录 + * @return \think\response\Json + * @author admin + * @date 2025/01/10 15:54 + */ + public function add() + { + $params = (new ChangePriceLogValidate())->post()->goCheck('add'); + $result = ChangePriceLogLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(ChangePriceLogLogic::getError()); + } + + + /** + * @notes 编辑价格变更记录 + * @return \think\response\Json + * @author admin + * @date 2025/01/10 15:54 + */ + public function edit() + { + $params = (new ChangePriceLogValidate())->post()->goCheck('edit'); + $result = ChangePriceLogLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(ChangePriceLogLogic::getError()); + } + + + /** + * @notes 删除价格变更记录 + * @return \think\response\Json + * @author admin + * @date 2025/01/10 15:54 + */ + public function delete() + { + $params = (new ChangePriceLogValidate())->post()->goCheck('delete'); + ChangePriceLogLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取价格变更记录详情 + * @return \think\response\Json + * @author admin + * @date 2025/01/10 15:54 + */ + public function detail() + { + $params = (new ChangePriceLogValidate())->goCheck('detail'); + $result = ChangePriceLogLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/store/lists/change_price_log/ChangePriceLogLists.php b/app/store/lists/change_price_log/ChangePriceLogLists.php new file mode 100644 index 000000000..00edc68ed --- /dev/null +++ b/app/store/lists/change_price_log/ChangePriceLogLists.php @@ -0,0 +1,80 @@ + ['product_id', 'group_id', 'before_price', 'after_price'], + ]; + } + + + /** + * @notes 获取价格变更记录列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2025/01/10 15:54 + */ + public function lists(): array + { + if ($this->request->get('store_name')) { + $store_name = $this->request->get('store_name'); + $ids = StoreProduct::where('store_name', 'like', '%' . $store_name . '%')->where('status',1)->column('id'); + if ($ids) { + $this->searchWhere[] = ['product_id', 'in', $ids]; + $this->ids = $ids; + } else { + return []; + } + } + return ChangePriceLog::where($this->searchWhere) + ->field(['id', 'product_id', 'group_id', 'before_price', 'after_price']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取价格变更记录数量 + * @return int + * @author admin + * @date 2025/01/10 15:54 + */ + public function count(): int + { + if($this->request->get('store_name')){ + if($this->ids<=0){ + return 0; + } + } + return ChangePriceLog::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/store/logic/change_price_log/ChangePriceLogLogic.php b/app/store/logic/change_price_log/ChangePriceLogLogic.php new file mode 100644 index 000000000..301b6aa9a --- /dev/null +++ b/app/store/logic/change_price_log/ChangePriceLogLogic.php @@ -0,0 +1,99 @@ + $params['product_id'], + 'group_id' => $params['group_id'], + 'before_price' => $params['before_price'], + 'after_price' => $params['after_price'] + ]); + + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + + + /** + * @notes 编辑价格变更记录 + * @param array $params + * @return bool + * @author admin + * @date 2025/01/10 15:54 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + ChangePriceLog::where('id', $params['id'])->update([ + 'product_id' => $params['product_id'], + 'group_id' => $params['group_id'], + 'before_price' => $params['before_price'], + 'after_price' => $params['after_price'] + ]); + + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + + + /** + * @notes 删除价格变更记录 + * @param array $params + * @return bool + * @author admin + * @date 2025/01/10 15:54 + */ + public static function delete(array $params): bool + { + return ChangePriceLog::destroy($params['id']); + } + + + /** + * @notes 获取价格变更记录详情 + * @param $params + * @return array + * @author admin + * @date 2025/01/10 15:54 + */ + public static function detail($params): array + { + return ChangePriceLog::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/store/validate/change_price_log/ChangePriceLogValidate.php b/app/store/validate/change_price_log/ChangePriceLogValidate.php new file mode 100644 index 000000000..66d0f8d5a --- /dev/null +++ b/app/store/validate/change_price_log/ChangePriceLogValidate.php @@ -0,0 +1,82 @@ + 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + ]; + + + /** + * @notes 添加场景 + * @return ChangePriceLogValidate + * @author admin + * @date 2025/01/10 15:54 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + + /** + * @notes 编辑场景 + * @return ChangePriceLogValidate + * @author admin + * @date 2025/01/10 15:54 + */ + public function sceneEdit() + { + return $this->only(['id']); + } + + + /** + * @notes 删除场景 + * @return ChangePriceLogValidate + * @author admin + * @date 2025/01/10 15:54 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return ChangePriceLogValidate + * @author admin + * @date 2025/01/10 15:54 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file From b7f9a3b5ee18cef9af3c6d2aec22cddc619c2416 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 10 Jan 2025 17:50:29 +0800 Subject: [PATCH 07/12] =?UTF-8?q?feat(change=5Fprice=5Flog):=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E4=BB=B7=E6=A0=BC=E5=8F=98=E6=9B=B4=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加商品名称和会员组名称字段 - 优化 store_name 搜索条件 - 调整列表数据返回格式,增加创建时间和关联信息 --- .../change_price_log/ChangePriceLogLists.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/store/lists/change_price_log/ChangePriceLogLists.php b/app/store/lists/change_price_log/ChangePriceLogLists.php index 00edc68ed..c8c461e58 100644 --- a/app/store/lists/change_price_log/ChangePriceLogLists.php +++ b/app/store/lists/change_price_log/ChangePriceLogLists.php @@ -7,6 +7,7 @@ use app\common\lists\BaseDataLists; use app\common\model\change_price_log\ChangePriceLog; use app\common\lists\ListsSearchInterface; use app\common\model\store_product\StoreProduct; +use app\common\model\user_ship\UserShip; /** * 价格变更记录列表 @@ -44,7 +45,7 @@ class ChangePriceLogLists extends BaseDataLists implements ListsSearchInterface { if ($this->request->get('store_name')) { $store_name = $this->request->get('store_name'); - $ids = StoreProduct::where('store_name', 'like', '%' . $store_name . '%')->where('status',1)->column('id'); + $ids = StoreProduct::where('store_name', 'like', '%' . $store_name . '%')->where('status', 1)->column('id'); if ($ids) { $this->searchWhere[] = ['product_id', 'in', $ids]; $this->ids = $ids; @@ -53,10 +54,14 @@ class ChangePriceLogLists extends BaseDataLists implements ListsSearchInterface } } return ChangePriceLog::where($this->searchWhere) - ->field(['id', 'product_id', 'group_id', 'before_price', 'after_price']) + ->field(['id', 'product_id', 'group_id', 'before_price', 'after_price','create_time']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) - ->select() + ->select()->each(function ($item) { + $store_name= StoreProduct::where('id', $item['product_id'])->value('store_name'); + $item->store_name = $store_name; + $item->group_name=UserShip::where('id',$item['group_id'])->value('title'); + }) ->toArray(); } @@ -69,12 +74,11 @@ class ChangePriceLogLists extends BaseDataLists implements ListsSearchInterface */ public function count(): int { - if($this->request->get('store_name')){ - if($this->ids<=0){ + if ($this->request->get('store_name')) { + if ($this->ids <= 0) { return 0; } } return ChangePriceLog::where($this->searchWhere)->count(); } - -} \ No newline at end of file +} From ca43cf01fa9788a50d373c7d0ce6f290419e2d7a Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 11 Jan 2025 11:31:48 +0800 Subject: [PATCH 08/12] =?UTF-8?q?refactor(store=5Fbranch=5Fproduct):=20?= =?UTF-8?q?=E9=87=8D=E6=9E=84=E5=BA=93=E5=AD=98=E7=BC=96=E8=BE=91=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除了冗余的代码和不必要的条件判断 - 优化了数据库查询和更新操作 - 简化了库存更新逻辑,提高了代码可读性和维护性 --- .../StoreBranchProductController.php | 2 ++ .../StoreBranchProductLogic.php | 24 ++++--------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/app/admin/controller/store_branch_product/StoreBranchProductController.php b/app/admin/controller/store_branch_product/StoreBranchProductController.php index efd9f862e..a5ae13f4d 100644 --- a/app/admin/controller/store_branch_product/StoreBranchProductController.php +++ b/app/admin/controller/store_branch_product/StoreBranchProductController.php @@ -93,6 +93,8 @@ class StoreBranchProductController extends BaseAdminController */ public function edit_stock() { + $params = $this->request->post(); + StoreBranchProductLogic::stock($params); return $this->success('编辑成功', [], 1, 1); } /** diff --git a/app/admin/logic/store_branch_product/StoreBranchProductLogic.php b/app/admin/logic/store_branch_product/StoreBranchProductLogic.php index 95a1debcb..b833b399a 100644 --- a/app/admin/logic/store_branch_product/StoreBranchProductLogic.php +++ b/app/admin/logic/store_branch_product/StoreBranchProductLogic.php @@ -67,7 +67,7 @@ class StoreBranchProductLogic extends BaseLogic return true; } catch (\Throwable $e) { Db::rollback(); - throw new BusinessException('商品编辑失败:',$e->getMessage()); + throw new BusinessException('商品编辑失败:', $e->getMessage()); } } /** @@ -77,29 +77,13 @@ class StoreBranchProductLogic extends BaseLogic * @author admin * @date 2024/06/07 13:56 */ - public static function stock(array $params, $type = 1,$admin_id=0): bool + public static function stock(array $params, $type = 1, $admin_id = 0): bool { Db::startTrans(); try { - $find = StoreProduct::where('id', $params['product_id'])->find()->toArray(); $storeBranchProduct = StoreBranchProduct::where('id', $params['id'])->find()->toArray(); - if ($type == 1) { - $stock = bcadd($find['stock'], $params['nums'], 2); - $branchStock = bcadd($storeBranchProduct['stock'], $params['nums'], 2); - - StoreBranchProduct::update(['stock' => $branchStock, 'total_price' => bcmul($branchStock, $find['purchase'], 2)],['id'=> $params['id']]); - SqlChannelLog('StoreBranchProduct', $params['id'], $params['nums'], 1, Request()->url(),$admin_id); - StoreProduct::update(['stock' => $stock, 'total_price' => bcmul($stock, $find['purchase'], 2)],['id'=> $params['product_id']]); - - } else { - $branchStock = bcsub($storeBranchProduct['stock'], $params['nums'], 2); - $stock = bcsub($find['stock'], $params['nums'], 2); - - StoreBranchProduct::where('id', $params['id'])->update(['stock' => $branchStock, 'total_price' => bcmul($branchStock, $find['purchase'], 2)],['id'=>$params['id']]); - SqlChannelLog('StoreBranchProduct', $params['id'], $params['nums'], -1, Request()->url(),$admin_id); - StoreProduct::where('id', $params['product_id'])->update(['stock' => $stock, 'total_price' => bcmul($stock, $find['purchase'], 2)],['id'=>$params['product_id']]); - - } + StoreBranchProduct::update(['stock' => $params['stock'], 'total_price' => bcmul($params['stock'], $storeBranchProduct['purchase'], 2)], ['id' => $params['id']]); + SqlChannelLog('StoreBranchProduct', $params['id'], $params['stock'], 0, Request()->url(), $admin_id); Db::commit(); return true; } catch (\Throwable $e) { From cc8eb3e72f4b4cd0c222a8b12a32047b2e6ae937 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 11 Jan 2025 14:59:39 +0800 Subject: [PATCH 09/12] =?UTF-8?q?fix(admin):=20=E4=BF=AE=E5=A4=8D=E6=8F=90?= =?UTF-8?q?=E5=89=8D=E5=8D=95=E7=BB=9F=E8=AE=A1=E5=8A=9F=E8=83=BD=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在创建提前单时添加审核状态字段 - 优化提前单统计查询条件 - 增加按订单类型筛选的功能 - 调整订单类型统计的字段名 --- .../beforehand_order/BeforehandOrderLogic.php | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index cb40bab46..0dbac1f3d 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -570,6 +570,7 @@ class BeforehandOrderLogic extends BaseLogic 'order_type' => 4, 'deduction_price' => 0, 'paid' => 0, + 'audit_status' => 1, 'mark' => $params['mark'] ?? '', 'other_data' => json_encode($other_data, true) @@ -956,10 +957,10 @@ class BeforehandOrderLogic extends BaseLogic { $where = []; $where2 = []; - if($params['store_id']>0){ + if ($params['store_id'] > 0) { $where2[] = ['store_id', '=', $params['store_id']]; } - if($params['start_time']!=''&& $params['end_time']!=''){ + if ($params['start_time'] != '' && $params['end_time'] != '') { $where2[] = ['create_time', 'between', [strtotime($params['start_time']), strtotime($params['end_time'])]]; } if ($params['warehouse_type'] > 0) { @@ -984,22 +985,25 @@ class BeforehandOrderLogic extends BaseLogic $orderCounts = BeforehandOrder::where('order_type', 'in', [1, 2, 3, 4, 5, 7, 8]) ->where($where2) ->group('order_type') - ->field([Db::raw('count(*) as count'),'order_type'])->select(); + ->field([Db::raw('count(*) as count'), 'order_type'])->select(); + if ($params['order_type'] > 0) { + $where2[] = ['order_type', '=', $params['order_type']]; + } $outbound_0 = BeforehandOrder::where([['is_outbound', '=', 0], ['order_type', '<>', 5]])->where($where2)->count(); $outbound_1 = BeforehandOrder::where([['is_outbound', '=', 1]])->where($where2)->count(); $warehousing_0 = BeforehandOrder::where([['is_warehousing', '=', 0]])->where($where2)->count(); $warehousing_1 = BeforehandOrder::where([['is_warehousing', '=', 1]])->where($where2)->count(); - $data=[ - 'order_type_1' =>0, - 'order_type_2'=>0, - 'order_type_3'=>0, - 'order_type_4'=>0, - 'order_type_5'=>0, - 'order_type_7'=>0, - 'order_type_8'=>0 + $data = [ + 'order_type_1' => 0, + 'order_type_2' => 0, + 'order_type_3' => 0, + 'order_type_4' => 0, + 'order_type_5' => 0, + 'order_type_7' => 0, + 'order_type_8' => 0 ]; foreach ($orderCounts as $k => $v) { - $data['order_type'.'_'.$v['order_type']] =$v['count'] ; + $data['order_type' . '_' . $v['order_type']] = $v['count']; } $data['outbound_0'] = $outbound_0; $data['outbound_1'] = $outbound_1; From 768068a8ea070c2c766157e89052c48772d880dc Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 11 Jan 2025 15:27:27 +0800 Subject: [PATCH 10/12] =?UTF-8?q?feat(store=5Forder):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E6=A0=B8=E9=94=80=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 writeoff_order 方法实现订单核销功能 - 增加核销码和门店 ID 的参数验证 - 调用 OrderLogic::writeOff 方法进行订单核销 - 返回核销成功或失败的响应 --- .../store_order/StoreOrderController.php | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/app/admin/controller/store_order/StoreOrderController.php b/app/admin/controller/store_order/StoreOrderController.php index 28b6ab613..96736ad62 100644 --- a/app/admin/controller/store_order/StoreOrderController.php +++ b/app/admin/controller/store_order/StoreOrderController.php @@ -10,6 +10,7 @@ use app\admin\logic\store_order\StoreOrderLogic; use app\admin\logic\store_product\StoreProductLogic; use app\admin\logic\warehouse_product\WarehouseProductLogic; use app\admin\validate\store_order\StoreOrderValidate; +use app\api\logic\order\OrderLogic; use app\common\enum\PayEnum; use app\common\logic\PayNotifyLogic; use app\common\model\delivery_service\DeliveryService; @@ -139,7 +140,25 @@ class StoreOrderController extends BaseAdminController $refundOrderService->refund($detail['uid'], $params); return $this->success('退款成功',[],1,1); } - + /** + * 核销 + */ + public function writeoff_order() + { + $params =$this->request->post(); + if (empty($params['verify_code'])) { + return $this->fail('核销码不存在'); + } + if (empty($params['store_id'])) { + return $this->fail('门店id不存在'); + } + $params['staff_id']=0; + $res = OrderLogic::writeOff($params); + if ($res) { + return $this->success('核销成功',[],1,1); + } + return $this->fail('核销失败'); + } /** * 设置配送员 */ From f485c956df1b32d932a041414ba4379eea161040 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Sat, 11 Jan 2025 16:15:52 +0800 Subject: [PATCH 11/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81?= =?UTF-8?q?=E8=B0=83=E6=8B=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StoreBranchProductLists.php | 14 +- .../InventoryTransferLogic.php | 138 ++++++++++-------- .../InventoryTransferValidate.php | 8 +- 3 files changed, 87 insertions(+), 73 deletions(-) diff --git a/app/admin/lists/store_branch_product/StoreBranchProductLists.php b/app/admin/lists/store_branch_product/StoreBranchProductLists.php index 3feb38d73..adf157c90 100644 --- a/app/admin/lists/store_branch_product/StoreBranchProductLists.php +++ b/app/admin/lists/store_branch_product/StoreBranchProductLists.php @@ -82,8 +82,12 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI if ($where) { $this->searchWhere[] = $where; } - return StoreBranchProduct::where($this->searchWhere) - ->field(['id', 'store_id', 'product_id', 'image', 'store_name', 'store_info', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost', 'purchase', 'status', 'batch', 'vip_price','bar_code', 'manufacturer_information','total_price']) + $query = StoreBranchProduct::where($this->searchWhere); + if (isset($this->params['low_stock']) && $this->params['low_stock'] == 1) { + $query->where('stock', '<=', 'low_stock'); + } + return $query + ->field(['id', 'store_id', 'product_id', 'image', 'store_name', 'store_info', 'cate_id', 'price', 'sales', 'stock', 'low_stock', 'unit', 'cost', 'purchase', 'status', 'batch', 'vip_price','bar_code', 'manufacturer_information','total_price']) ->when(!empty($this->adminInfo['store_id']), function ($query) { $query->where('store_id', $this->adminInfo['store_id']); }) @@ -111,7 +115,11 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI */ public function count(): int { - return StoreBranchProduct::where($this->searchWhere) + $query = StoreBranchProduct::where($this->searchWhere); + if (isset($this->params['low_stock']) && $this->params['low_stock'] == 1) { + $query->where('stock', '<=', 'low_stock'); + } + return $query ->when(!empty($this->adminInfo['store_id']), function ($query) { $query->where('store_id', $this->adminInfo['store_id']); }) diff --git a/app/admin/logic/inventory_transfer/InventoryTransferLogic.php b/app/admin/logic/inventory_transfer/InventoryTransferLogic.php index 736fc4b46..f8cc56ffb 100644 --- a/app/admin/logic/inventory_transfer/InventoryTransferLogic.php +++ b/app/admin/logic/inventory_transfer/InventoryTransferLogic.php @@ -6,6 +6,7 @@ use app\admin\logic\warehouse_product\WarehouseProductLogic; use app\common\model\inventory_transfer\InventoryTransfer; use app\common\logic\BaseLogic; use app\common\model\store_branch_product\StoreBranchProduct; +use app\common\model\store_product\StoreProduct; use app\common\model\warehouse_product_storege\WarehouseProductStorege; use support\exception\BusinessException; use think\facade\Db; @@ -29,75 +30,84 @@ class InventoryTransferLogic extends BaseLogic */ public static function add(array $params,$admin_id=0): bool { - $one_before_nums = 0; - $one_after_nums = 0; - $two_before_nums = 0; - $two_after_nums = 0; - if($params['one_type']==1){ - $stock = StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['one_id'])->value('stock'); - if ($stock < $params['nums']) { - throw new BusinessException('调拨数量不能大于当前门店库存'); + if (empty($params['product_arr'])) { + throw new BusinessException('请选择商品'); + } + $productIds = array_column($params['product_arr'], 'product_id'); + if ($params['one_type'] == 1) { + $outProducts = StoreBranchProduct::whereIn('product_id', $productIds)->where('store_id', $params['one_id'])->field('id,product_id,stock')->select()->toArray(); + } else { + $outProducts = WarehouseProductStorege::whereIn('product_id', $productIds)->where('warehouse_id', $params['one_id'])->field('id,product_id,nums stock')->select()->toArray(); + } + $outProducts = reset_index($outProducts, 'product_id'); + if ($params['two_type'] == 1) { + $inProducts = StoreBranchProduct::whereIn('product_id', $productIds)->where('store_id', $params['two_id'])->field('id,product_id,stock')->select()->toArray(); + } else { + $inProducts = WarehouseProductStorege::whereIn('product_id', $productIds)->where('warehouse_id', $params['two_id'])->field('id,product_id,nums stock')->select()->toArray(); + } + $inProducts = reset_index($inProducts, 'product_id'); + $insert = []; + foreach ($params['product_arr'] as $v) { + $outProduct = !empty($outProducts[$v['product_id']]) ? $outProducts[$v['product_id']] : ['stock' => 0, 'id' => 0, 'product_id' => $v['product_id']]; + $inProduct = !empty($inProducts[$v['product_id']]) ? $inProducts[$v['product_id']] : ['stock' => 0, 'id' => 0, 'product_id' => $v['product_id']]; + if ($outProduct['stock'] < $v['nums']) { + throw new BusinessException("出库商品 {$outProduct['product_id']} 调拨数量不能大于当前仓库库存"); } - if($params['two_type']==1){ - $stock_two = StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['two_id'])->value('stock'); - }elseif($params['two_type']==2){ - $stock_two = WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['two_id'])->value('nums'); - } - $one_before_nums = $stock; - $one_after_nums = bcsub($stock, $params['nums']); - - $two_before_nums = $stock_two; - $two_after_nums = bcadd($stock_two, $params['nums']); - }elseif($params['one_type']==2){ - $stock = WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['one_id'])->value('nums'); - if ($stock < $params['nums']) { - throw new BusinessException('调拨数量不能大于当前仓库库存'); - } - if($params['two_type']==1){ - $stock_two = StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['two_id'])->value('stock'); - }elseif($params['two_type']==2){ - $stock_two = WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['two_id'])->value('nums'); - } - $one_before_nums = $stock; - $one_after_nums = bcsub($stock, $params['nums']); - - $two_before_nums = $stock_two; - $two_after_nums = bcadd($stock_two, $params['nums']); - }else{ - throw new BusinessException('调拨类型错误'); + $insert[] = [ + 'product_id' => $v['product_id'], + 'nums' => $v['nums'], + 'one_before_nums' => $outProduct['stock'], + 'one_after_nums' => bcsub($outProduct['stock'], $v['nums']), + 'two_before_nums' => $inProduct['stock'], + 'two_after_nums' => bcadd($inProduct['stock'], $v['nums']), + 'one_type' => $params['one_type'], + 'two_type' => $params['two_type'], + 'one_id' => $params['one_id'], + 'two_id' => $params['two_id'], + 'create_time' => time(), + ]; } Db::startTrans(); try { - InventoryTransfer::create([ - 'product_id' => $params['product_id'], - 'nums' => $params['nums'], - 'one_before_nums' => $one_before_nums, - 'one_after_nums' => $one_after_nums, - 'two_before_nums' => $two_before_nums, - 'two_after_nums' => $two_after_nums, - 'one_type' => $params['one_type'], - 'two_type' => $params['two_type'], - 'one_id' => $params['one_id'], - 'two_id' => $params['two_id'] - ]); - if($params['one_type']==1){ - $find=StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['one_id'])->find(); - $find->save(['stock' =>bcsub( $find['stock'],$params['nums'],2)]); - SqlChannelLog('StoreBranchProduct', $find['id'], $params['nums'], -1, Request()->url(),$admin_id); - } elseif ($params['one_type'] == 2) { - $find=WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['one_id'])->find(); - $find->save(['nums' =>bcsub( $find['nums'],$params['nums'],2)]); - SqlChannelLog('WarehouseProductStorege', $find['id'], $params['nums'], -1, Request()->url(),$admin_id); - } - if($params['two_type']==1){ - $find=StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['two_id'])->find(); - $find->save(['stock' =>bcadd( $find['stock'],$params['nums'],2)]); - SqlChannelLog('StoreBranchProduct', $find['id'], $params['nums'], 1, Request()->url(),$admin_id); - } elseif ($params['two_type'] == 2) { - $find=WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['two_id'])->find(); - $find->save(['nums' =>bcadd( $find['nums'],$params['nums'],2)]); - SqlChannelLog('WarehouseProductStorege', $find['id'], $params['nums'], 1, Request()->url(),$admin_id); + InventoryTransfer::insertAll($insert); + foreach ($insert as $v) { + if($params['one_type']==1){ + $find=StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $params['one_id'])->find(); + $find->save(['stock' =>bcsub( $find['stock'],$v['nums'],2)]); + SqlChannelLog('StoreBranchProduct', $find['id'], $v['nums'], -1, Request()->url(),$admin_id); + } elseif ($params['one_type'] == 2) { + $find=WarehouseProductStorege::where('product_id', $v['product_id'])->where('warehouse_id', $params['one_id'])->find(); + $find->save(['nums' =>bcsub( $find['nums'],$v['nums'],2)]); + SqlChannelLog('WarehouseProductStorege', $find['id'], $v['nums'], -1, Request()->url(),$admin_id); + } + if($params['two_type']==1){ + $find=StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $params['two_id'])->find(); + if (empty($find)) { + $storeProduct = StoreProduct::field('top_cate_id,two_cate_id,cate_id,store_name,image,price,vip_price,cost,purchase,keyword,bar_code,store_info,rose,product_type,unit,batch,store_batch,label_id,is_lack,manufacturer_information')->where('id', $v['product_id'])->find()->toArray(); + $find = new StoreBranchProduct(); + $find->product_id = $v['product_id']; + $find->store_id = $params['two_id']; + $find->stock = $v['nums']; + $find->setAttrs($storeProduct); + $find->save(); + } else { + $find->save(['stock' =>bcadd( $find['stock'],$v['nums'],2)]); + } + SqlChannelLog('StoreBranchProduct', $find['id'], $v['nums'], 1, Request()->url(),$admin_id); + } elseif ($params['two_type'] == 2) { + $find=WarehouseProductStorege::where('product_id', $v['product_id'])->where('warehouse_id', $params['two_id'])->find(); + if (empty($find)) { + $find = new WarehouseProductStorege(); + $find->warehouse_id = $params['two_id']; + $find->product_id = $v['product_id']; + $find->nums = $v['nums']; + $find->save(); + } else { + $find->save(['nums' =>bcadd( $find['nums'],$v['nums'],2)]); + } + SqlChannelLog('WarehouseProductStorege', $find['id'], $v['nums'], 1, Request()->url(),$admin_id); + } } Db::commit(); return true; diff --git a/app/admin/validate/inventory_transfer/InventoryTransferValidate.php b/app/admin/validate/inventory_transfer/InventoryTransferValidate.php index dd55ec814..dcf398e94 100644 --- a/app/admin/validate/inventory_transfer/InventoryTransferValidate.php +++ b/app/admin/validate/inventory_transfer/InventoryTransferValidate.php @@ -20,8 +20,6 @@ class InventoryTransferValidate extends BaseValidate */ protected $rule = [ 'id' => 'require', - 'product_id' => 'require', - 'nums' => 'require', 'type' => 'require', 'one_id' => 'require', 'two_id' => 'require', @@ -34,8 +32,6 @@ class InventoryTransferValidate extends BaseValidate */ protected $field = [ 'id' => 'id', - 'product_id' => '商品', - 'nums' => '数量', 'type' => '1商户2仓库', 'one_id' => '转出id', 'two_id' => '转入id', @@ -50,7 +46,7 @@ class InventoryTransferValidate extends BaseValidate */ public function sceneAdd() { - return $this->only(['product_id','nums','one_id','two_id']); + return $this->only(['one_id','two_id']); } @@ -62,7 +58,7 @@ class InventoryTransferValidate extends BaseValidate */ public function sceneEdit() { - return $this->only(['id','product_id','nums','type','one_id','two_id']); + return $this->only(['id','type','one_id','two_id']); } From 5d73af571922ac377425178d22185bdd4f435803 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Sat, 11 Jan 2025 16:52:14 +0800 Subject: [PATCH 12/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=97=A8=E5=BA=97?= =?UTF-8?q?=E9=A2=84=E8=AE=A2=E5=8D=95=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lists/beforehand_order/BeforehandOrderLists.php | 11 ++++++++--- .../logic/beforehand_order/BeforehandOrderLogic.php | 1 + .../beforehand_order/BeforehandOrderController.php | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/admin/lists/beforehand_order/BeforehandOrderLists.php b/app/admin/lists/beforehand_order/BeforehandOrderLists.php index e5d8f2251..48e3abef4 100644 --- a/app/admin/lists/beforehand_order/BeforehandOrderLists.php +++ b/app/admin/lists/beforehand_order/BeforehandOrderLists.php @@ -12,6 +12,7 @@ use app\common\model\system_store\SystemStore; use app\common\lists\ListsExcelInterface; use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo; use app\common\model\store_order\StoreOrder; +use app\common\model\system_store\SystemStoreStaff; use app\common\model\warehouse_order\WarehouseOrder; use app\common\model\warehouse_product\WarehouseProduct; @@ -33,7 +34,7 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte public function setSearch(): array { return [ - '=' => ['store_id', 'paid', 'status', 'order_type', 'admin_id'], + '=' => ['store_id', 'paid', 'status', 'order_type', 'admin_id', 'store_staff_id'], '%like' => ['order_id','order_sn'], '%like%' => ['mark'], 'between_time' => 'create_time' @@ -81,8 +82,9 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte $oid=WarehouseOrder::where('financial_pm',0)->where('code','like','%'.$order_ck)->column('id'); $this->searchWhere[] = ['outbound_id','in',$oid]; } - $file=['id','uid', 'order_id', 'order_sn','store_id', 'order_type', 'total_num', 'total_price', 'outbound_id', 'admin_id', 'create_time', 'status', 'mark', 'warehousing_id', 'file','other_data', 'audit_status']; - return BeforehandOrder::where($this->searchWhere) + $file=['id','uid', 'order_id', 'order_sn','store_id', 'order_type', 'total_num', 'total_price', 'outbound_id', 'admin_id', 'create_time', 'status', 'mark', 'warehousing_id', 'file','other_data', 'audit_status', 'store_staff_id']; + $query = BeforehandOrder::where($this->searchWhere); + return $query ->field($file) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) @@ -94,6 +96,9 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte } else { $item->admin_name = ''; } + if ($item->store_staff_id) { + $item->admin_name = SystemStoreStaff::where(['id' => $item->store_staff_id])->value('staff_name'); + } if ($item->order_type == 1) { $item->order_type_name = '铺货订单'; } elseif ($item->order_type == 2) { diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index 0dbac1f3d..13c5e4117 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -112,6 +112,7 @@ class BeforehandOrderLogic extends BaseLogic $order = BeforehandOrder::create([ 'order_id' => getNewOrderId('YG'), 'admin_id' => $params['admin_id'] ?? 0, + 'store_staff_id' => $params['store_staff_id'] ?? 0, 'store_id' => $params['store_id'] ?? 0, 'uid' => $uid, 'total_num' => $total_num, diff --git a/app/store/controller/beforehand_order/BeforehandOrderController.php b/app/store/controller/beforehand_order/BeforehandOrderController.php index 9f5002491..9d39c2276 100644 --- a/app/store/controller/beforehand_order/BeforehandOrderController.php +++ b/app/store/controller/beforehand_order/BeforehandOrderController.php @@ -39,7 +39,7 @@ class BeforehandOrderController extends BaseAdminController { $params = $this->request->get(); $params['store_id'] = $this->request->adminInfo['store_id'] ?? 0; - $params['admin_id'] = $this->request->adminInfo['admin_id'] ?? 0; + $params['store_staff_id'] = $this->request->adminInfo['admin_id'] ?? 0; $this->request->setGet($params); return $this->dataLists(new BeforehandOrderLists()); } @@ -63,7 +63,7 @@ class BeforehandOrderController extends BaseAdminController public function add() { $params = $this->request->post(); - $params['admin_id'] = $this->adminId; + $params['store_staff_id'] = $this->adminId; $params['store_id'] = $this->request->adminInfo['store_id'] ?? 0; $other_data = [ 'nickname' => $params['nickname'] ?? '',