master
wangxinglong 2022-03-16 15:29:14 +08:00
parent 415b90e801
commit baa35bdbf7
1 changed files with 11 additions and 8 deletions

View File

@ -371,9 +371,17 @@ class Coupon extends Base
$deductionAmount = (($couponMain->deduction_money / 100) * $couponMain->commission_dis_distribution);
//是否开启分销 并且有分销人 给分销人发红包
if($couponMain->business->is_assign == BusinessModel::COMMON_ON && !empty($distributionUserCode))
if(
$couponMain->business->is_assign == BusinessModel::COMMON_OFF
&&
!empty($distributionUserCode)
)
{
$distributionUser = Account::findOne([["user_code","=",$distributionUserCode]]);
if(empty($distributionUser)){
Db::rollback();
return $this->json(4001,"分享人不存在");
}
// 2. 写入优惠券流水
$couponBillData = [
"coupon_main_id" => $couponMain->id,
@ -399,12 +407,7 @@ class Coupon extends Base
$amount = round($deductionAmount,2); //四舍五入 精确到分
CouponBill::create($couponBillData);
$distributionUser = Account::findOne([["user_code","=",$distributionUserCode]]);
if(empty($distributionUser)){
Db::rollback();
return $this->json(4001,"分享人不存在");
}
$payment = WechatPay::getInstance();
$distributionRedpack = Redpack::getDistributionRedpack($distributionUserCode,$couponMainId,$account->user_code);
//如果付款过一次了 就用同一个订单号发起