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()); + } + } + }