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/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/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/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/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/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/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..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; @@ -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(); } 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/AccountsReceivableLogic.php b/app/admin/logic/AccountsReceivableLogic.php index 2e363e7e0..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; @@ -26,97 +25,51 @@ 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']; $model->save(); } - - /** - * @notes 编辑 - * @param array $params - * @return bool - * @author admin - * @date 2024/12/20 10:52 - */ - public static function edit(array $params): bool + public static function edit($params) { Db::startTrans(); try { - ActivityZone::where('id', $params['id'])->update([ - 'form_id' => $params['form_id'], - 'product_id' => $params['product_id'], - ]); - + $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 (\Throwable $e) { + } catch (\Exception $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 + public static function record($params) { - 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 edd1f6a04..63bdb3a90 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'])==false) { + $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) { @@ -455,7 +456,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(); @@ -1132,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()); + } + } + } 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']; 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'] = '';