|
|
|
@ -80,7 +80,7 @@ class StoreOrderRepository extends BaseRepository |
|
|
|
|
const TYPE_SN_PRESELL = 'wxp'; |
|
|
|
|
const TYPE_SN_USER_ORDER = 'wxs'; |
|
|
|
|
const TYPE_SN_USER_RECHARGE = 'wxu'; |
|
|
|
|
|
|
|
|
|
public $pay_type_2; |
|
|
|
|
const TYPE_SN_REFUND = 'rwx'; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -101,11 +101,11 @@ class StoreOrderRepository extends BaseRepository |
|
|
|
|
* @author xaboy |
|
|
|
|
* @day 2020/10/22 |
|
|
|
|
*/ |
|
|
|
|
public function pay(string $type, User $user, StoreGroupOrder $groupOrder, $return_url = '', $isApp = false) |
|
|
|
|
public function pay(string $type, User $user, StoreGroupOrder $groupOrder, $return_url = '', $isApp = false, $pay_type_2 = '') |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
if ($type === 'balance') { |
|
|
|
|
return $this->payBalance($user, $groupOrder); |
|
|
|
|
return $this->payBalance($user, $groupOrder, $pay_type_2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (in_array($type, ['weixin', 'alipay'], true) && $isApp) { |
|
|
|
@ -128,27 +128,34 @@ class StoreOrderRepository extends BaseRepository |
|
|
|
|
* @author xaboy |
|
|
|
|
* @day 2020/6/9 |
|
|
|
|
*/ |
|
|
|
|
public function payBalance(User $user, StoreGroupOrder $groupOrder) |
|
|
|
|
public function payBalance(User $user, StoreGroupOrder $groupOrder, $pay_type_2 = '') |
|
|
|
|
{ |
|
|
|
|
$this->pay_type_2 = $pay_type_2; |
|
|
|
|
if (!systemConfig('yue_pay_status')) |
|
|
|
|
throw new ValidateException('未开启余额支付'); |
|
|
|
|
if ($user['now_money'] < $groupOrder['pay_price']) |
|
|
|
|
if ($user['now_money'] < $groupOrder['pay_price'] && $pay_type_2 != 1) |
|
|
|
|
throw new ValidateException('余额不足,请更换支付方式'); |
|
|
|
|
Db::transaction(function () use ($user, $groupOrder) { |
|
|
|
|
$user->now_money = bcsub($user->now_money, $groupOrder['pay_price'], 2); |
|
|
|
|
$user->save(); |
|
|
|
|
$userBillRepository = app()->make(UserBillRepository::class); |
|
|
|
|
|
|
|
|
|
$memo = '余额支付支付' . floatval($groupOrder['pay_price']) . '元购买商品'; |
|
|
|
|
if ($this->pay_type_2 == 1) { |
|
|
|
|
$memo = '线下支付' . floatval($groupOrder['pay_price']) . '元购买商品'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$userBillRepository->decBill($user['uid'], 'now_money', 'pay_product', [ |
|
|
|
|
'link_id' => $groupOrder['group_order_id'], |
|
|
|
|
'status' => 1, |
|
|
|
|
'title' => '购买商品', |
|
|
|
|
'number' => $groupOrder['pay_price'], |
|
|
|
|
'mark' => '余额支付支付' . floatval($groupOrder['pay_price']) . '元购买商品', |
|
|
|
|
'mark' => $memo, |
|
|
|
|
'balance' => $user->now_money |
|
|
|
|
]); |
|
|
|
|
$this->paySuccess($groupOrder); |
|
|
|
|
}); |
|
|
|
|
return app('json')->status('success', '余额支付成功', ['order_id' => $groupOrder['group_order_id']]); |
|
|
|
|
return app('json')->status('success', '支付成功', ['order_id' => $groupOrder['group_order_id']]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function changePayType(StoreGroupOrder $groupOrder, int $pay_type) |
|
|
|
@ -193,6 +200,8 @@ class StoreOrderRepository extends BaseRepository |
|
|
|
|
$groupOrder->paid = 1; |
|
|
|
|
$groupOrder->pay_time = $time; |
|
|
|
|
$groupOrder->is_combine = $is_combine; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$orderStatus = []; |
|
|
|
|
$groupOrder->append(['orderList.orderProduct']); |
|
|
|
|
$flag = true; |
|
|
|
|