|
@@ -982,21 +982,8 @@ class StoreOrder extends BaseModel
|
|
|
// $parent_level_info = $parent_level_info->toArray();
|
|
// $parent_level_info = $parent_level_info->toArray();
|
|
|
// if ()
|
|
// if ()
|
|
|
// }
|
|
// }
|
|
|
- @file_put_contents('quanju.txt', json_encode($level_info) . "-等级信息\r\n", 8);
|
|
|
|
|
-
|
|
|
|
|
- if ($parentLevel > $level_info['grade']) { //如果上上级等级小于上级,就直接跳过
|
|
|
|
|
- if ($user['spread_uid'] > 0) {
|
|
|
|
|
- self::processRebate($order, $user['spread_uid'], $parentLevel, $parentBrokerage);
|
|
|
|
|
- }
|
|
|
|
|
- } elseif ($parentLevel == $level_info['grade']) { //如果上上级等级等于上级,就获取上级佣金的10%
|
|
|
|
|
-
|
|
|
|
|
- $userPeerLevel = sys_config('user_peer_level', 10);
|
|
|
|
|
- if ($userPeerLevel > 0) {
|
|
|
|
|
- $userPeerLevel = bcmul($userPeerLevel, 0.01, 2);
|
|
|
|
|
- $brokerage = bcmul($parentBrokerage, $userPeerLevel, 2);
|
|
|
|
|
- }
|
|
|
|
|
- } elseif ($parentLevel < $parentLevel['grade']) { //如果上上级等级大于上级,就获取自己等级返利的佣金
|
|
|
|
|
-// StoreProductLevel::where('product_id',$)
|
|
|
|
|
|
|
+ $spread_uid = User::where('uid', $order['uid'])->value(['spread_uid']);
|
|
|
|
|
+ if ($spread_uid == $uid) { //如果订单用户上级uid和传参的uid相同说明是第一层
|
|
|
$shopping_cart = $order['cart_id'];
|
|
$shopping_cart = $order['cart_id'];
|
|
|
// 先不考虑什么商品返现比例了
|
|
// 先不考虑什么商品返现比例了
|
|
|
foreach ($shopping_cart as $cart) {
|
|
foreach ($shopping_cart as $cart) {
|
|
@@ -1004,7 +991,7 @@ class StoreOrder extends BaseModel
|
|
|
$product_radio = 0;
|
|
$product_radio = 0;
|
|
|
$product_info = StoreCart::where('id', $cart)->find()->toArray();
|
|
$product_info = StoreCart::where('id', $cart)->find()->toArray();
|
|
|
|
|
|
|
|
- $product = StoreProductLevel::where('id', $product_info['product_id'])->where('level_id', $user['level'])->where('type',1)->find(); //商品返现比例
|
|
|
|
|
|
|
+ $product = StoreProductLevel::where('id', $product_info['product_id'])->where('level_id', $user['level'])->where('type', 1)->find(); //商品返现比例
|
|
|
if (!empty($product)) {
|
|
if (!empty($product)) {
|
|
|
$product = $product->toArray();
|
|
$product = $product->toArray();
|
|
|
$product_radio = $product['rebate_ratio'];
|
|
$product_radio = $product['rebate_ratio'];
|
|
@@ -1021,7 +1008,50 @@ class StoreOrder extends BaseModel
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ } else {
|
|
|
|
|
+
|
|
|
|
|
+ @file_put_contents('quanju.txt', json_encode($level_info) . "-等级信息\r\n", 8);
|
|
|
|
|
+
|
|
|
|
|
+ if ($parentLevel > $level_info['grade']) { //如果上上级等级小于上级,就直接跳过
|
|
|
|
|
+ if ($user['spread_uid'] > 0) {
|
|
|
|
|
+ self::processRebate($order, $user['spread_uid'], $parentLevel, $parentBrokerage);
|
|
|
|
|
+ }
|
|
|
|
|
+ } elseif ($parentLevel == $level_info['grade']) { //如果上上级等级等于上级,就获取上级佣金的10%
|
|
|
|
|
+
|
|
|
|
|
+ $userPeerLevel = sys_config('user_peer_level', 10);
|
|
|
|
|
+ if ($userPeerLevel > 0) {
|
|
|
|
|
+ $userPeerLevel = bcmul($userPeerLevel, 0.01, 2);
|
|
|
|
|
+ $brokerage = bcmul($parentBrokerage, $userPeerLevel, 2);
|
|
|
|
|
+ }
|
|
|
|
|
+ } elseif ($parentLevel < $parentLevel['grade']) { //如果上上级等级大于上级,就获取自己等级返利的佣金
|
|
|
|
|
+// StoreProductLevel::where('product_id',$)
|
|
|
|
|
+ $shopping_cart = $order['cart_id'];
|
|
|
|
|
+// 先不考虑什么商品返现比例了
|
|
|
|
|
+ foreach ($shopping_cart as $cart) {
|
|
|
|
|
+// @file_put_contents('quanju4.txt', $cart . "-购物车id2\r\n", 8);
|
|
|
|
|
+ $product_radio = 0;
|
|
|
|
|
+ $product_info = StoreCart::where('id', $cart)->find()->toArray();
|
|
|
|
|
+
|
|
|
|
|
+ $product = StoreProductLevel::where('id', $product_info['product_id'])->where('level_id', $user['level'])->where('type', 1)->find(); //商品返现比例
|
|
|
|
|
+ if (!empty($product)) {
|
|
|
|
|
+ $product = $product->toArray();
|
|
|
|
|
+ $product_radio = $product['rebate_ratio'];
|
|
|
|
|
+ }
|
|
|
|
|
+// @file_put_contents('quanju.txt', json_encode($product_info) . "-购物车信息\r\n", 8);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if ($product_radio > 0) {
|
|
|
|
|
+// if ($user_radio>0){
|
|
|
|
|
+ $product_price = StoreProduct::where('id', $product_info['product_id'])->value('price');
|
|
|
|
|
+ $rebate = bcmul($product_price, bcdiv($product_radio, 100, 2), 2); //商品返现金额
|
|
|
|
|
+ $brokerage = bcadd($brokerage, $rebate, 2);
|
|
|
|
|
+// }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
// }
|
|
// }
|
|
|
@file_put_contents('quanju.txt', $brokerage . "-返利佣金金额\r\n", 8);
|
|
@file_put_contents('quanju.txt', $brokerage . "-返利佣金金额\r\n", 8);
|
|
|
|
|
|
|
@@ -1039,7 +1069,7 @@ class StoreOrder extends BaseModel
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
if ($user['spread_uid'] > 0) {
|
|
if ($user['spread_uid'] > 0) {
|
|
|
- self::processRebate($order, $user['spread_uid'], $level_info['grade'],$brokerage);
|
|
|
|
|
|
|
+ self::processRebate($order, $user['spread_uid'], $level_info['grade'], $brokerage);
|
|
|
} else {
|
|
} else {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|