...
|
...
|
@@ -329,16 +329,19 @@ class Person extends Api |
|
|
* @return bool
|
|
|
*/
|
|
|
public function getScore($share_uid,$type){
|
|
|
$class = '';
|
|
|
if($type == 'share_purchase'){
|
|
|
$scoreRule = Db::table('gc_sscore')
|
|
|
->where('set_rule','like','%购买%')
|
|
|
->field('set_score')
|
|
|
->find();
|
|
|
$class = 1;
|
|
|
}else if($type == 'share_sell'){
|
|
|
$scoreRule = Db::table('gc_sscore')
|
|
|
->where('set_rule','like','%卖废品%')
|
|
|
->field('set_score')
|
|
|
->find();
|
|
|
$class = 0;
|
|
|
}
|
|
|
// $score = config('site.'.$type);
|
|
|
$score = 0;
|
...
|
...
|
@@ -346,16 +349,29 @@ class Person extends Api |
|
|
$score = $scoreRule['set_score'];
|
|
|
}
|
|
|
$offlineModel = new Line();
|
|
|
//此处判断不能相互成为下线(你成为我的下线,我就不能成为你的下线)
|
|
|
$offlineModel->where(['off_uid'=>$share_uid,'uid'=>$this->user_id])->find();
|
|
|
//此处判断分享用户否已有上线,如果有,则不能成为其他的下线
|
|
|
$each_other = $offlineModel->where(['off_uid'=>$share_uid])->select();
|
|
|
//判断本登录用户是否有上线
|
|
|
$other = $offlineModel->where(['off_uid'=>$this->user_id])->select();
|
|
|
//分享人是自己无效
|
|
|
if($share_uid != $this->user_id){
|
|
|
if(!$offlineModel){
|
|
|
//分享用户有上线
|
|
|
if($each_other && !$other){
|
|
|
$on_uid = array_unique(array_column($each_other,'uid'))[0];
|
|
|
//给上线增加积分
|
|
|
$userModel = new \app\admin\model\User();
|
|
|
$userModel->where(['id'=>$on_uid,'status'=>'normal'])->setInc('score', $score);
|
|
|
//创建上线用户的积分记录
|
|
|
$offlineModel->create(['uid'=>$on_uid,'s_score'=>$score,'off_uid'=>$share_uid,'type'=>$class]);
|
|
|
}else{
|
|
|
//本登录用户没有上线
|
|
|
if(!$other){
|
|
|
//给分享用户增加积分
|
|
|
$userModel = new \app\admin\model\User();
|
|
|
$userModel->where(['id'=>$share_uid,'status'=>'normal'])->setInc('score', $score);
|
|
|
//成为分享用户的下线
|
|
|
$offlineModel->create(['uid'=>$share_uid,'s_score'=>$score,'off_uid'=>$this->user_id]);
|
|
|
//成为分享用户的下线并创建积分记录
|
|
|
$offlineModel->create(['uid'=>$share_uid,'s_score'=>$score,'off_uid'=>$this->user_id,'type'=>$class]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
...
|
...
|
|