From 0b7d0b21a6cf3b273afef5de30773d43b33bc9ba Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Wed, 5 Feb 2025 11:07:19 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BC=9A=E5=91=98?= =?UTF-8?q?=E5=85=85=E5=80=BC=E6=B5=81=E6=B0=B4=E5=86=99=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index a576278eb..3db446c56 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -501,8 +501,10 @@ class PayNotifyLogic extends BaseLogic if ($order['other_uid'] > 0) { $uid = $order['other_uid']; } - $cashFlowLogic = new CashFlowLogic(); - $cashFlowLogic->insert($order['store_id'], $order['price'],$orderSn); + if ($type == 'wechat') { + $cashFlowLogic = new CashFlowLogic(); + $cashFlowLogic->insert($order['store_id'], $order['price'],$orderSn); + } PushService::push('wechat_mmp_' . $uid, $uid, ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]); PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]); From 5e1f639f633ba3856c2b6055e3f7d56eeac52107 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Wed, 5 Feb 2025 11:15:40 +0800 Subject: [PATCH 2/6] =?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 --- .../AccountsReceivableController.php | 46 +++++++ app/admin/lists/AccountsReceivableLists.php | 60 +++++++++ app/admin/logic/AccountsReceivableLogic.php | 122 ++++++++++++++++++ .../beforehand_order/BeforehandOrderLogic.php | 5 + .../model/finance/AccountsReceivable.php | 20 +++ .../model/finance/AccountsReceivableInfo.php | 14 ++ 6 files changed, 267 insertions(+) create mode 100644 app/admin/controller/accounts_receivable/AccountsReceivableController.php create mode 100644 app/admin/lists/AccountsReceivableLists.php create mode 100644 app/admin/logic/AccountsReceivableLogic.php create mode 100644 app/common/model/finance/AccountsReceivable.php create mode 100644 app/common/model/finance/AccountsReceivableInfo.php diff --git a/app/admin/controller/accounts_receivable/AccountsReceivableController.php b/app/admin/controller/accounts_receivable/AccountsReceivableController.php new file mode 100644 index 000000000..8359978a0 --- /dev/null +++ b/app/admin/controller/accounts_receivable/AccountsReceivableController.php @@ -0,0 +1,46 @@ +dataLists(new AccountsReceivableLists()); + } + + public function edit() + { + $params = (new AppUpdateValidate())->post()->goCheck('edit'); + $result = AccountsReceivableLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(AccountsReceivableLogic::getError()); + } + + public function delete() + { + $params = (new AppUpdateValidate())->post()->goCheck('delete'); + AccountsReceivableLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + public function detail() + { + $params = (new AppUpdateValidate())->goCheck('detail'); + $result = AccountsReceivableLogic::detail($params); + return $this->data($result); + } + +} \ No newline at end of file diff --git a/app/admin/lists/AccountsReceivableLists.php b/app/admin/lists/AccountsReceivableLists.php new file mode 100644 index 000000000..16a6b70f0 --- /dev/null +++ b/app/admin/lists/AccountsReceivableLists.php @@ -0,0 +1,60 @@ + ['store_id', 'user_id'], + ]; + } + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function lists(): array + { + $query = AccountsReceivable::where($this->searchWhere); + if (!empty($this->params['order_sn'])) { + $orderIds = BeforehandOrder::where('order_id', 'like', '%' . $this->params['order_sn'] . '%')->column('id'); + $query->whereIn('order_id', $orderIds); + } + return $query + ->with('info') + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + /** + * @notes 获取数量 + * @return int + */ + public function count(): int + { + $query = AccountsReceivable::where($this->searchWhere); + if (!empty($this->params['order_sn'])) { + $orderIds = BeforehandOrder::where('order_id', 'like', '%' . $this->params['order_sn'] . '%')->column('id'); + $query->whereIn('order_id', $orderIds); + } + return $query->count(); + } + +} \ No newline at end of file diff --git a/app/admin/logic/AccountsReceivableLogic.php b/app/admin/logic/AccountsReceivableLogic.php new file mode 100644 index 000000000..2e363e7e0 --- /dev/null +++ b/app/admin/logic/AccountsReceivableLogic.php @@ -0,0 +1,122 @@ +order_id = $order['id']; + $model->store_id = $order['store_id']; + $model->user_id = $order['uid']; + $model->deadline = time() + 86400 * 15; + $model->total_debt = $order['total_price']; + $model->surplus_debt = $order['total_price']; + $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 diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index 214111352..5feb71975 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -2,6 +2,7 @@ namespace app\admin\logic\beforehand_order; +use app\admin\logic\AccountsReceivableLogic; use app\admin\logic\store_branch_product\StoreBranchProductLogic; use app\admin\logic\store_product\StoreProductLogic; use app\admin\logic\warehouse_product\WarehouseProductLogic; @@ -127,6 +128,7 @@ class BeforehandOrderLogic extends BaseLogic 'address' => $params['address'] ?? '', 'mark' => $params['mark'] ?? '', 'order_type' => $order_type, + 'is_arrears' => $params['is_arrears'] ?? 1, 'other_data' => json_encode($params['other_data'], true) ]); /** 添加审批记录 */ @@ -441,6 +443,9 @@ class BeforehandOrderLogic extends BaseLogic throw new BusinessException('出库失败,预订单更新出错'); } BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->update(['is_buyer' => -1]); + if ($order['is_arrears'] == 2) { + AccountsReceivableLogic::add($order); + } self::confirm(['id' => $params['bhoid']]); Db::commit(); return true; diff --git a/app/common/model/finance/AccountsReceivable.php b/app/common/model/finance/AccountsReceivable.php new file mode 100644 index 000000000..1747c8d94 --- /dev/null +++ b/app/common/model/finance/AccountsReceivable.php @@ -0,0 +1,20 @@ +hasMany(AccountsReceivableInfo::class, 'accounts_receivable_id', 'id'); + } + +} diff --git a/app/common/model/finance/AccountsReceivableInfo.php b/app/common/model/finance/AccountsReceivableInfo.php new file mode 100644 index 000000000..b5c469f41 --- /dev/null +++ b/app/common/model/finance/AccountsReceivableInfo.php @@ -0,0 +1,14 @@ + Date: Wed, 5 Feb 2025 11:23:55 +0800 Subject: [PATCH 3/6] =?UTF-8?q?refactor(admin):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=89=8D=E7=BD=AE=E8=AE=A2=E5=8D=95=E5=87=BA=E5=BA=93=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 BeforehandOrderCartInfo 的查询结果转换为数组,以便后续处理 - 注释掉的代码片段显示了库存验证的逻辑,但已被移除 - 移除了冗余的库存验证逻辑,简化了订单处理流程 --- .../logic/beforehand_order/BeforehandOrderLogic.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index de88b04fc..27b5b6c4d 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -29,6 +29,7 @@ use app\common\model\user_ship\UserShip; use app\common\model\warehouse_order\WarehouseOrder; use app\common\model\warehouse_product\WarehouseProduct; use app\common\model\warehouse_product_return\WarehouseProductReturn; +use app\common\model\warehouse_product_storege\WarehouseProductStorege; use app\common\service\xlsx\OrderAllocation; use app\common\service\xlsx\OrderInfo; use app\common\service\xlsx\OrderList; @@ -373,11 +374,20 @@ class BeforehandOrderLogic extends BaseLogic if ($order['outbound_id'] > 0) { throw new BusinessException('该订单已创建出库单'); } - $info = BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->select(); + $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(); 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']); + // } + // } + // } } $count = BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->where('cart_num', 0)->count('id'); if ($count > 0) { From 6bbd2253022b544ffd9a5d8a827c1e48273878b5 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 5 Feb 2025 11:39:30 +0800 Subject: [PATCH 4/6] =?UTF-8?q?refactor(purchase):=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E9=A2=84=E5=94=AE=E8=AE=A2=E5=8D=95=E4=B8=AD=E4=B8=8D=E5=BF=85?= =?UTF-8?q?=E8=A6=81=E7=9A=84=E4=BA=A7=E5=93=81=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 注释掉 BeforehandOrderLogic、BeforehandOrderCartInfoLogic 和 PurchaseProductOfferLogic 中的多余属性 - 移除 marques、store_info、after_sales、loss、gross_weight 和 net_weight 等不再使用的变量 - 优化代码结构,提高代码可读性和维护性 --- .../beforehand_order/BeforehandOrderLogic.php | 54 +++++++++---------- .../BeforehandOrderCartInfoLogic.php | 24 ++++----- .../PurchaseProductOfferLogic.php | 8 +-- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index f8271fe06..edd1f6a04 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -94,13 +94,13 @@ class BeforehandOrderLogic extends BaseLogic $datas[$k]['mark'] = $v['mark'] ?? ''; $datas[$k]['product_id'] = $v['product_id']; $datas[$k]['uid'] = $uid; - $datas[$k]['marques'] = $v['marques'] ?? ''; - $datas[$k]['store_info'] = $v['store_info'] ?? ''; - $datas[$k]['after_sales'] = $v['after_sales'] ?? ''; - $datas[$k]['loss'] = $v['loss'] ?? ''; + // $datas[$k]['marques'] = $v['marques'] ?? ''; + // $datas[$k]['store_info'] = $v['store_info'] ?? ''; + // $datas[$k]['after_sales'] = $v['after_sales'] ?? ''; + // $datas[$k]['loss'] = $v['loss'] ?? ''; $datas[$k]['unit'] = $v['unit'] ?? ''; - $datas[$k]['gross_weight'] = $v['gross_weight'] ?? ''; - $datas[$k]['net_weight'] = $v['net_weight'] ?? ''; + // $datas[$k]['gross_weight'] = $v['gross_weight'] ?? ''; + // $datas[$k]['net_weight'] = $v['net_weight'] ?? ''; $datas[$k]['cart_num'] = $v['nums']; $datas[$k]['accept_num'] = $v['nums']; $datas[$k]['is_buyer'] = $is_buyer; @@ -140,27 +140,27 @@ class BeforehandOrderLogic extends BaseLogic $datas[$k]['bhoid'] = $order['id']; $data['id'] = $v['product_id']; - if ($v['marques'] != '') { - $data['marques'] = $v['marques']; - } - if ($v['store_info'] != '') { - $data['store_info'] = $v['store_info']; - } - if ($v['after_sales'] != '') { - $data['after_sales'] = $v['after_sales']; - } - if ($v['package'] != '') { - $data['package'] = $v['package']; - } - if ($v['loss'] != '') { - $data['loss'] = $v['loss']; - } - if ($v['gross_weight'] != '') { - $data['gross_weight'] = $v['gross_weight']; - } - if ($v['net_weight'] != '') { - $data['net_weight'] = $v['net_weight']; - } + // if ($v['marques'] != '') { + // $data['marques'] = $v['marques']; + // } + // if ($v['store_info'] != '') { + // $data['store_info'] = $v['store_info']; + // } + // if ($v['after_sales'] != '') { + // $data['after_sales'] = $v['after_sales']; + // } + // if ($v['package'] != '') { + // $data['package'] = $v['package']; + // } + // if ($v['loss'] != '') { + // $data['loss'] = $v['loss']; + // } + // if ($v['gross_weight'] != '') { + // $data['gross_weight'] = $v['gross_weight']; + // } + // if ($v['net_weight'] != '') { + // $data['net_weight'] = $v['net_weight']; + // } $product_arr[] = $data; } (new StoreProduct())->saveAll($product_arr); diff --git a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php index 309a94515..7f2e74f97 100644 --- a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php +++ b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php @@ -240,18 +240,18 @@ class BeforehandOrderCartInfoLogic extends BaseLogic $data['manufacture'] = $v['manufacture'] > 0 ? date('Y-m-d H:i:s', $v['manufacture']) : ''; $data['expiration_date'] = $v['expiration_date'] > 0 ? date('Y-m-d H:i:s', $v['expiration_date']) : ''; $product_arr=[]; - if($v['package']!=''){ - $product_arr['package']=$v['package']; - } - if($v['store_info']!=''){ - $product_arr['store_info']=$v['store_info']; - } - if($v['marques']!=''){ - $product_arr['marques']=$v['marques']; - } - if($v['after_sales']!=''){ - $product_arr['after_sales']=$v['after_sales']; - } + // if($v['package']!=''){ + // $product_arr['package']=$v['package']; + // } + // if($v['store_info']!=''){ + // $product_arr['store_info']=$v['store_info']; + // } + // if($v['marques']!=''){ + // $product_arr['marques']=$v['marques']; + // } + // if($v['after_sales']!=''){ + // $product_arr['after_sales']=$v['after_sales']; + // } if($product_arr!=[]){ StoreProduct::where('id',$v['product_id'])->save($product_arr); } diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index 8dc233dcc..44d94db5a 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -84,10 +84,10 @@ class PurchaseProductOfferLogic extends BaseLogic 'need_num' => $params['need_num'], 'mark' => $mark, 'buyer_id' => $params['buyer_id'], - 'package' => $find['package'], - 'store_info' => $find['store_info'], - 'marques' => $find['marques'], - 'after_sales' => $find['after_sales'], + // 'package' => $find['package'], + // 'store_info' => $find['store_info'], + // 'marques' => $find['marques'], + // 'after_sales' => $find['after_sales'], 'status' => 0, 'source_order_info' => [ [ From 541e752573b6fc3444ac187e36e41d4ede824e39 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Wed, 5 Feb 2025 14:09:29 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BC=9A=E5=91=98?= =?UTF-8?q?=E5=85=85=E5=80=BC=E6=B5=81=E6=B0=B4=E5=86=99=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index cbcbd9d44..e560ac23f 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -501,7 +501,7 @@ class PayNotifyLogic extends BaseLogic if ($order['other_uid'] > 0) { $uid = $order['other_uid']; } - if ($type == 'wechat') { + if ($type != 'wechat') { $cashFlowLogic = new CashFlowLogic(); $cashFlowLogic->insert($order['store_id'], $order['price'], $orderSn); } From 405eebb6426ac07bd916bbc140b6ed22cf397d45 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Wed, 5 Feb 2025 17:44:31 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E9=87=87=E8=B4=AD=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BeforehandOrderController.php | 7 +- app/admin/lists/AccountsReceivableLists.php | 16 ++++- .../PurchaseProductOfferLogic.php | 69 +++++++++++++++++++ 3 files changed, 89 insertions(+), 3 deletions(-) diff --git a/app/admin/controller/beforehand_order/BeforehandOrderController.php b/app/admin/controller/beforehand_order/BeforehandOrderController.php index 1dbb0f96e..23295ae45 100644 --- a/app/admin/controller/beforehand_order/BeforehandOrderController.php +++ b/app/admin/controller/beforehand_order/BeforehandOrderController.php @@ -8,6 +8,7 @@ use app\admin\lists\beforehand_order\BeforehandOrderLists; use app\admin\lists\beforehand_order\BeforehandOrderTwoLists; use app\admin\lists\beforehand_order\BeforehandOrderThreeLists; use app\admin\logic\beforehand_order\BeforehandOrderLogic; +use app\admin\logic\purchase_product_offer\PurchaseProductOfferLogic; use app\common\model\beforehand_order\BeforehandOrder; use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo; use app\common\model\store_order\StoreOrder; @@ -83,7 +84,11 @@ class BeforehandOrderController extends BaseAdminController 'regional_manager' => $params['regional_manager'] ?? '', ]; $params['other_data'] = $other_data; - $result = BeforehandOrderLogic::add($params); + if ($params['order_type'] == 7) { + PurchaseProductOfferLogic::batchCreate($params); + } else { + BeforehandOrderLogic::add($params); + } return $this->success('添加成功', [], 1, 1); } /** diff --git a/app/admin/lists/AccountsReceivableLists.php b/app/admin/lists/AccountsReceivableLists.php index 16a6b70f0..6634da2f3 100644 --- a/app/admin/lists/AccountsReceivableLists.php +++ b/app/admin/lists/AccountsReceivableLists.php @@ -5,6 +5,9 @@ namespace app\admin\lists; 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 @@ -35,12 +38,21 @@ class AccountsReceivableLists extends BaseAdminDataLists implements ListsSearchI $orderIds = BeforehandOrder::where('order_id', 'like', '%' . $this->params['order_sn'] . '%')->column('id'); $query->whereIn('order_id', $orderIds); } - return $query - ->with('info') + $list = $query->with('info') ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select() ->toArray(); + $stores = SystemStore::field('id,name')->whereIn('id', array_column($list, 'store_id'))->select()->toArray(); + $stores = reset_index($stores, 'id'); + $orderInfo = BeforehandOrder::field('id,order_id')->whereIn('id', array_column($list, 'order_id'))->select()->toArray(); + $orderInfo = reset_index($orderInfo, 'id'); + $orderInfo = reset_index($orderInfo, 'id'); + foreach ($list as &$item) { + $item['store_name'] = $stores[$item['store_id']]['name']; + $item['order_sn'] = $orderInfo[$item['order_id']]['order_id']; + } + return $list; } /** diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index 44d94db5a..1a06454eb 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -488,4 +488,73 @@ class PurchaseProductOfferLogic extends BaseLogic } return $res; } + + public static function batchCreate($params) + { + if (empty($params['buyer_id'])) { + throw new BusinessException('请选择采购员'); + } + Db::startTrans(); + try { + $procurementOrder = new BeforehandOrder(); + $procurementOrder->order_id = getNewOrderId('CG'); + $procurementOrder->buyer_id = $params['buyer_id']; + $procurementOrder->admin_id = $params['admin_id']; + $procurementOrder->order_type = 7; + $procurementOrder->total_price = 0; + $procurementOrder->pay_price = 0; + $procurementOrder->save(); + $purchaseOffer = []; + $cartInfo = []; + foreach ($params['product_arr'] as $product) { + if ($product['product_id'] <= 0) { + continue; + } + $cartInfo[] = [ + 'bhoid' => $procurementOrder['id'], + 'product_id' => $product['product_id'], + 'unit' => $product['unit'], + 'cart_num' => $product['nums'], + 'accept_num' => $product['nums'], + 'mark' => $product['mark'], + 'is_buyer' => 1, + 'procurement_order_id' => $procurementOrder['id'], + 'total_price' => bcmul($product['price'], $product['nums'], 2), + 'pay_price' => bcmul($product['price'], $product['nums'], 2), + 'purchase' => $product['purchase'], + 'uid' => $params['uid'], + 'price' => $product['price'], + 'package' => $product['package'], + 'create_time' => time(), + 'update_time' => time(), + ]; + $purchaseOffer[] = [ + 'order_id' => $procurementOrder['id'], + 'product_id' => $product['product_id'], + 'unit' => $product['unit'], + 'is_buyer' => 1, + 'need_num' => $product['nums'], + 'mark' => $product['mark'], + 'buyer_id' => $params['buyer_id'], + 'status' => 0, + 'source_order_info' => [ + [ + 'source_order_id' => $procurementOrder['id'], + 'product_id' => $product['product_id'], + 'need_num' => $product['nums'], + 'mark' => $product['mark'], + ] + ] + ]; + } + PurchaseProductOffer::insertAll($purchaseOffer); + BeforehandOrderCartInfo::insertAll($cartInfo); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + }