|
|
|
@ -43,10 +43,11 @@ class DepositRecordRepository extends BaseRepository |
|
|
|
|
$this->dao = $dao; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function create($uid, int $depositId, string $type) |
|
|
|
|
public function create($uid, $price, int $depositId, string $type) |
|
|
|
|
{ |
|
|
|
|
return $this->dao->create([ |
|
|
|
|
'uid' => $uid, |
|
|
|
|
'price' => $price, |
|
|
|
|
'deposit_id' => $depositId, |
|
|
|
|
'deposit_type' => $type, |
|
|
|
|
'order_id' => $this->dao->createOrderId($uid) |
|
|
|
@ -76,7 +77,7 @@ class DepositRecordRepository extends BaseRepository |
|
|
|
|
if (in_array($type, ['weixin', 'alipay'], true) && $isApp) { |
|
|
|
|
$type .= 'App'; |
|
|
|
|
} |
|
|
|
|
$service = new PayService($type, $depositRecord->getPayParams($type === 'alipay' ? $return_url : ''),'deposit_record'); |
|
|
|
|
$service = new PayService($type, $depositRecord->getPayParams($type === 'alipay' ? $return_url : ''),'user_recharge'); |
|
|
|
|
$config = $service->pay($user); |
|
|
|
|
return $config + ['deposit_id' => $depositRecord['deposit_id'], 'type' => $type]; |
|
|
|
|
} |
|
|
|
@ -93,32 +94,14 @@ class DepositRecordRepository extends BaseRepository |
|
|
|
|
*/ |
|
|
|
|
public function paySuccess($orderId) |
|
|
|
|
{ |
|
|
|
|
$recharge = $this->dao->getWhere(['order_id' => $orderId]); |
|
|
|
|
if ($recharge->paid == 1) return; |
|
|
|
|
$recharge->paid = 1; |
|
|
|
|
$recharge->pay_time = date('Y-m-d H:i:s'); |
|
|
|
|
$record = $this->dao->getWhere(['order_id' => $orderId]); |
|
|
|
|
if (empty($record) or $record->status != 0) return; |
|
|
|
|
$record->status = 1; |
|
|
|
|
|
|
|
|
|
Db::transaction(function () use ($recharge) { |
|
|
|
|
$price = bcadd($recharge->price, $recharge->give_price, 2); |
|
|
|
|
$mark = '成功充值余额' . floatval($recharge->price) . '元' . ($recharge->give_price > 0 ? ',赠送' . $recharge->give_price . '元' : ''); |
|
|
|
|
app()->make(UserBillRepository::class)->incBill($recharge->user->uid, 'now_money', 'recharge', [ |
|
|
|
|
'link_id' => $recharge->recharge_id, |
|
|
|
|
'status' => 1, |
|
|
|
|
'title' => '余额充值', |
|
|
|
|
'number' => $price, |
|
|
|
|
'mark' => $mark, |
|
|
|
|
'balance' => bcadd($recharge->user->now_money, $price, 2) |
|
|
|
|
]); |
|
|
|
|
$recharge->user->now_money = bcadd($recharge->user->now_money, $price, 2); |
|
|
|
|
$recharge->user->save(); |
|
|
|
|
$recharge->save(); |
|
|
|
|
Db::transaction(function () use ($record) { |
|
|
|
|
$record->save(); |
|
|
|
|
app(UserRepository::class)->update($record['uid'],['is_lottery' => 1]); |
|
|
|
|
}); |
|
|
|
|
Queue::push(SendSmsJob::class,['tempId' => 'USER_BALANCE_CHANGE', 'id' =>$orderId]); |
|
|
|
|
|
|
|
|
|
//小程序发货管理 |
|
|
|
|
event('mini_order_shipping', ['recharge', $recharge, 3, '', '']); |
|
|
|
|
|
|
|
|
|
event('user.recharge',compact('recharge')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getSum($uid, $field){ |
|
|
|
|