From 545e01e75a33a2036d350996845f8223e1bc5874 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Sat, 15 Jun 2024 10:49:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=87=87=E8=B4=AD=E6=AC=BE?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E6=96=B9=E5=BC=8F=E5=92=8C=E9=A2=84=E7=95=99?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=86=E4=BA=AB=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/order/OrderController.php | 4 ++ app/api/logic/order/OrderLogic.php | 3 ++ app/common/enum/OrderEnum.php | 3 ++ app/common/enum/PayEnum.php | 3 +- app/common/logic/PayNotifyLogic.php | 37 ++++++++++++++++++- .../model/user_spread_log/UserSpreadLog.php | 22 +++++++++++ .../store_order/StoreOrderController.php | 4 ++ 7 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 app/common/model/user_spread_log/UserSpreadLog.php diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index c8a6a62c..a436e98f 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -188,6 +188,10 @@ class OrderController extends BaseApiController } if ($order != false) { switch ($pay_type) { + case PayEnum::PURCHASE_FUNDS: + //采购款支付 + PayNotifyLogic::handle('purchase_funds', $order['order_id']); + return $this->success('采购款支付成功'); case PayEnum::BALANCE_PAY: //余额支付 PayNotifyLogic::handle('balancePay', $order['order_id']); diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 895a42e0..1f422b03 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -23,6 +23,7 @@ use app\common\model\system_store\SystemStoreStaff; use app\common\model\user\User; use app\common\model\user\UserAddress; use app\common\model\user\UserShip; +use app\common\model\user_spread_log\UserSpreadLog; use Picqer\Barcode\BarcodeGeneratorJPG; use Picqer\Barcode\BarcodeGeneratorPNG; use support\exception\BusinessException; @@ -160,6 +161,8 @@ class OrderLogic extends BaseLogic $_order = $orderInfo['order']; $_order['uid'] = request()->userId; $user = User::where('id', \request()->userId)->find(); + $_order['is_vip'] = $user['user_ship']; + $_order['spread_uid'] = UserSpreadLog::where('uid',request()->userId)->value('old_spread_uid')??0;//预留分享关系 $_order['real_name'] = $user['real_name']; $_order['mobile'] = $user['mobile']; $_order['pay_type'] = $orderInfo['order']['pay_type']; diff --git a/app/common/enum/OrderEnum.php b/app/common/enum/OrderEnum.php index 21516293..e8312c82 100644 --- a/app/common/enum/OrderEnum.php +++ b/app/common/enum/OrderEnum.php @@ -24,6 +24,7 @@ class OrderEnum * @SYSTEM_SET 系统设置 * @OWN_GET 平台收入 * @ORDER_MARGIN 商户保证金 + * @PURCHASE_FUNDS 采购款收银 */ const USER_ORDER_PAY = 1; const MERCHANT_ORDER_OBTAINS = 2; @@ -44,6 +45,8 @@ class OrderEnum const CASHIER_FACE_PAY = 17;//现金收银 + const PURCHASE_FUNDS = 18;//采购款收银 + /** * 收入支出类型 diff --git a/app/common/enum/PayEnum.php b/app/common/enum/PayEnum.php index 8065e8fa..99786c42 100644 --- a/app/common/enum/PayEnum.php +++ b/app/common/enum/PayEnum.php @@ -31,6 +31,7 @@ class PayEnum * @GOODS_FIRST_PAYMENT_LATER 先货后款 * @CORPORATE_TRANSFER 对公转账 * @CASH_PAY 现金支付 + * @PURCHASE_FUNDS 采购款收银 */ const BALANCE_PAY = 3; const WECHAT_PAY = 1; @@ -49,7 +50,7 @@ class PayEnum const GOODS_FIRST_PAYMENT_LATER = 15; const CORPORATE_TRANSFER = 16; const CASH_PAY = 17; - + const PURCHASE_FUNDS = 18;//采购款收银 //支付状态 const UNPAID = 0; //未支付 const ISPAID = 1; //已支付 diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 6bb5f81e..82e4e1c3 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -32,7 +32,7 @@ class PayNotifyLogic extends BaseLogic { Db::startTrans(); try { - if ($action != 'cash_pay' && $action != 'balancePay') { + if ($action != 'cash_pay' && $action != 'balancePay'&& $action != 'purchase_funds') { $payNotifyLogLogic = new PayNotifyLogLogic(); if ($action == 'refund') { $payNotifyLogLogic->insert($action, $extra, PayNotifyLog::TYPE_REFUND); @@ -83,6 +83,41 @@ class PayNotifyLogic extends BaseLogic PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); } + + /** + * 采购款支付 + * @param $orderSn + * @param $extra + * @return void + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public static function purchase_funds($orderSn, $extra = []) + { + $order = StoreOrder::where('order_id', $orderSn)->findOrEmpty(); + $user = User::where('id', $order['uid'])->find(); + if ($user['purchase_funds'] < $order['pay_price']) { + throw new \Exception('采购款不足'); + } + $order->money = $order['pay_price']; + $order->paid = 1; + $order->pay_time = time(); + if (!$order->save()) { + throw new \Exception('订单保存出错'); + } + // 减去采购款 + $user->purchase_funds = bcsub($user['purchase_funds'], $order['pay_price'], 2); + $user->save(); + + $capitalFlowDao = new CapitalFlowLogic($user); + $capitalFlowDao->userExpense('user_order_pay', 'order', $order['id'], $order['pay_price']); + self::afterPay($order); + Redis::send('push-platform-print', ['id' => $order['id']], 60); + PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); + + } + /** * @notes 微信通用回调 * @param $orderSn diff --git a/app/common/model/user_spread_log/UserSpreadLog.php b/app/common/model/user_spread_log/UserSpreadLog.php new file mode 100644 index 00000000..6ac54de1 --- /dev/null +++ b/app/common/model/user_spread_log/UserSpreadLog.php @@ -0,0 +1,22 @@ +success('采购款支付成功'); case PayEnum::CASH_PAY: //现金支付