From 6e2a0ca2626306b78e6890df573805aaa00665c8 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Thu, 6 Feb 2025 16:13:09 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B4=A6=E6=9C=9F?= =?UTF-8?q?=E6=AC=A0=E6=AC=BE=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/lists/AccountsReceivableLists.php | 4 +- app/admin/logic/AccountsReceivableLogic.php | 87 --------------------- 2 files changed, 2 insertions(+), 89 deletions(-) diff --git a/app/admin/lists/AccountsReceivableLists.php b/app/admin/lists/AccountsReceivableLists.php index 6634da2f3..1cfa84c89 100644 --- a/app/admin/lists/AccountsReceivableLists.php +++ b/app/admin/lists/AccountsReceivableLists.php @@ -6,8 +6,6 @@ use app\common\lists\ListsSearchInterface; use app\common\model\beforehand_order\BeforehandOrder; use app\common\model\finance\AccountsReceivable; use app\common\model\system_store\SystemStore; -use app\common\model\user\User; -use Illuminate\Contracts\Cache\Store; /** * AccountsReceivableLists @@ -51,6 +49,8 @@ class AccountsReceivableLists extends BaseAdminDataLists implements ListsSearchI foreach ($list as &$item) { $item['store_name'] = $stores[$item['store_id']]['name']; $item['order_sn'] = $orderInfo[$item['order_id']]['order_id']; + $item['debt_day'] = intval((time() - strtotime($item['create_time'])) / 86400); + $item['deadline'] = date('Y-m-d H:i:s', $item['deadline']); } return $list; } diff --git a/app/admin/logic/AccountsReceivableLogic.php b/app/admin/logic/AccountsReceivableLogic.php index 2e363e7e0..0584f6b1c 100644 --- a/app/admin/logic/AccountsReceivableLogic.php +++ b/app/admin/logic/AccountsReceivableLogic.php @@ -32,91 +32,4 @@ class AccountsReceivableLogic extends BaseLogic $model->save(); } - - /** - * @notes 编辑 - * @param array $params - * @return bool - * @author admin - * @date 2024/12/20 10:52 - */ - public static function edit(array $params): bool - { - Db::startTrans(); - try { - ActivityZone::where('id', $params['id'])->update([ - 'form_id' => $params['form_id'], - 'product_id' => $params['product_id'], - ]); - - Db::commit(); - return true; - } catch (\Throwable $e) { - Db::rollback(); - throw new BusinessException($e->getMessage()); - } - } - - - /** - * @notes 删除 - * @param array $params - * @return bool - * @author admin - * @date 2024/12/20 10:52 - */ - public static function delete(array $params): bool - { - return ActivityZone::destroy($params['id']); - } - - - /** - * @notes 获取详情 - * @param $params - * @return array - * @author admin - * @date 2024/12/20 10:52 - */ - public static function detail($params): array - { - return ActivityZone::findOrEmpty($params['id'])->toArray(); - } - - public function addProduct($product) - { - $activityFormId1 = ActivityZoneForm::whereRaw('FIND_IN_SET(:cate_id,cate_ids)', ['cate_id' => $product['two_cate_id']])->column('id'); - $activityFormId2 = ActivityZoneForm::whereRaw('FIND_IN_SET(:cate_id,cate_ids)', ['cate_id' => $product['cate_id']])->column('id'); - $activityFormIds = array_unique(array_merge($activityFormId1, $activityFormId2)); - foreach ($activityFormIds as $activityFormId) { - $activityZone = new ActivityZone(); - $activityZone->form_id = $activityFormId; - $activityZone->product_id = $product['id']; - $activityZone->save(); - } - } - - public function updateProduct($productId, $product) - { - $product['id'] = $productId; - $formIds = ActivityZone::where('product_id', $productId)->column('form_id'); - if (empty($formIds)) { - $this->addProduct($product); - return; - } - $forms = ActivityZoneForm::whereIn('id', $formIds)->select()->toArray(); - foreach ($forms as $form) { - $cateIds = explode(',', $form['cate_ids']); - if (!in_array($product['two_cate_id'], $cateIds) && !in_array($product['cate_id'], $cateIds)) { - ActivityZone::where('product_id', $productId)->where('form_id', $form['id'])->update(['delete_time' => time()]); - } - $this->addProduct($product); - } - } - - public function deleteProduct($productId) - { - ActivityZone::where('product_id', $productId)->update(['delete_time' => time()]); - } - } \ No newline at end of file From 2a30c2144fff4a3d67ce807e81c39bb6a1f4232d Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 6 Feb 2025 16:17:42 +0800 Subject: [PATCH 02/12] =?UTF-8?q?refactor(app):=20=E9=99=90=E5=88=B6?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=88=97=E8=A1=A8=E4=B8=AD=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E7=9A=84=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 OrderList 类中,为 StoreOrderCartInfo 的查询添加了 limit(3) 方法 - 此修改旨在减少查询结果的数量,提高性能和可读性 --- app/api/lists/order/OrderList.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/api/lists/order/OrderList.php b/app/api/lists/order/OrderList.php index 5b436418c..ca84f6f11 100644 --- a/app/api/lists/order/OrderList.php +++ b/app/api/lists/order/OrderList.php @@ -51,7 +51,9 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface ->select() ->each(function ($item) { $item['goods_list'] = StoreOrderCartInfo::where('oid', $item['id']) - ->field('id,product_id,cart_num,verify_code,is_writeoff,writeoff_time,cart_info,status')->select() + ->field('id,product_id,cart_num,verify_code,is_writeoff,writeoff_time,cart_info,status') + ->limit(3) + ->select() ->each(function ($v) use ($item) { $v['store_name'] = ''; $v['image'] = ''; From 0693df434f626ce6d6cd5decc0e55f5dbddf9876 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Thu, 6 Feb 2025 16:56:57 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E8=B0=83=E8=AF=95=E8=B4=A6=E5=8D=95?= =?UTF-8?q?=E6=AC=A0=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/beforehand_order/BeforehandOrderLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index edd1f6a04..e097f3ae1 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -455,7 +455,7 @@ class BeforehandOrderLogic extends BaseLogic } BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->update(['is_buyer' => -1]); if ($order['is_arrears'] == 2) { - AccountsReceivableLogic::add($order); + AccountsReceivableLogic::add($order->toArray()); } self::confirm(['id' => $params['bhoid']]); Db::commit(); From f4d02f91aae23488989d60c4bb820cd8a269105c Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Thu, 6 Feb 2025 17:01:26 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E8=B0=83=E8=AF=95=E8=B4=A6=E5=8D=95?= =?UTF-8?q?=E6=AC=A0=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/AccountsReceivableLogic.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/admin/logic/AccountsReceivableLogic.php b/app/admin/logic/AccountsReceivableLogic.php index 0584f6b1c..2c2eaaf36 100644 --- a/app/admin/logic/AccountsReceivableLogic.php +++ b/app/admin/logic/AccountsReceivableLogic.php @@ -26,6 +26,8 @@ class AccountsReceivableLogic extends BaseLogic $model->order_id = $order['id']; $model->store_id = $order['store_id']; $model->user_id = $order['uid']; + $model->nickname = $order['other_data']['nickname']; + $model->phone = $order['other_data']['phone']; $model->deadline = time() + 86400 * 15; $model->total_debt = $order['total_price']; $model->surplus_debt = $order['total_price']; From e42568dd0375b524b0c06f93bac1a6857cc8bd59 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Thu, 6 Feb 2025 17:30:39 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E8=B0=83=E8=AF=95=E8=B4=A6=E5=8D=95?= =?UTF-8?q?=E6=AC=A0=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/AccountsReceivableLogic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/admin/logic/AccountsReceivableLogic.php b/app/admin/logic/AccountsReceivableLogic.php index 2c2eaaf36..b02c63dd7 100644 --- a/app/admin/logic/AccountsReceivableLogic.php +++ b/app/admin/logic/AccountsReceivableLogic.php @@ -26,8 +26,8 @@ class AccountsReceivableLogic extends BaseLogic $model->order_id = $order['id']; $model->store_id = $order['store_id']; $model->user_id = $order['uid']; - $model->nickname = $order['other_data']['nickname']; - $model->phone = $order['other_data']['phone']; + $model->nickname = $order['other_data']->nickname; + $model->phone = $order['other_data']->phone; $model->deadline = time() + 86400 * 15; $model->total_debt = $order['total_price']; $model->surplus_debt = $order['total_price']; From e67ae33478d266b7058c423685b9a88dbe81a0f9 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 7 Feb 2025 10:49:23 +0800 Subject: [PATCH 06/12] =?UTF-8?q?feat(warehouse):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=95=86=E5=93=81=E7=8A=B6=E6=80=81=E4=BF=AE=E6=94=B9=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=B9=B6=E4=BC=98=E5=8C=96=E5=BA=93=E5=AD=98=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 WarehouseProductStoregeController 中添加 verify 方法,用于修改商品状态 - 在 WarehouseProductStoregeLists 中添加 is_verify 字段,用于显示商品状态 - 在 BeforehandOrderLogic 中重新启用并优化库存校验逻辑,提高系统稳定性 --- .../WarehouseProductStoregeController.php | 13 +++++++++++-- .../WarehouseProductStoregeLists.php | 3 ++- .../beforehand_order/BeforehandOrderLogic.php | 19 ++++++++++--------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/app/admin/controller/warehouse_product_storege/WarehouseProductStoregeController.php b/app/admin/controller/warehouse_product_storege/WarehouseProductStoregeController.php index 103b4de6c..96e072939 100644 --- a/app/admin/controller/warehouse_product_storege/WarehouseProductStoregeController.php +++ b/app/admin/controller/warehouse_product_storege/WarehouseProductStoregeController.php @@ -7,7 +7,7 @@ use app\admin\controller\BaseAdminController; use app\admin\lists\warehouse_product_storege\WarehouseProductStoregeLists; use app\admin\logic\warehouse_product_storege\WarehouseProductStoregeLogic; use app\admin\validate\warehouse_product_storege\WarehouseProductStoregeValidate; - +use app\common\model\warehouse_product_storege\WarehouseProductStorege; /** * 仓库商品存储控制器 @@ -88,6 +88,15 @@ class WarehouseProductStoregeController extends BaseAdminController // $result = WarehouseProductStoregeLogic::detail($params); // return $this->data($result); // } - + /** + * @notes 修改商品状态 + * @return \think\response\Json + * @date 2024/05/31 10:53 + */ + public function verify(){ + $params=$this->request->post(); + WarehouseProductStorege::where('id',$params['id'])->update(['is_verify'=>$params['is_verify']]); + return $this->success('操作成功',[],1,1); + } } \ No newline at end of file diff --git a/app/admin/lists/warehouse_product_storege/WarehouseProductStoregeLists.php b/app/admin/lists/warehouse_product_storege/WarehouseProductStoregeLists.php index b5f7646cb..3e245892c 100644 --- a/app/admin/lists/warehouse_product_storege/WarehouseProductStoregeLists.php +++ b/app/admin/lists/warehouse_product_storege/WarehouseProductStoregeLists.php @@ -85,7 +85,7 @@ class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSe } } return WarehouseProductStorege::where($this->searchWhere) - ->field(['id', 'warehouse_id', 'product_id', 'nums', 'price', 'total_price', 'status']) + ->field(['id','is_verify','warehouse_id', 'product_id', 'nums', 'price', 'total_price', 'status']) ->limit($this->limitOffset, $this->limitLength) ->order($this->sortOrder) ->select()->each(function ($item) { @@ -96,6 +96,7 @@ class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSe $item->image = $find->image; $item->bar_code = $find->bar_code; $item->price = $find->price; + $item->vip_price = $find->vip_price; $item->cost = $find->cost; $item->purchase = $find->purchase; $item->store_info = $find->store_info; diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index edd1f6a04..e7bbc14ad 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -377,19 +377,20 @@ class BeforehandOrderLogic extends BaseLogic throw new BusinessException('该订单已创建出库单'); } $info = BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->select()->toArray(); - // $product_column = array_column($info, 'product_id'); - // $storege_arr=WarehouseProductStorege::where('warehouse_id', $params['warehouse_id'])->where('product_id','in',$product_column)->select(); + $product_column = array_column($info, 'product_id'); + $storege_arr=WarehouseProductStorege::where('warehouse_id', $params['warehouse_id'])->where('product_id','in',$product_column)->select(); foreach ($info as $k => $v) { if ($v['pay_price'] <= 0) { throw new BusinessException('商品价格为空 不能生成出库订单,对应id:' . $v['id']); } - // foreach ($storege_arr as $key => $value) { - // if ($value['is_verify']==1 && $v['product_id'] == $value['product_id']) { - // if ($v['cart_num'] > $value['nums']) { - // throw new BusinessException('仓库库存不足 不能生成出库订单,对应id:' . $v['id']); - // } - // } - // } + foreach ($storege_arr as $key => $value) { + if ($value['is_verify']==1 && $v['product_id'] == $value['product_id']) { + if ($v['cart_num'] < $value['nums']) { + $store_name=StoreProduct::where('id', $v['product_id'])->withTrashed()->value('store_name'); + throw new BusinessException('商品:'.$store_name.'已开启强制库存校验,库存不足,库存数量' . $value['nums'].',需求数量:' . $v['cart_num']); + } + } + } } $count = BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->where('cart_num', 0)->count('id'); if ($count > 0) { From 100a3c9f825d78e925273923611e466e58476d16 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 7 Feb 2025 11:02:18 +0800 Subject: [PATCH 07/12] =?UTF-8?q?refactor(admin):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=BA=93=E5=AD=98=E6=A0=A1=E9=AA=8C=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/beforehand_order/BeforehandOrderLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index d65b5673d..c492c2105 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -385,7 +385,7 @@ class BeforehandOrderLogic extends BaseLogic } foreach ($storege_arr as $key => $value) { if ($value['is_verify']==1 && $v['product_id'] == $value['product_id']) { - if ($v['cart_num'] < $value['nums']) { + if (($v['cart_num'] < $value['nums'])==false) { $store_name=StoreProduct::where('id', $v['product_id'])->withTrashed()->value('store_name'); throw new BusinessException('商品:'.$store_name.'已开启强制库存校验,库存不足,库存数量' . $value['nums'].',需求数量:' . $v['cart_num']); } From a1517c1aba8adfca50494a9b715a5e42f7431e00 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Fri, 7 Feb 2025 11:31:21 +0800 Subject: [PATCH 08/12] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E9=87=87=E8=B4=AD=E5=8D=95=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logic/purchase_product_offer/PurchaseProductOfferLogic.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index 1a06454eb..ca9e9a33a 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -60,9 +60,8 @@ class PurchaseProductOfferLogic extends BaseLogic if ($mark == '') { $mark = BeforehandOrderCartInfo::where('bhoid', $params['order_id'])->where('product_id', $params['product_id'])->value('mark'); } - $find = StoreProduct::where('id', $params['product_id'])->withTrashed()->find(); $purchaseProductOffer = PurchaseProductOffer::where(['order_id' => $procurementOrder['id'], 'product_id' => $params['product_id']])->find(); - if ($purchaseProductOffer) { + if (isset($params['merge_product']) && $params['merge_product'] == 1 && $purchaseProductOffer) { $purchaseProductOffer->need_num = $purchaseProductOffer['need_num'] + $params['need_num']; if (!empty($purchaseProductOffer['source_order_info'])) { $sourceOrderInfo = $purchaseProductOffer['source_order_info']; From 025a143de9028ccfaee6be1e81ebc2dfb2e79944 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Fri, 7 Feb 2025 15:20:42 +0800 Subject: [PATCH 09/12] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A2=84=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E8=BD=AC=E6=AC=A0=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BeforehandOrderController.php | 8 ++++++++ .../beforehand_order/BeforehandOrderLists.php | 2 +- .../beforehand_order/BeforehandOrderLogic.php | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/admin/controller/beforehand_order/BeforehandOrderController.php b/app/admin/controller/beforehand_order/BeforehandOrderController.php index 23295ae45..c7a40e5d4 100644 --- a/app/admin/controller/beforehand_order/BeforehandOrderController.php +++ b/app/admin/controller/beforehand_order/BeforehandOrderController.php @@ -353,5 +353,13 @@ class BeforehandOrderController extends BaseAdminController BeforehandOrderLogic::copy($params); return $this->success('复制成功'); } + + public function transfer() + { + $params = $this->request->post(); + $params['admin_id'] = $this->adminId; + BeforehandOrderLogic::transfer($params); + return $this->success('操作成功'); + } } diff --git a/app/admin/lists/beforehand_order/BeforehandOrderLists.php b/app/admin/lists/beforehand_order/BeforehandOrderLists.php index bb29f26d3..131bdea1e 100644 --- a/app/admin/lists/beforehand_order/BeforehandOrderLists.php +++ b/app/admin/lists/beforehand_order/BeforehandOrderLists.php @@ -88,7 +88,7 @@ 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', 'store_staff_id']; + $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', 'is_arrears']; $query = BeforehandOrder::where($this->searchWhere); return $query ->field($file) diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index c492c2105..63bdb3a90 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -1133,4 +1133,21 @@ class BeforehandOrderLogic extends BaseLogic } } + public static function transfer($params) + { + Db::startTrans(); + try { + $order = BeforehandOrder::where('id', $params['id'])->findOrEmpty()->toArray(); + if ($order['is_arrears'] != 1) { + throw new BusinessException('该订单已转欠款'); + } + AccountsReceivableLogic::add($order); + BeforehandOrder::where('id', $params['id'])->update(['is_arrears' => 2]); + Db::commit(); + } catch (\Exception $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + } From 0594ce6f7636d12d5767e14719afdbea4c297fc6 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 7 Feb 2025 17:31:14 +0800 Subject: [PATCH 10/12] =?UTF-8?q?feat(admin):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=88=97=E8=A1=A8=E5=92=8C=E4=BB=93=E5=BA=93?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在订单列表中添加订单号字段和按店铺ID搜索功能 - 在仓库产品列表中增加订单类型名称和相关处理逻辑 --- .../StoreOrderCartInfoLists.php | 3 ++- .../WarehouseProductLists.php | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php index b604a7f79..49ab62688 100644 --- a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php +++ b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php @@ -34,7 +34,7 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI public function setSearch(): array { return [ - '=' => ['oid','product_id','is_pay'], + '=' => ['oid','product_id','is_pay','store_id'], ]; } @@ -53,6 +53,7 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI return StoreOrderCartInfo::where($this->searchWhere) ->field('id,oid,uid,product_id,store_id,cart_num,price,total_price,create_time,refund_num,refund_amount')->limit($this->limitOffset, $this->limitLength) ->select()->each(function ($item) { + $item['order_id']=StoreOrder::where('id',$item['oid'])->value('order_id')??"";//订单号 $find=StoreProduct::where('id',$item['product_id'])->field('image,unit,store_name,store_info')->withTrashed()->find(); $item['nickname']='无'; $item['mobile']=''; diff --git a/app/admin/lists/warehouse_product/WarehouseProductLists.php b/app/admin/lists/warehouse_product/WarehouseProductLists.php index 869ed72a6..c951120b3 100644 --- a/app/admin/lists/warehouse_product/WarehouseProductLists.php +++ b/app/admin/lists/warehouse_product/WarehouseProductLists.php @@ -134,6 +134,27 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt } $item->expiration_date = $item->expiration_date ? date('Y-m-d', $item->expiration_date) : ''; $item->manufacture = $item->manufacture ? date('Y-m-d', $item->manufacture) : ''; + + if ($item->order_type == 1) { + $item->order_type_name = '铺货订单'; + } elseif ($item->order_type == 2) { + $item->order_type_name = '商贩订单'; + } elseif ($item->order_type == 3) { + $item->order_type_name = '一条龙订单'; + } elseif ($item->order_type == 4) { + $item->order_type_name = '线上订单'; + } elseif ($item->order_type == 5) { + $item->order_type_name = '仓库补货'; + $item->outbound = '无须出库'; + } elseif ($item->order_type == 6) { + $item->order_type_name = '往期补单-出库'; + } elseif ($item->order_type == 7) { + $item->order_type_name = '采购订单'; + } elseif ($item->order_type == 8) { + $item->order_type_name = '其他订单'; + }elseif ($item->order_type == 9) { + $item->order_type_name = '往期补单-入库'; + } }) ->toArray(); } From 850c06df402ded15e6d79b6eec52e6b971d69915 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 7 Feb 2025 17:46:09 +0800 Subject: [PATCH 11/12] =?UTF-8?q?fix(admin):=20=E4=BF=AE=E5=A4=8D=E4=BB=93?= =?UTF-8?q?=E5=BA=93=E4=BA=A7=E5=93=81=E6=90=9C=E7=B4=A2=E6=9C=AA=E5=8C=85?= =?UTF-8?q?=E5=90=AB=E8=BD=AF=E5=88=A0=E9=99=A4=E5=95=86=E5=93=81=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在产品名称和条形码搜索中添加 withTrashed() 方法 - 确保软删除的商品也能在仓库产品搜索结果中显示 --- app/admin/lists/warehouse_product/WarehouseProductLists.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/admin/lists/warehouse_product/WarehouseProductLists.php b/app/admin/lists/warehouse_product/WarehouseProductLists.php index c951120b3..ec0fe5d90 100644 --- a/app/admin/lists/warehouse_product/WarehouseProductLists.php +++ b/app/admin/lists/warehouse_product/WarehouseProductLists.php @@ -54,7 +54,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt { if ($this->request->get('product_id')) { $product_id = $this->request->get('product_id'); - $ids = StoreProduct::where('store_name', 'like', '%' . $product_id . '%')->column('id'); + $ids = StoreProduct::where('store_name', 'like', '%' . $product_id . '%')->withTrashed()->column('id'); if ($ids) { $this->searchWhere[] = ['product_id', 'in', $ids]; $this->ids = $ids; @@ -64,7 +64,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt } if ($this->request->get('bar_code')) { $bar_code = $this->request->get('bar_code'); - $ids = StoreProduct::where('bar_code', 'like', '%' . $bar_code . '%')->column('id'); + $ids = StoreProduct::where('bar_code', 'like', '%' . $bar_code . '%')->withTrashed()->column('id'); if ($ids) { $this->searchWhere[] = ['product_id', 'in', $ids]; $this->ids = $ids; From 31320e396156b440306140971ee0675223329b97 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Fri, 7 Feb 2025 17:54:51 +0800 Subject: [PATCH 12/12] =?UTF-8?q?=E8=B0=83=E8=AF=95=E8=B4=A6=E5=8D=95?= =?UTF-8?q?=E8=BF=98=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AccountsReceivableController.php | 10 ++- .../lists/AccountsReceivableInfoLists.php | 68 +++++++++++++++++++ app/admin/logic/AccountsReceivableLogic.php | 42 +++++++++++- 3 files changed, 116 insertions(+), 4 deletions(-) create mode 100644 app/admin/lists/AccountsReceivableInfoLists.php diff --git a/app/admin/controller/accounts_receivable/AccountsReceivableController.php b/app/admin/controller/accounts_receivable/AccountsReceivableController.php index 8359978a0..dba9a7996 100644 --- a/app/admin/controller/accounts_receivable/AccountsReceivableController.php +++ b/app/admin/controller/accounts_receivable/AccountsReceivableController.php @@ -3,6 +3,7 @@ namespace app\admin\controller\accounts_receivable; use app\admin\controller\BaseAdminController; +use app\admin\lists\AccountsReceivableInfoLists; use app\admin\lists\AccountsReceivableLists; use app\admin\logic\AccountsReceivableLogic; use app\admin\validate\app_update\AppUpdateValidate; @@ -21,10 +22,10 @@ class AccountsReceivableController extends BaseAdminController public function edit() { - $params = (new AppUpdateValidate())->post()->goCheck('edit'); + $params = $this->request->post(); $result = AccountsReceivableLogic::edit($params); if (true === $result) { - return $this->success('编辑成功', [], 1, 1); + return $this->success('操作成功', [], 1, 1); } return $this->fail(AccountsReceivableLogic::getError()); } @@ -43,4 +44,9 @@ class AccountsReceivableController extends BaseAdminController return $this->data($result); } + public function record() + { + return $this->dataLists(new AccountsReceivableInfoLists()); + } + } \ No newline at end of file diff --git a/app/admin/lists/AccountsReceivableInfoLists.php b/app/admin/lists/AccountsReceivableInfoLists.php new file mode 100644 index 000000000..e5e78c2cf --- /dev/null +++ b/app/admin/lists/AccountsReceivableInfoLists.php @@ -0,0 +1,68 @@ + ['accounts_receivable_id'], + ]; + } + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function lists(): array + { + $query = AccountsReceivableInfo::where($this->searchWhere); + $list = $query + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + $accountReceivable = AccountsReceivable::field('id,store_id,nickname')->where('id', $this->params['accounts_receivable_id'])->findOrEmpty()->toArray(); + $store = SystemStore::where('id', $accountReceivable['store_id'])->value('name'); + $payTypeMap = [ + 1 => '现金', + 2 => '微信支付', + 3 => '支付宝支付', + 4 => '对公账号', + 5 => '其他' + ]; + foreach ($list as &$item) { + $item['store_name'] = $store; + $item['pay_type_name'] = $payTypeMap[$item['pay_type']]; + $item['nickname'] = $accountReceivable['nickname']; + } + return $list; + } + + /** + * @notes 获取数量 + * @return int + */ + public function count(): int + { + $query = AccountsReceivableInfo::where($this->searchWhere); + return $query->count(); + } + +} \ No newline at end of file diff --git a/app/admin/logic/AccountsReceivableLogic.php b/app/admin/logic/AccountsReceivableLogic.php index b02c63dd7..9098dda9f 100644 --- a/app/admin/logic/AccountsReceivableLogic.php +++ b/app/admin/logic/AccountsReceivableLogic.php @@ -2,10 +2,9 @@ namespace app\admin\logic; -use app\common\model\ActivityZone; use app\common\logic\BaseLogic; -use app\common\model\ActivityZoneForm; use app\common\model\finance\AccountsReceivable; +use app\common\model\finance\AccountsReceivableInfo; use support\exception\BusinessException; use think\facade\Db; @@ -34,4 +33,43 @@ class AccountsReceivableLogic extends BaseLogic $model->save(); } + public static function edit($params) + { + Db::startTrans(); + try { + $accountsReceivable = AccountsReceivable::where(['id' => $params['accounts_receivable_id']])->find(); + if ($accountsReceivable->surplus_debt <= 0) { + throw new BusinessException('该账单已支付'); + } + $surplusDebt = bcsub($accountsReceivable->surplus_debt, $params['pay_debt'], 2); + $model = new AccountsReceivableInfo(); + $model->accounts_receivable_id = $params['accounts_receivable_id']; + $model->pay_type = $params['pay_type']; + $model->total_debt = $params['surplus_debt']; + $model->pay_debt = $params['pay_debt']; + $model->recipient = $params['recipient']; + $model->surplus_debt = $surplusDebt; + $model->file = $params['file']; + $model->mark = $params['mark']; + if (!$model->save()) { + throw new BusinessException('添加失败'); + } + $accountsReceivable->pay_debt = bcadd($accountsReceivable->pay_debt, $params['pay_debt'], 2); + $accountsReceivable->surplus_debt = $surplusDebt; + if (!$accountsReceivable->save()) { + throw new BusinessException('更新账单出错'); + } + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + + public static function record($params) + { + + } + } \ No newline at end of file