|
|
@@ -110,6 +110,29 @@ class User extends ModelBasic
|
|
|
$res2 = self::bcInc($userInfo['spread_uid'],'now_money',$brokeragePrice,'uid');
|
|
|
$res = $res1 && $res2;
|
|
|
self::checkTrans($res);
|
|
|
+ if(res) self::backOrderBrokerageTwo($orderInfo);
|
|
|
+ return $res;
|
|
|
+ }
|
|
|
+ public static function backOrderBrokerageTwo($orderInfo){
|
|
|
+ $userInfo = User::getUserInfo($orderInfo['uid']);
|
|
|
+ $userInfoTwo = User::getUserInfo($userInfo['spread_uid']);
|
|
|
+ if(!$userInfoTwo || !$userInfoTwo['spread_uid']) return true;
|
|
|
+ $storeBrokerageStatu = SystemConfigService::get('store_brokerage_statu') ? : 1;//获取后台分销类型
|
|
|
+ if($storeBrokerageStatu == 1){
|
|
|
+ if(!User::be(['uid'=>$userInfoTwo['spread_uid'],'is_promoter'=>1])) return true;
|
|
|
+ }
|
|
|
+ $brokerageRatio = (SystemConfigService::get('store_brokerage_ratio_two') ?: 0)/100;
|
|
|
+ if($brokerageRatio <= 0) return true;
|
|
|
+ $cost = isset($orderInfo['cost']) ? $orderInfo['cost'] : 0;//成本价
|
|
|
+ if($cost > $orderInfo['pay_price']) return true;//成本价大于支付价格时直接返回
|
|
|
+ $brokeragePrice = bcmul(bcsub($orderInfo['pay_price'],$cost,2),$brokerageRatio,2);
|
|
|
+ if($brokeragePrice <= 0) return true;
|
|
|
+ $mark = '二级推广人'.$userInfo['nickname'].'成功消费'.floatval($orderInfo['pay_price']).'元,奖励推广佣金'.floatval($brokeragePrice);
|
|
|
+ self::beginTrans();
|
|
|
+ $res1 = UserBill::income('获得推广佣金',$userInfoTwo['spread_uid'],'now_money','brokerage',$brokeragePrice,$orderInfo['id'],0,$mark);
|
|
|
+ $res2 = self::bcInc($userInfoTwo['spread_uid'],'now_money',$brokeragePrice,'uid');
|
|
|
+ $res = $res1 && $res2;
|
|
|
+ self::checkTrans($res);
|
|
|
return $res;
|
|
|
}
|
|
|
|