|
@@ -161,7 +161,18 @@ class User extends BaseModel
|
|
|
$userInfo = self::where('uid', $uid)->find();
|
|
|
if (!$userInfo) return true;
|
|
|
//当前用户有上级直接返回
|
|
|
- if ($userInfo->spread_uid) return true;
|
|
|
+ if ($userInfo->spread_uid && $userInfo->lock_spread) return true;
|
|
|
+
|
|
|
+ $sp = $spread;
|
|
|
+ $userlist = User::column('uid,spread_uid', 'uid');
|
|
|
+ while ($sp) {
|
|
|
+ if ($sp == $uid) {
|
|
|
+ $spread = 0;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $sp = $userlist[$sp]['spread_uid'];
|
|
|
+ }
|
|
|
+
|
|
|
//没有推广编号直接返回
|
|
|
if (!$spread) return true;
|
|
|
if ($spread == $uid) return true;
|
|
@@ -454,7 +465,7 @@ class User extends BaseModel
|
|
|
$orderBy = 'u.uid asc';
|
|
|
$model = $model->alias(' u');
|
|
|
$sql = StoreOrder::where('o.paid', 1)->group('o.uid')->field(['SUM(o.pay_price) as numberCount', 'o.uid', 'o.order_id'])
|
|
|
- ->where('o.is_del', 0)->where('o.refund_status', 'in', [0,1])->where('o.is_system_del', 0)->alias('o')->fetchSql(true)->select();
|
|
|
+ ->where('o.is_del', 0)->where('o.refund_status', 'in', [0, 1])->where('o.is_system_del', 0)->alias('o')->fetchSql(true)->select();
|
|
|
$model = $model->join("(" . $sql . ") p", 'u.uid = p.uid', 'LEFT');
|
|
|
$model = $model->where('u.uid', 'IN', $uid);
|
|
|
$model = $model->field("u.uid,u.real_name as nickname,u.avatar,u.add_time as time,u.spread_count as childCount,u.pay_count as orderCount,p.numberCount");
|
|
@@ -480,19 +491,32 @@ class User extends BaseModel
|
|
|
{
|
|
|
// 自己不能绑定自己为上级
|
|
|
if ($uid == $spreadUid) return false;
|
|
|
- //TODO 获取后台分销类型
|
|
|
- $storeBrokerageStatus = sys_config('store_brokerage_statu');
|
|
|
- $storeBrokerageStatus = $storeBrokerageStatus ? $storeBrokerageStatus : 1;
|
|
|
- if ($storeBrokerageStatus == 1) {
|
|
|
- $spreadCount = self::where('uid', $spreadUid)->count();
|
|
|
- if ($spreadCount) {
|
|
|
- $spreadInfo = self::where('uid', $spreadUid)->find();
|
|
|
- if ($spreadInfo->is_promoter) {
|
|
|
- //TODO 只有扫码才可以获得推广权限
|
|
|
- if (isset($wechatUser['isPromoter'])) $data['is_promoter'] = 1;
|
|
|
- }
|
|
|
+
|
|
|
+ $sp = $spreadUid;
|
|
|
+ $userlist = User::column('uid,spread_uid', 'uid');
|
|
|
+ while ($sp) {
|
|
|
+ if ($sp == $uid) {
|
|
|
+ $spreadUid = 0;
|
|
|
+ break;
|
|
|
}
|
|
|
+ $sp = $userlist[$sp]['spread_uid'];
|
|
|
}
|
|
|
+
|
|
|
+ //TODO 获取后台分销类型
|
|
|
+// $storeBrokerageStatus = sys_config('store_brokerage_statu');
|
|
|
+// $storeBrokerageStatus = $storeBrokerageStatus ? $storeBrokerageStatus : 1;
|
|
|
+// if ($storeBrokerageStatus == 1) {
|
|
|
+// $spreadCount = self::where('uid', $spreadUid)->count();
|
|
|
+// if ($spreadCount) {
|
|
|
+// $spreadInfo = self::where('uid', $spreadUid)->find();
|
|
|
+// if ($spreadInfo->is_promoter) {
|
|
|
+// //TODO 只有扫码才可以获得推广权限
|
|
|
+// if (isset($wechatUser['isPromoter'])) $data['is_promoter'] = 1;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+ if (!$spreadUid) return false;
|
|
|
+ if (self::where('lock_spread', 1)->where('uid', $uid)->find()) return false;
|
|
|
return self::where('uid', $uid)->update(['spread_uid' => $spreadUid, 'spread_time' => time()]);
|
|
|
}
|
|
|
|
|
@@ -515,7 +539,7 @@ class User extends BaseModel
|
|
|
* @param $spread
|
|
|
* @return User|\think\Model
|
|
|
*/
|
|
|
- public static function register($account, $password, $spread,$real_name='',$addres='')
|
|
|
+ public static function register($account, $password, $spread, $real_name = '', $addres = '')
|
|
|
{
|
|
|
if (self::be(['account' => $account])) return self::setErrorInfo('用户已存在');
|
|
|
$phone = $account;
|
|
@@ -604,7 +628,7 @@ class User extends BaseModel
|
|
|
->where('t1.spread_uid', '<>', 0)
|
|
|
->order('count desc')
|
|
|
->order('t0.uid desc')
|
|
|
- ->where('t1.add_time', 'BETWEEN', [date("Y-m-d H:i:s",$startTime), date("Y-m-d H:i:s",$endTime)])
|
|
|
+ ->where('t1.add_time', 'BETWEEN', [date("Y-m-d H:i:s", $startTime), date("Y-m-d H:i:s", $endTime)])
|
|
|
->page($data['page'], $data['limit'])
|
|
|
->group('t0.uid')
|
|
|
->select();
|
|
@@ -665,8 +689,8 @@ class User extends BaseModel
|
|
|
* 获取门店会员信息
|
|
|
* @return \think\model\relation\HasOne
|
|
|
*/
|
|
|
- public function storeMember()
|
|
|
- {
|
|
|
- return $this->hasOne(SystemStoreMember::class,"uid","uid");
|
|
|
- }
|
|
|
+ public function storeMember()
|
|
|
+ {
|
|
|
+ return $this->hasOne(SystemStoreMember::class, "uid", "uid");
|
|
|
+ }
|
|
|
}
|