|
@@ -296,7 +296,7 @@ class User extends BaseModel
|
|
|
if (!$userInfo || !$userInfo['spread_uid'] || $userInfo['spread_uid'] == $orderInfo['uid']) return true;
|
|
|
if (!User::be(['uid' => $userInfo['spread_uid'], 'is_promoter' => 1])) return self::backOrderBrokerageTwo($orderInfo, $open);
|
|
|
$cartId = is_string($orderInfo['cart_id']) ? json_decode($orderInfo['cart_id'], true) : $orderInfo['cart_id'];
|
|
|
- list($realBrokeragePrice, $virtualBrokeragePrice) = StoreProduct::getProductBrokerage($userInfo['spread_uid'],$cartId);
|
|
|
+ list($realBrokeragePrice, $virtualBrokeragePrice) = StoreProduct::getProductBrokerage($userInfo['uid'],$userInfo['spread_uid'],$cartId);
|
|
|
//TODO 返佣金额小于等于0 直接返回不返佣金
|
|
|
if ($realBrokeragePrice <= 0 && $virtualBrokeragePrice <= 0) return true;
|
|
|
//TODO 获取上级推广员信息
|
|
@@ -316,56 +316,112 @@ class User extends BaseModel
|
|
|
}
|
|
|
if ($realBrokeragePrice > 0) {
|
|
|
$spreadUserInfo = User::getUserInfo($userInfo['spread_uid']);
|
|
|
+ $order_count = StoreOrder::where('uid', $userInfo['uid'])->where('paid' , 1)->count();
|
|
|
+
|
|
|
|
|
|
//TODO 上级推广员返佣之后的金额
|
|
|
|
|
|
//TODO 添加推广记录
|
|
|
- $brokerage_price = $realBrokeragePrice * 0.95;// 到账佣金
|
|
|
- $integral = $realBrokeragePrice * 0.05;// 到账积分
|
|
|
-
|
|
|
- $mark = $userInfo['nickname'] . '成功消费[实体产品]' . floatval($orderInfo['pay_price']) . '元,奖励推广佣金' . floatval($brokerage_price);
|
|
|
- $mark1 = $userInfo['nickname'] . '成功消费[实体产品]' . floatval($orderInfo['pay_price']) . '元,奖励推广积分' . floatval($integral);
|
|
|
-
|
|
|
+ if ($order_count < 2){
|
|
|
+ $brokerage_price = $realBrokeragePrice * 0.95;// 到账佣金
|
|
|
+ $integral = $realBrokeragePrice * 0.05;// 到账积分
|
|
|
+
|
|
|
+ $mark = $userInfo['nickname'] . '成功消费[实体产品]' . floatval($orderInfo['pay_price']) . '元,奖励推广佣金' . floatval($brokerage_price);
|
|
|
+ $mark1 = $userInfo['nickname'] . '成功消费[实体产品]' . floatval($orderInfo['pay_price']) . '元,奖励推广积分' . floatval($integral);
|
|
|
+
|
|
|
+
|
|
|
+ $res = UserBill::income('获得推广佣金', $userInfo['spread_uid'], 'now_money', 'brokerage', $brokerage_price, $orderInfo['id'], $spreadUserInfo['brokerage_price'] + $brokerage_price, $mark);
|
|
|
+ $res = UserBill::income('获得推广积分', $userInfo['spread_uid'], 'integral', 'push', $integral, $orderInfo['id'], $spreadUserInfo['integral'] + $integral, $mark1);
|
|
|
+
|
|
|
+ $res2 = self::bcInc($userInfo['spread_uid'], 'brokerage_price', $brokerage_price, 'uid');
|
|
|
+ $res2 = self::bcInc($userInfo['spread_uid'], 'integral', $integral, 'uid');
|
|
|
+
|
|
|
+ if ($spreadUserInfo['identity'] == 1){
|
|
|
+ $uid = getParent($userInfo['spread_uid'],User::select()); //找到最上级
|
|
|
+ if (count($uid) > 0){
|
|
|
+ $uid1 = array_pop($uid);
|
|
|
+ $user1 = User::where('uid', $uid1)->find();
|
|
|
+ if ($user1['line'] >= 3){
|
|
|
+ $amministrazione = User::where('uid', $user1['spread_uid'])->find();// 发放管理奖
|
|
|
+ if ($amministrazione){
|
|
|
+ $brokerage_price = $realBrokeragePrice * 0.95;// 到账佣金
|
|
|
+ $integral = $realBrokeragePrice * 0.05;// 到账积分
|
|
|
+
|
|
|
+ UserBill::income('获得推广佣金', $uid1, 'now_money', 'brokerage', $brokerage_price, $orderInfo['id'], $amministrazione['brokerage_price'] + $brokerage_price, '管理佣金奖励');
|
|
|
+ UserBill::income('获得推广积分', $uid1, 'integral', 'Level', $integral, $orderInfo['id'], $amministrazione['integral'] + $integral, '管理积分奖励');
|
|
|
+ self::bcInc($uid1, 'brokerage_price', $brokerage_price, 'uid'); //发放管理奖
|
|
|
+ self::bcInc($uid1, 'integral', $integral, 'uid'); //发放管理奖
|
|
|
+ self::livello($amministrazione['spread_uid'], $realBrokeragePrice);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }elseif ($spreadUserInfo['identity'] == 2){
|
|
|
+ self::livello($spreadUserInfo['spread_uid'], $realBrokeragePrice);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $brokerage_price = $realBrokeragePrice * 0.95;// 到账佣金
|
|
|
+ $integral = $realBrokeragePrice * 0.05;// 到账积分
|
|
|
|
|
|
- $res = UserBill::income('获得推广佣金', $userInfo['spread_uid'], 'now_money', 'brokerage', $brokerage_price, $orderInfo['id'], $spreadUserInfo['brokerage_price'] + $brokerage_price, $mark);
|
|
|
- $res = UserBill::income('获得推广积分', $userInfo['spread_uid'], 'integral', 'push', $integral, $orderInfo['id'], $spreadUserInfo['integral'] + $integral, $mark1);
|
|
|
+ $mark = $userInfo['nickname'] . '复购成功消费[实体产品]' . floatval($orderInfo['pay_price']) . '元,奖励推广佣金' . floatval($brokerage_price);
|
|
|
+ $mark1 = $userInfo['nickname'] . '复购成功消费[实体产品]' . floatval($orderInfo['pay_price']) . '元,奖励推广积分' . floatval($integral);
|
|
|
|
|
|
- $res2 = self::bcInc($userInfo['spread_uid'], 'brokerage_price', $brokerage_price, 'uid');
|
|
|
- $res2 = self::bcInc($userInfo['spread_uid'], 'integral', $integral, 'uid');
|
|
|
|
|
|
+ $res = UserBill::income('获得推广佣金', $userInfo['spread_uid'], 'now_money', 'brokerage', $brokerage_price, $orderInfo['id'], $spreadUserInfo['brokerage_price'] + $brokerage_price, $mark);
|
|
|
+ $res = UserBill::income('获得推广积分', $userInfo['spread_uid'], 'integral', 'push', $integral, $orderInfo['id'], $spreadUserInfo['integral'] + $integral, $mark1);
|
|
|
|
|
|
- $uid = getParent($userInfo['spread_uid'],User::select());
|
|
|
- if (count($uid) >= 2){
|
|
|
- $uid1 = array_pop($uid);
|
|
|
- $uid2 = array_pop($uid);
|
|
|
- $user1 = User::where('uid', $uid1)->find();
|
|
|
- $user2 = User::where('uid', $uid2)->find();
|
|
|
- if ($user1['identity'] == 2){
|
|
|
- $brokerage_price = ($orderInfo['pay_price'] * sys_config('shopowner')/100 * 0.7) * 0.3 * 0.95;// 到账佣金
|
|
|
- $integral = ($orderInfo['pay_price'] * sys_config('shopowner')/100 * 0.7) * 0.3 * 0.05;// 到账积分
|
|
|
+ $res2 = self::bcInc($userInfo['spread_uid'], 'brokerage_price', $brokerage_price, 'uid');
|
|
|
+ $res2 = self::bcInc($userInfo['spread_uid'], 'integral', $integral, 'uid');
|
|
|
+ }
|
|
|
|
|
|
- UserBill::income('获得推广佣金', $uid1, 'now_money', 'brokerage', $brokerage_price, $orderInfo['id'], $user1['brokerage_price'] + $brokerage_price, '店长平级佣金奖励');
|
|
|
- UserBill::income('获得推广积分', $uid1, 'integral', 'Level', $integral, $orderInfo['id'], $user1['integral'] + $integral, '店长平级积分奖励');
|
|
|
- self::bcInc($uid1, 'brokerage_price', $brokerage_price, 'uid'); //那二代店长业绩的百分之30
|
|
|
- self::bcInc($uid1, 'integral', $integral, 'uid'); //那二代店长业绩的百分之30
|
|
|
- }
|
|
|
- if ($user2['identity'] == 2){
|
|
|
- $brokerage_price = ($orderInfo['pay_price'] * sys_config('shopowner')/100 * 0.7) * 0.95;// 到账佣金
|
|
|
- $integral = ($orderInfo['pay_price'] * sys_config('shopowner')/100 * 0.7) * 0.05;// 到账积分
|
|
|
|
|
|
|
|
|
- UserBill::income('获得推广佣金', $uid2, 'now_money', 'brokerage', $brokerage_price, $orderInfo['id'], $user2['brokerage_price'] + $brokerage_price, '店长平级佣金奖励');
|
|
|
- UserBill::income('获得推广积分', $uid2, 'integral', 'Level', $integral, $orderInfo['id'], $user2['brokerage_price'] + $integral, '店长平级积分奖励');
|
|
|
- self::bcInc($uid2, 'brokerage_price',$brokerage_price, 'uid'); //那二代店长业绩的百分之30
|
|
|
- self::bcInc($uid2, 'brokerage_price', $integral, 'uid'); //那二代店长业绩的百分之30
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
// $res = $res && self::backOrderBrokerageTwo($orderInfo);
|
|
|
// $open && self::checkTrans($res);
|
|
|
return $res;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 平级奖励
|
|
|
+ * @param $uid
|
|
|
+ * @param $price
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public static function livello($uid, $price)
|
|
|
+ {
|
|
|
+ $uids = getParent_livello( $uid, User::select());
|
|
|
+
|
|
|
+ if (count($uids) > 0){
|
|
|
+ // 第一级店长
|
|
|
+ if (isset($uids[0])){
|
|
|
+ $user = User::where('uid', $uids[0])->find();
|
|
|
+ $price1 = $price * 0.7;
|
|
|
+ $brokerage_price = $price1 * 0.95;// 到账佣金
|
|
|
+ $integral = $price1 * 0.05;// 到账积分
|
|
|
+
|
|
|
+ UserBill::income('获得推广佣金', $user['uid'], 'now_money', 'brokerage', $brokerage_price, '', $user['brokerage_price'] + $brokerage_price, '店长平级佣金奖励');
|
|
|
+ UserBill::income('获得推广积分', $user['uid'], 'integral', 'Level', $integral, '', $user['integral'] + $integral, '店长平级积分奖励');
|
|
|
+ self::bcInc($user['uid'], 'brokerage_price', $brokerage_price, 'uid'); //发放管理奖
|
|
|
+ self::bcInc($user['uid'], 'integral', $integral, 'uid'); //发放管理奖
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($uids[1])){
|
|
|
+ // 第二级店长
|
|
|
+ $user = User::where('uid', $uids[1])->find();
|
|
|
+ $price2 = $price * 0.3;
|
|
|
+ $brokerage_price = $price2 * 0.95;// 到账佣金
|
|
|
+ $integral = $price2 * 0.05;// 到账积分
|
|
|
+
|
|
|
+ UserBill::income('获得推广佣金', $user['uid'], 'now_money', 'brokerage', $brokerage_price, '', $user['brokerage_price'] + $brokerage_price, '店长平级佣金奖励');
|
|
|
+ UserBill::income('获得推广积分', $user['uid'], 'integral', 'Level', $integral, '', $user['integral'] + $integral, '店长平级积分奖励');
|
|
|
+ self::bcInc($user['uid'], 'brokerage_price', $brokerage_price, 'uid'); //发放管理奖
|
|
|
+ self::bcInc($user['uid'], 'integral', $integral, 'uid'); //发放管理奖
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* TODO 二级推广
|
|
|
* @param $orderInfo
|