mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-01-04 02:48:14 +00:00
二级返佣修复
This commit is contained in:
parent
09c33e3200
commit
bdc219ec1c
@ -91,6 +91,10 @@ class User extends ModelBasic
|
|||||||
return $uid;
|
return $uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** //TODO 一级返佣
|
||||||
|
* @param $orderInfo
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public static function backOrderBrokerage($orderInfo)
|
public static function backOrderBrokerage($orderInfo)
|
||||||
{
|
{
|
||||||
$userInfo = User::getUserInfo($orderInfo['uid']);
|
$userInfo = User::getUserInfo($orderInfo['uid']);
|
||||||
@ -102,6 +106,7 @@ class User extends ModelBasic
|
|||||||
$brokerageRatio = (SystemConfigService::get('store_brokerage_ratio') ?: 0)/100;
|
$brokerageRatio = (SystemConfigService::get('store_brokerage_ratio') ?: 0)/100;
|
||||||
if($brokerageRatio <= 0) return true;
|
if($brokerageRatio <= 0) return true;
|
||||||
$cost = isset($orderInfo['cost']) ? $orderInfo['cost'] : 0;//成本价
|
$cost = isset($orderInfo['cost']) ? $orderInfo['cost'] : 0;//成本价
|
||||||
|
if($cost > $orderInfo['pay_price']) return true;//成本价大于支付价格时直接返回
|
||||||
$brokeragePrice = bcmul(bcsub($orderInfo['pay_price'],$cost,2),$brokerageRatio,2);
|
$brokeragePrice = bcmul(bcsub($orderInfo['pay_price'],$cost,2),$brokerageRatio,2);
|
||||||
if($brokeragePrice <= 0) return true;
|
if($brokeragePrice <= 0) return true;
|
||||||
$mark = $userInfo['nickname'].'成功消费'.floatval($orderInfo['pay_price']).'元,奖励推广佣金'.floatval($brokeragePrice);
|
$mark = $userInfo['nickname'].'成功消费'.floatval($orderInfo['pay_price']).'元,奖励推广佣金'.floatval($brokeragePrice);
|
||||||
@ -110,6 +115,35 @@ class User extends ModelBasic
|
|||||||
$res2 = self::bcInc($userInfo['spread_uid'],'now_money',$brokeragePrice,'uid');
|
$res2 = self::bcInc($userInfo['spread_uid'],'now_money',$brokeragePrice,'uid');
|
||||||
$res = $res1 && $res2;
|
$res = $res1 && $res2;
|
||||||
self::checkTrans($res);
|
self::checkTrans($res);
|
||||||
|
if($res) self::backOrderBrokerageTwo($orderInfo);
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* //TODO 二级推广
|
||||||
|
* @param $orderInfo
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
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_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;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
composer.lock
generated
10
composer.lock
generated
@ -871,16 +871,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "topthink/framework",
|
"name": "topthink/framework",
|
||||||
"version": "v5.0.21",
|
"version": "v5.0.23",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/top-think/framework.git",
|
"url": "https://github.com/top-think/framework.git",
|
||||||
"reference": "ab826da071a7a47116a7f1d01f72228d6bcf212a"
|
"reference": "4cbc0b5e93314446243ebc7d5f005f9c32864737"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/top-think/framework/zipball/ab826da071a7a47116a7f1d01f72228d6bcf212a",
|
"url": "https://api.github.com/repos/top-think/framework/zipball/4cbc0b5e93314446243ebc7d5f005f9c32864737",
|
||||||
"reference": "ab826da071a7a47116a7f1d01f72228d6bcf212a",
|
"reference": "4cbc0b5e93314446243ebc7d5f005f9c32864737",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -918,7 +918,7 @@
|
|||||||
"orm",
|
"orm",
|
||||||
"thinkphp"
|
"thinkphp"
|
||||||
],
|
],
|
||||||
"time": "2018-09-04T09:18:48+00:00"
|
"time": "2018-12-09T12:40:40+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "topthink/think-captcha",
|
"name": "topthink/think-captcha",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user