master
wangxinglong 2022-02-08 16:13:04 +08:00
parent 87671f10d6
commit 6e245814a4
1 changed files with 6 additions and 4 deletions

View File

@ -392,7 +392,7 @@ class Coupon extends Base
}
$coupon = CouponRepository::getInstance()->findById($couponId,[],function ($q){
return $q->with(["couponMain","redpack"]);
return $q->with(["couponMain","redpack"])->lock(true);
});
if(empty($coupon)){
@ -597,7 +597,7 @@ class Coupon extends Base
"create_time" => date("Y-m-d H:i:s",$time),
"pay_time" => '0000-00-00 00:00:00',
];
$redpack = Redpack::create($redpackData);
//发起支付
//$result = $payment->transfer->toBalance($toBalanceData);
@ -606,8 +606,7 @@ class Coupon extends Base
//付款成功才提交!!!!!伪装成功
if( true || isset($result['payment_no']) ){
$redpack->pay_time = date("Y-m-d H:i:s",$time);
$redpack->save();
$redpackData['pay_time'] = date("Y-m-d H:i:s",$time);
Db::commit();
return $this->json(
@ -622,6 +621,9 @@ class Coupon extends Base
//默认回滚
Db::rollback();
Redpack::create($redpackData);
return $this->json(5003, "验证失败,发放红包失败");
}
Db::commit();