setter
parent
b32a6edb78
commit
5ac15caa86
|
@ -595,8 +595,6 @@ class Coupon extends Base
|
|||
$deductionMoney = $coupon->couponMain->deduction_money;
|
||||
|
||||
|
||||
|
||||
|
||||
//可分配金额 如果是普通商家
|
||||
if($business->model == BusinessModel::model_ordinary) {
|
||||
$agencyMoney = (($deductionMoney/100) * $coupon->couponMain->commission_agency);
|
||||
|
@ -614,6 +612,8 @@ class Coupon extends Base
|
|||
||
|
||||
(!empty($coupon->distribution_user_code)&&$coupon->is_distribution_coupon == CouponMain::COMMON_ON)
|
||||
){
|
||||
$redpackUser = Account::findOne([["user_code","=",$coupon->distribution_user_code]]);
|
||||
|
||||
$disAdminMoney = (($deductionMoney/100) * $coupon->couponMain->commission_dis_admin);
|
||||
//$disDistributionMoney = (($deductionMoney/100) * $coupon->couponMain->commission_dis_distribution);
|
||||
$disDistributedMoney = (($deductionMoney/100) * $coupon->couponMain->commission_dis_distributed);
|
||||
|
@ -622,9 +622,23 @@ class Coupon extends Base
|
|||
$adminMoney = round($disAdminMoney,2); //四舍五入 精确到分
|
||||
//$disDistributionMoney = round($disDistributionMoney,2); //四舍五入 精确到分
|
||||
$consumerMoney = round($disDistributedMoney,2); //四舍五入 精确到分
|
||||
}else{
|
||||
$redpackUser = $account;
|
||||
}
|
||||
|
||||
}else{
|
||||
//开启了分销 覆盖 平台应得金额 和消费者应得金额 并且取消 渠道商打款
|
||||
if(
|
||||
$business->is_assign == BusinessModel::COMMON_OFF
|
||||
||
|
||||
(!empty($coupon->distribution_user_code)&&$coupon->is_distribution_coupon == CouponMain::COMMON_ON)
|
||||
){
|
||||
$redpackUser = Account::findOne([["user_code","=",$coupon->distribution_user_code]]);
|
||||
}else{
|
||||
$redpackUser = $account;
|
||||
}
|
||||
|
||||
|
||||
$adminMoney = 0;
|
||||
$consumerMoney = round($deductionMoney,2) ;
|
||||
$agencyMoney = 0; //四舍五入 精确到分
|
||||
|
@ -772,8 +786,8 @@ class Coupon extends Base
|
|||
|
||||
|
||||
|
||||
//6. 用户提现到零钱 写入红包记录
|
||||
if($consumerMoney > 0){
|
||||
//6. 分销者用户提现到零钱 写入红包记录
|
||||
if($consumerMoney > 0 && !empty($redpackUser)){
|
||||
//如果付款过一次了 就查询付款状态
|
||||
if(isset($coupon->redpack) && $coupon->redpack){
|
||||
$mch_billno = $coupon->redpack->mch_billno;
|
||||
|
@ -798,7 +812,7 @@ class Coupon extends Base
|
|||
|
||||
$toBalanceData = [
|
||||
'partner_trade_no' => $mch_billno,// 商户订单号,需保持唯一性(只能是字母或者数字,不能包含有符号)
|
||||
'openid' => $account->open_id,
|
||||
'openid' => $redpackUser->open_id,
|
||||
'check_name' => 'NO_CHECK',// NO_CHECK:不校验真实姓名, FORCE_CHECK:强校验真实姓名
|
||||
'amount' => $amount, //单位为分,不小于300
|
||||
'desc' => '验证优惠券签到奖励',
|
||||
|
@ -808,8 +822,8 @@ class Coupon extends Base
|
|||
$redpackData = [
|
||||
"coupon_id" => $coupon->id,
|
||||
"mch_billno" => $mch_billno,
|
||||
"openid" => $account->open_id,
|
||||
"user_code" => $account->user_code,
|
||||
"openid" => $redpackUser->open_id,
|
||||
"user_code" => $redpackUser->user_code,
|
||||
"money" => $amount, //单位为分,不小于300
|
||||
"create_time" => date("Y-m-d H:i:s",$time),
|
||||
"pay_time" => '0000-00-00 00:00:00',
|
||||
|
@ -843,6 +857,7 @@ class Coupon extends Base
|
|||
Redpack::create($redpackData);
|
||||
return $this->json(5003, "验证失败,发放红包失败");
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return $this->json();
|
||||
|
||||
|
@ -854,8 +869,6 @@ class Coupon extends Base
|
|||
Db::rollback();
|
||||
return $this->json(5002, "服务器错误");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* 发布优惠券
|
||||
|
|
Loading…
Reference in New Issue