|
|
@@ -152,12 +152,12 @@ class StoreOrder extends BaseModel
|
|
|
}
|
|
|
if ($storeFreePostage <= $totalPrice) $storePostage = 0;//如果总价大于等于满额包邮 邮费等于0
|
|
|
|
|
|
- if ($temp['collect_on_delivery']==1){
|
|
|
+ if ($temp['collect_on_delivery'] == 1) {
|
|
|
$storePostage = 0;
|
|
|
$collect_on_delivery = 1;
|
|
|
}
|
|
|
}
|
|
|
- return compact('storePostage', 'storeFreePostage', 'totalPrice', 'costPrice', 'vipPrice', 'totalIntegral','collect_on_delivery');
|
|
|
+ return compact('storePostage', 'storeFreePostage', 'totalPrice', 'costPrice', 'vipPrice', 'totalIntegral', 'collect_on_delivery');
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -302,7 +302,7 @@ class StoreOrder extends BaseModel
|
|
|
$payPrice = (float)$priceGroup['totalPrice'];
|
|
|
$payIntegral = (float)$priceGroup['totalIntegral'];
|
|
|
$addr = UserAddress::where('uid', $uid)->where('id', $addressId)->find();
|
|
|
- $collect_on_delivery=0;
|
|
|
+ $collect_on_delivery = 0;
|
|
|
if ($payType == 'offline' && sys_config('offline_postage') == 1) {
|
|
|
$payPostage = 0;
|
|
|
} else {
|
|
|
@@ -557,20 +557,20 @@ class StoreOrder extends BaseModel
|
|
|
$total_num = 0;
|
|
|
$total_price = 0;
|
|
|
$deduction_price = 0;
|
|
|
- @file_put_contents('quanju4.txt', json_encode($v)."-测试1\r\n", 8);
|
|
|
+ @file_put_contents('quanju4.txt', json_encode($v) . "-测试1\r\n", 8);
|
|
|
|
|
|
$cartInfo = StoreCart::where('id', 'in', $v['ids'])->select();
|
|
|
- @file_put_contents('quanju4.txt', json_encode($cartInfo)."-测试5\r\n", 8);
|
|
|
+ @file_put_contents('quanju4.txt', json_encode($cartInfo) . "-测试5\r\n", 8);
|
|
|
|
|
|
foreach ($cartInfo as $cart) {
|
|
|
- @file_put_contents('quanju4.txt', json_encode($cart['product_id'])."-测试3\r\n", 8);
|
|
|
+ @file_put_contents('quanju4.txt', json_encode($cart['product_id']) . "-测试3\r\n", 8);
|
|
|
|
|
|
$price = StoreProduct::where('id', $cart['product_id'])->value('price');
|
|
|
$product_price = bcmul($price, $cart['cart_num'], 2);
|
|
|
$total_price = bcadd($total_price, $product_price, 2); //商品总价
|
|
|
$total_num = bcadd($total_num, $cart['cart_num'], 2);
|
|
|
}
|
|
|
- @file_put_contents('quanju4.txt', "-这里吗\r\n", 8);
|
|
|
+ @file_put_contents('quanju4.txt', "-这里吗\r\n", 8);
|
|
|
|
|
|
if ($user_info['level'] > 0) { //会员折扣
|
|
|
$discount = SystemUserLevel::where('id', $user_info['level'])->value('discount');
|
|
|
@@ -578,7 +578,7 @@ class StoreOrder extends BaseModel
|
|
|
$total_price = bcmul($total_price, bcsub(1, $discount, 2), 2);
|
|
|
$deduction_price = bcsub($moto_price, $total_price, 2); //抵扣金额
|
|
|
}
|
|
|
- @file_put_contents('quanju4.txt', "-测试4\r\n", 8);
|
|
|
+ @file_put_contents('quanju4.txt', "-测试4\r\n", 8);
|
|
|
|
|
|
$orderInfo = [
|
|
|
'mer_id' => $v['mer_id'],
|
|
|
@@ -913,15 +913,196 @@ class StoreOrder extends BaseModel
|
|
|
UserBill::expend('购买商品', $order['uid'], 'now_money', 'pay_money', $order['pay_price'], $order['id'], $now_money, '支付' . floatval($order['pay_price']) . '元购买商品');
|
|
|
//支付成功后
|
|
|
event('OrderPaySuccess', [$order, $formId]);
|
|
|
- self::userLevelReward($order, $order['uid'], 1); //激励奖 会员返现
|
|
|
+// self::userLevelReward($order, $order['uid'], 1); //激励奖 会员返现
|
|
|
if ($order['is_wholesale'] == 1) { //批发订单
|
|
|
- self::wholesale($order); //批发订单返利
|
|
|
- self::umbrella($order); //伞下返利
|
|
|
+// self::wholesale($order); //批发订单返利
|
|
|
+// self::umbrella($order); //伞下返利
|
|
|
}
|
|
|
$res = $res1 && $resPink && UserSpread::setSpreadSure($order['uid']) && User::backOrderBrokerage($order);
|
|
|
return false !== $res;
|
|
|
}
|
|
|
|
|
|
+ public static function userLevelRewards($order, $uid)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 无限级分销返利方法
|
|
|
+ * @param array $order 订单信息
|
|
|
+ * @param int $uid 购买者用户ID
|
|
|
+ * @param float $orderAmount 订单金额
|
|
|
+ * @return bool 处理结果
|
|
|
+ */
|
|
|
+// public static function infiniteRebate($order, $uid, $orderAmount)
|
|
|
+// {
|
|
|
+// try {
|
|
|
+// // 获取购买者信息
|
|
|
+// $buyerInfo = User::get($uid);
|
|
|
+// if (empty($buyerInfo)) {
|
|
|
+//
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+//
|
|
|
+// $buyerLevel = $buyerInfo['level'];
|
|
|
+//
|
|
|
+// // 开始递归查找上级并处理返利
|
|
|
+// return self::processRebate($order, $buyerInfo['spread_uid'], $buyerLevel, $orderAmount, 0, false);
|
|
|
+// } catch (\Exception $e) {
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 递归处理 商品返利
|
|
|
+ * @param array $order 订单信息
|
|
|
+ * @param int $uid 当前处理的用户ID
|
|
|
+ * @param int $parentLevel 上级等级
|
|
|
+ * @param int $parentBrokerage 上级等级获得金额
|
|
|
+ * @return bool 处理结果
|
|
|
+ */
|
|
|
+ private static function processRebate($order, $uid, $parentLevel = 0, $parentBrokerage = 0)
|
|
|
+ {
|
|
|
+ $brokerage = 0; //奖励金额
|
|
|
+ $user = User::get($uid);
|
|
|
+ $blance = $user['brokerage_price'];
|
|
|
+ $level_info = SystemUserLevel::where('id', $user['level'])->where('is_del', 0)->find();
|
|
|
+ if (!empty($level_info)) {
|
|
|
+ $level_info = $level_info->toArray();
|
|
|
+ }
|
|
|
+ if ($parentLevel > 0) {
|
|
|
+// $parent_level_info= SystemUserLevel::where('grade')->where('is_del',0)->find();
|
|
|
+// if (!empty($parent_level_info)){
|
|
|
+// $parent_level_info = $parent_level_info->toArray();
|
|
|
+// if ()
|
|
|
+// }
|
|
|
+ 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'])->find(); //商品返现比例
|
|
|
+ if (!empty($product)) {
|
|
|
+ $product = $product->toArray();
|
|
|
+ $product_radio = $product['rebate_ratio'];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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);
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果返利金额大于0,添加佣金记录
|
|
|
+ if ($brokerage > 0) {
|
|
|
+ $newBalance = bcadd($user['brokerage_price'], $brokerage, 2);
|
|
|
+// if ($parentLevel ==0 && $parentBrokerage == 0){
|
|
|
+// UserBill::income('商品返利', $uid, 'brokerage_price', 'order_money', $brokerage, $order['id'], $newBalance, '购买商品的商品返利佣金');
|
|
|
+//
|
|
|
+// }else{
|
|
|
+ UserBill::income('下级商品返利', $uid, 'brokerage_price', 'order_money', $brokerage, $order['id'], $newBalance, '下级购买商品的商品返利佣金');
|
|
|
+
|
|
|
+// }
|
|
|
+ User::where('uid', $uid)->update(['brokerage_price' => $newBalance]);
|
|
|
+
|
|
|
+
|
|
|
+ if ($user['spread_uid'] > 0) {
|
|
|
+ self::processRebate($order, $user['spread_uid'], $level_info['grade']);
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取商品积分返利
|
|
|
+ * @return float 返利比例
|
|
|
+ */
|
|
|
+ private static function getProductIntegral($order,$uid)
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $shopping_cart = $order['cart_id'];
|
|
|
+ $integral = 0;
|
|
|
+ $user = User::get($uid);
|
|
|
+// 先不考虑什么商品返现比例了
|
|
|
+ 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 = StoreProduct::where('id', $product_info['product_id'])->find(); //商品信息
|
|
|
+ if (!empty($product)) {
|
|
|
+ $product = $product->toArray();
|
|
|
+ $product_radio = $product['rebate_ratio'];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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); //商品返现金额
|
|
|
+ $integral = bcadd($integral, $rebate, 2);
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ $newBalance = bcadd($user['integral'],$integral,2);
|
|
|
+ UserBill::income('商品返利', $uid, 'integral', 'order_integral', $integral, $order['id'], $newBalance, '购买商品的商品返利积分');
|
|
|
+
|
|
|
+// }
|
|
|
+ User::where('uid', $uid)->update(['integral' => $newBalance]);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ @file_put_contents('quanju.txt', json_encode(['line' => $e->getLine(), 'message' => $e->getMessage(), 'file' => $e->getFile()]) . "-报错内容\r\n", 8);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取商品等级返利比例
|
|
|
+ * @param int $productId 商品ID
|
|
|
+ * @param int $levelId 等级ID
|
|
|
+ * @return float 返利比例
|
|
|
+ */
|
|
|
+ private static function getProductLevelRebate($productId, $levelId)
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ // 先从商品等级返利表中获取
|
|
|
+ $rebateRatio = StoreProductLevel::where('product_id', $productId)
|
|
|
+ ->where('level_id', $levelId)
|
|
|
+ ->value('rebate_ratio');
|
|
|
+
|
|
|
+ // 如果商品等级没有设置返利比例,使用等级表中的默认比例
|
|
|
+ if (empty($rebateRatio)) {
|
|
|
+ $rebateRatio = SystemUserLevel::where('id', $levelId)->value('rebate_ratio');
|
|
|
+ }
|
|
|
+
|
|
|
+ return floatval($rebateRatio);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 激励奖 会员返现
|
|
|
public static function userLevelReward($order, $uid, $type)
|
|
|
{
|
|
|
@@ -934,7 +1115,7 @@ class StoreOrder extends BaseModel
|
|
|
@file_put_contents('quanju4.txt', json_encode($user_radio) . "-会员等级返利比例\r\n", 8);
|
|
|
|
|
|
$rebate = bcmul($order['pay_price'], bcdiv($user_radio, 100, 2), 2); //用户返现金额
|
|
|
- if ($rebate > 0){
|
|
|
+ if ($rebate > 0) {
|
|
|
$blance = bcadd($userInfo['brokerage_price'], $rebate, 2); //用户佣金
|
|
|
@file_put_contents('quanju4.txt', json_encode(['line' => $rebate, 'message' => $order['id'], 'file' => $blance]) . "-会员等级激励奖报错内容2\r\n", 8);
|
|
|
|
|
|
@@ -947,23 +1128,23 @@ class StoreOrder extends BaseModel
|
|
|
UserBill::income('下级会员返利', $uid, 'brokerage_price', 'level_money', $rebate, $order['id'], $blance, '下级购买商品的会员返利佣金');
|
|
|
return true;
|
|
|
}
|
|
|
- User::where('uid',$uid)->update(['brokerage_price'=>$blance]);
|
|
|
+ User::where('uid', $uid)->update(['brokerage_price' => $blance]);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- $rebate=0;
|
|
|
- $userInfo = User::get($uid);
|
|
|
- @file_put_contents('quanju4.txt',json_encode($order['cart_id']) . "-购物车id1\r\n", 8);
|
|
|
+ $rebate = 0;
|
|
|
+ $userInfo = User::get($uid);
|
|
|
+ @file_put_contents('quanju4.txt', json_encode($order['cart_id']) . "-购物车id1\r\n", 8);
|
|
|
// $shopping_cart = json_decode($order['cart_id'], true);
|
|
|
$shopping_cart = $order['cart_id'];
|
|
|
// 先不考虑什么商品返现比例了
|
|
|
foreach ($shopping_cart as $cart) {
|
|
|
- @file_put_contents('quanju4.txt',$cart . "-购物车id2\r\n", 8);
|
|
|
- $product_radio=0;
|
|
|
+ @file_put_contents('quanju4.txt', $cart . "-购物车id2\r\n", 8);
|
|
|
+ $product_radio = 0;
|
|
|
$product_info = StoreCart::where('id', $cart)->find()->toArray();
|
|
|
@file_put_contents('quanju4.txt', json_encode($product_info) . "-购物车详情\r\n", 8);
|
|
|
$product = StoreProduct::where('id', $product_info['product_id'])->find(); //商品返现比例
|
|
|
- if (!empty($product)){
|
|
|
+ if (!empty($product)) {
|
|
|
$product = $product->toArray();
|
|
|
$product_radio = $product['rebate_ratio'];
|
|
|
}
|
|
|
@@ -971,23 +1152,23 @@ class StoreOrder extends BaseModel
|
|
|
@file_put_contents('quanju4.txt', $product_radio . "-会员等级激励奖报错内容4\r\n", 8);
|
|
|
|
|
|
|
|
|
- if ($product_radio>0){
|
|
|
+ if ($product_radio > 0) {
|
|
|
// if ($user_radio>0){
|
|
|
$rebate = bcmul($order['pay_price'], bcdiv($product_radio, 100, 2), 2); //用户返现金额
|
|
|
|
|
|
- $blance = bcadd($userInfo['brokerage_price'], $rebate, 2); //用户佣金
|
|
|
- @file_put_contents('quanju4.txt', json_encode(['line' => $rebate, 'message' => $order['id'], 'file' => $blance]) . "-会员等级激励奖报错内容2\r\n", 8);
|
|
|
+ $blance = bcadd($userInfo['brokerage_price'], $rebate, 2); //用户佣金
|
|
|
+ @file_put_contents('quanju4.txt', json_encode(['line' => $rebate, 'message' => $order['id'], 'file' => $blance]) . "-会员等级激励奖报错内容2\r\n", 8);
|
|
|
|
|
|
- if ($type == 1) {
|
|
|
- UserBill::income('商品返利', $uid, 'brokerage_price', 'order_money', $rebate, $order['id'], $blance, '商品返利佣金');
|
|
|
+ if ($type == 1) {
|
|
|
+ UserBill::income('商品返利', $uid, 'brokerage_price', 'order_money', $rebate, $order['id'], $blance, '商品返利佣金');
|
|
|
// if ($userInfo['spread_uid'] > 0) {
|
|
|
// self::userLevelReward($order, $userInfo['spread_uid'], 2);
|
|
|
// }
|
|
|
- } elseif ($type == 2) { //下级推荐返利
|
|
|
- UserBill::income('下级商品返利', $uid, 'brokerage_price', 'order_money', $rebate, $order['id'], $blance, '下级购买商品的商品返利佣金');
|
|
|
- return true;
|
|
|
- }
|
|
|
- User::where('uid',$uid)->update(['brokerage_price'=>$blance]);
|
|
|
+ } elseif ($type == 2) { //下级推荐返利
|
|
|
+ UserBill::income('下级商品返利', $uid, 'brokerage_price', 'order_money', $rebate, $order['id'], $blance, '下级购买商品的商品返利佣金');
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ User::where('uid', $uid)->update(['brokerage_price' => $blance]);
|
|
|
// }
|
|
|
}
|
|
|
if ($userInfo['spread_uid'] > 0) {
|
|
|
@@ -995,7 +1176,7 @@ class StoreOrder extends BaseModel
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- }catch (\Exception $e) {
|
|
|
+ } catch (\Exception $e) {
|
|
|
// 处理异常
|
|
|
@file_put_contents('quanju4.txt', json_encode(['line' => $e->getLine(), 'message' => $e->getMessage(), 'file' => $e->getFile()]) . "-会员等级激励奖报错内容\r\n", 8);
|
|
|
|
|
|
@@ -1045,7 +1226,7 @@ class StoreOrder extends BaseModel
|
|
|
User::where('uid', $one_spread_info['uid'])->update(['brokerage_price' => $blance]);
|
|
|
|
|
|
}
|
|
|
- $price=0;
|
|
|
+ $price = 0;
|
|
|
//然后算二级推荐人的
|
|
|
if ($userInfo['agent'] > 0 && $two_spread_info) {
|
|
|
if ($two_spread_info['agent'] > 0) {
|
|
|
@@ -1055,7 +1236,7 @@ class StoreOrder extends BaseModel
|
|
|
}
|
|
|
} elseif ($two > $one) { //如果二级推荐人等级大于直推等级
|
|
|
if ($two > $user_agnet['grade']) { //如果二级推荐人等级高于自己
|
|
|
- $indirect_rebates = bcmul($two_agent['indirect_rebates'],2,2);
|
|
|
+ $indirect_rebates = bcmul($two_agent['indirect_rebates'], 2, 2);
|
|
|
$price = bcmul($order['total_price'], bcdiv($indirect_rebates, 100, 2), 2); //二级推荐人获得直接推荐比例的两倍
|
|
|
|
|
|
} elseif ($two == $user_agnet['grade']) { //如果二级推荐人等级等于自己
|
|
|
@@ -1070,34 +1251,36 @@ class StoreOrder extends BaseModel
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
- }catch (\Exception $e) {
|
|
|
+ } catch (\Exception $e) {
|
|
|
// 处理异常
|
|
|
@file_put_contents('quanju4.txt', json_encode(['line' => $e->getLine(), 'message' => $e->getMessage(), 'file' => $e->getFile()]) . "-代理等级批发返利报错内容\r\n", 8);
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//伞下返利
|
|
|
- public static function umbrella($order){
|
|
|
- try{
|
|
|
+ public static function umbrella($order)
|
|
|
+ {
|
|
|
+ try {
|
|
|
// 获取所有伞下比例大于0的等级
|
|
|
- $agent_level = SystemUserLevel::where('umbrella_rebates','>',0)->where('is_show',1)->where('is_del',0)->column('id');
|
|
|
+ $agent_level = SystemUserLevel::where('umbrella_rebates', '>', 0)->where('is_show', 1)->where('is_del', 0)->column('id');
|
|
|
|
|
|
// for循环所有伞下比例大于0的等级计算他们每个等级伞下比例乘订单金额的奖池数量再除以该等级的上级人数
|
|
|
- foreach ($agent_level as $level){
|
|
|
+ foreach ($agent_level as $level) {
|
|
|
$level_uids = self::getAllSuperiors($order['uid'], $level['id']); //获取所有符合等级的上级用户UID
|
|
|
$level_count = count($level_uids); //符合等级的上级人数
|
|
|
- $pool = bcmul($order['total_price'],bcdiv($level['umbrella_rebates'],100,2),2); //该等级奖池
|
|
|
- $user_price = bcdiv($pool,$level_count,2); //该等级奖池/符合等级的上级人数
|
|
|
- $name = SystemUserLevel::where('id',$level['id'])->value('name'); //等级名称
|
|
|
+ $pool = bcmul($order['total_price'], bcdiv($level['umbrella_rebates'], 100, 2), 2); //该等级奖池
|
|
|
+ $user_price = bcdiv($pool, $level_count, 2); //该等级奖池/符合等级的上级人数
|
|
|
+ $name = SystemUserLevel::where('id', $level['id'])->value('name'); //等级名称
|
|
|
foreach ($level_uids as $uid) {
|
|
|
$brokerage_price = User::where('uid', $uid)->value('brokerage_price');
|
|
|
$blance = bcadd($brokerage_price, $user_price, 2);
|
|
|
- UserBill::income('伞下团体返利', $uid, 'brokerage_price', 'umbrella_rebates', $user_price, $order['id'], $blance, $name.'伞下团队购买商品返利');
|
|
|
+ UserBill::income('伞下团体返利', $uid, 'brokerage_price', 'umbrella_rebates', $user_price, $order['id'], $blance, $name . '伞下团队购买商品返利');
|
|
|
User::where('uid', $uid)->update(['brokerage_price' => $blance]);
|
|
|
}
|
|
|
}
|
|
|
- }catch (\Exception $e) {
|
|
|
+ } catch (\Exception $e) {
|
|
|
// 处理异常
|
|
|
@file_put_contents('quanju4.txt', json_encode(['line' => $e->getLine(), 'message' => $e->getMessage(), 'file' => $e->getFile()]) . "-伞下团队批发返利报错内容\r\n", 8);
|
|
|
|
|
|
@@ -1105,6 +1288,7 @@ class StoreOrder extends BaseModel
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 递归获取所有上级(推荐人/推广人)的UID
|
|
|
* @param int $uid 团队成员的ID
|
|
|
@@ -1112,7 +1296,8 @@ class StoreOrder extends BaseModel
|
|
|
* @param array $allSuperiors 内部递归使用,用于存储所有上级UID,初始为空数组
|
|
|
* @return array 过滤后的上级UID列表
|
|
|
*/
|
|
|
- public static function getAllSuperiors($uid, $agent = null, &$allSuperiors = []) {
|
|
|
+ public static function getAllSuperiors($uid, $agent = null, &$allSuperiors = [])
|
|
|
+ {
|
|
|
// 1. 获取当前用户的直接上级 spread_uid
|
|
|
// 假设 User::where('uid', $uid)->value('spread_uid') 可以获取到该用户的直接上级ID
|
|
|
$superiorUid = User::where('uid', $uid)->value('spread_uid');
|
|
|
@@ -1146,6 +1331,7 @@ class StoreOrder extends BaseModel
|
|
|
// 7. 如果没有传入 $agent,则返回所有收集到的上级 UID
|
|
|
return $resultUids;
|
|
|
}
|
|
|
+
|
|
|
/*
|
|
|
* 线下支付消息通知
|
|
|
* 待完善
|