|
@@ -682,6 +682,42 @@ class StoreOrder extends BaseModel
|
|
|
return $res;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 佣金支付
|
|
|
+ * @param $order_id
|
|
|
+ * @param $uid
|
|
|
+ * @param string $formId
|
|
|
+ * @return bool
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws DataNotFoundException
|
|
|
+ * @throws ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
+ public static function brokerage($order_id, $uid, $formId = '')
|
|
|
+ {
|
|
|
+ $orderInfo = self::where('uid', $uid)->where('order_id', $order_id)->where('is_del', 0)->find();
|
|
|
+ if (!$orderInfo) return self::setErrorInfo('订单不存在!');
|
|
|
+ if ($orderInfo['paid']) return self::setErrorInfo('该订单已支付!');
|
|
|
+// if($orderInfo['pay_type'] != 'yue') return self::setErrorInfo('该订单不能使用余额支付!');
|
|
|
+ $userInfo = User::getUserInfo($uid);
|
|
|
+ if ($userInfo['now_money'] < $orderInfo['brokerage_price'])
|
|
|
+ return self::setErrorInfo(['status' => 'pay_deficiency', 'msg' => '佣金不足' . floatval($orderInfo['pay_price'])]);
|
|
|
+ self::beginTrans();
|
|
|
+
|
|
|
+ $res1 = false !== User::bcDec($uid, 'brokerage_price', $orderInfo['pay_price'], 'uid');
|
|
|
+ $res2 = UserBill::expend('购买商品', $uid, 'now_money', 'brokerage_price', $orderInfo['pay_price'], $orderInfo['id'], $userInfo['now_money'], '佣金支付' . floatval($orderInfo['pay_price']) . '元购买商品');
|
|
|
+ $res3 = self::paySuccess($order_id, 'brokerage', $formId);//佣金支付成功
|
|
|
+ try {
|
|
|
+ PaymentRepositories::yuePayProduct($userInfo, $orderInfo);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ self::rollbackTrans();
|
|
|
+ return self::setErrorInfo($e->getMessage());
|
|
|
+ }
|
|
|
+ $res = $res1 && $res2 && $res3;
|
|
|
+ self::checkTrans($res);
|
|
|
+ return $res;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 微信支付 为 0元时
|
|
|
* @param $order_id
|