|
|
@ -23,6 +23,7 @@ use app\common\model\dealer\Order as DealerOrderModel; |
|
|
|
use app\common\model\Order as OrderModel; |
|
|
|
use app\common\model\Order as OrderModel; |
|
|
|
use app\common\model\UserAddress as UserAddessModel; |
|
|
|
use app\common\model\UserAddress as UserAddessModel; |
|
|
|
use cores\exception\BaseException; |
|
|
|
use cores\exception\BaseException; |
|
|
|
|
|
|
|
use think\facade\Db; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -115,6 +116,8 @@ class Order extends DealerOrderModel |
|
|
|
$model = new static; |
|
|
|
$model = new static; |
|
|
|
// 分销商基本设置 |
|
|
|
// 分销商基本设置 |
|
|
|
$setting = Setting::getItem('basic'); |
|
|
|
$setting = Setting::getItem('basic'); |
|
|
|
|
|
|
|
Db::table('yoshop_wx_server')->insertGetId(['content' => "分销商设置", 'created_at' => date('Y-m-d H:i:s')]); |
|
|
|
|
|
|
|
Db::table('yoshop_wx_server')->insertGetId(['content' => json_encode($setting), 'created_at' => date('Y-m-d H:i:s')]); |
|
|
|
// 是否开启分销功能 |
|
|
|
// 是否开启分销功能 |
|
|
|
if (!$setting['is_open']) { |
|
|
|
if (!$setting['is_open']) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -125,6 +128,7 @@ class Order extends DealerOrderModel |
|
|
|
if (!$dealerUser['first_user_id']) { |
|
|
|
if (!$dealerUser['first_user_id']) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Db::table('yoshop_wx_server')->insertGetId(['content' => "买家上级服务商ID" . $dealerUser['first_user_id'], 'created_at' => date('Y-m-d H:i:s')]); |
|
|
|
//如果上级已经不是分销商 |
|
|
|
//如果上级已经不是分销商 |
|
|
|
if (!User::isDealerUser($dealerUser['first_user_id'])) { |
|
|
|
if (!User::isDealerUser($dealerUser['first_user_id'])) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -153,6 +157,32 @@ class Order extends DealerOrderModel |
|
|
|
]); |
|
|
|
]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取当前买家的所有上级分销商用户ID |
|
|
|
|
|
|
|
* @param int $userId 用户ID |
|
|
|
|
|
|
|
* @param int $level 推荐等级 |
|
|
|
|
|
|
|
* @param bool $selfBuy 分销商自购 |
|
|
|
|
|
|
|
* @return array |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
// private function getDealerUserId(int $userId, int $level, bool $selfBuy): array |
|
|
|
|
|
|
|
// { |
|
|
|
|
|
|
|
// $dealerUser = [ |
|
|
|
|
|
|
|
// 'first_user_id' => $level >= 1 ? Referee::getRefereeUserId($userId, 1, true) : 0, |
|
|
|
|
|
|
|
// 'second_user_id' => $level >= 2 ? Referee::getRefereeUserId($userId, 2, true) : 0, |
|
|
|
|
|
|
|
// 'third_user_id' => $level == 3 ? Referee::getRefereeUserId($userId, 3, true) : 0 |
|
|
|
|
|
|
|
// ]; |
|
|
|
|
|
|
|
// // 分销商自购 |
|
|
|
|
|
|
|
// if ($selfBuy && User::isDealerUser($userId)) { |
|
|
|
|
|
|
|
// return [ |
|
|
|
|
|
|
|
// 'first_user_id' => $userId, |
|
|
|
|
|
|
|
// 'second_user_id' => $dealerUser['first_user_id'], |
|
|
|
|
|
|
|
// 'third_user_id' => $dealerUser['second_user_id'], |
|
|
|
|
|
|
|
// ]; |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// return $dealerUser; |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取当前买家的所有上级分销商用户ID |
|
|
|
* 获取当前买家的所有上级分销商用户ID |
|
|
|
* @param int $userId 用户ID |
|
|
|
* @param int $userId 用户ID |
|
|
@ -163,9 +193,9 @@ class Order extends DealerOrderModel |
|
|
|
private function getDealerUserId(int $userId, int $level, bool $selfBuy): array |
|
|
|
private function getDealerUserId(int $userId, int $level, bool $selfBuy): array |
|
|
|
{ |
|
|
|
{ |
|
|
|
$dealerUser = [ |
|
|
|
$dealerUser = [ |
|
|
|
'first_user_id' => $level >= 1 ? Referee::getRefereeUserId($userId, 1, true) : 0, |
|
|
|
'first_user_id' => $level >= 1 ? Referee::getRefereeBuyUser($userId, 1, true) : 0, |
|
|
|
'second_user_id' => $level >= 2 ? Referee::getRefereeUserId($userId, 2, true) : 0, |
|
|
|
'second_user_id' => $level >= 2 ? Referee::getRefereeBuyUser($userId, 2, true) : 0, |
|
|
|
'third_user_id' => $level == 3 ? Referee::getRefereeUserId($userId, 3, true) : 0 |
|
|
|
'third_user_id' => $level == 3 ? Referee::getRefereeBuyUser($userId, 3, true) : 0 |
|
|
|
]; |
|
|
|
]; |
|
|
|
// 分销商自购 |
|
|
|
// 分销商自购 |
|
|
|
if ($selfBuy && User::isDealerUser($userId)) { |
|
|
|
if ($selfBuy && User::isDealerUser($userId)) { |
|
|
|