作者 景龙
1 个管道 的构建 失败 耗费 0 秒

修改分享处理问题

@@ -250,16 +250,20 @@ class Person extends Api @@ -250,16 +250,20 @@ class Person extends Api
250 */ 250 */
251 public function getScore($share_uid,$type){ 251 public function getScore($share_uid,$type){
252 $score = config('site.'.$type); 252 $score = config('site.'.$type);
253 - //给分享用户增加积分  
254 - $userModel = new \app\admin\model\User();  
255 - $user = $userModel->where(['id'=>$share_uid,'status'=>'normal'])->setInc('score', $score);  
256 - //成为分享用户的下线 253 +
257 $offlineModel = new Line(); 254 $offlineModel = new Line();
258 - $off = $offlineModel->create(['uid'=>$share_uid,'s_score'=>$score,'off_uid'=>$this->user_id]);  
259 - if($user && $off){  
260 - return true; 255 + //此处判断不能相互成为下线(你成为我的下线,我就不能成为你的下线)
  256 + $offlineModel->where(['off_uid'=>$share_uid,'uid'=>$this->user_id])->find();
  257 + //分享人是自己无效
  258 + if($share_uid != $this->user_id){
  259 + if(!$offlineModel){
  260 + //给分享用户增加积分
  261 + $userModel = new \app\admin\model\User();
  262 + $userModel->where(['id'=>$share_uid,'status'=>'normal'])->setInc('score', $score);
  263 + //成为分享用户的下线
  264 + $offlineModel->create(['uid'=>$share_uid,'s_score'=>$score,'off_uid'=>$this->user_id]);
  265 + }
261 } 266 }
262 - return false;  
263 } 267 }
264 268
265 } 269 }
@@ -47,13 +47,10 @@ class Sell extends Api @@ -47,13 +47,10 @@ class Sell extends Api
47 if (!$validate->check($sell_data)) { 47 if (!$validate->check($sell_data)) {
48 $this->error($validate->getError()); 48 $this->error($validate->getError());
49 } 49 }
50 - //如果携带分享uid,则按照积分增加 50 + //如果携带分享uid,则按照积分增加,并成为下线
51 if(!empty($sell_data['share_uid'])){ 51 if(!empty($sell_data['share_uid'])){
52 $person = new Person(); 52 $person = new Person();
53 - $res = $person->getScore($sell_data['share_uid'],'share_sell');  
54 - if(!$res){  
55 - $this->error('失败');  
56 - } 53 + $person->getScore($sell_data['share_uid'],'share_sell');
57 } 54 }
58 $sell = new \app\admin\model\Sell(); 55 $sell = new \app\admin\model\Sell();
59 $data['uid'] = $this->user_id; 56 $data['uid'] = $this->user_id;
@@ -219,8 +219,8 @@ class Wxpay extends Api @@ -219,8 +219,8 @@ class Wxpay extends Api
219 } 219 }
220 220
221 /** 221 /**
222 - * @ApiTitle (分享购买增加积分)  
223 - * @ApiSummary (分享购买增加积分) 222 + * @ApiTitle (分享购买成功调用,增加积分并获得相应的积分)
  223 + * @ApiSummary (分享购买成功调用,增加积分并获得相应的积分)
224 * @ApiMethod (GET) 224 * @ApiMethod (GET)
225 * @ApiRoute (/api/wxpay/addScore) 225 * @ApiRoute (/api/wxpay/addScore)
226 * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") 226 * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
@@ -237,12 +237,8 @@ class Wxpay extends Api @@ -237,12 +237,8 @@ class Wxpay extends Api
237 $share_uid = $this->request->get('share_uid'); 237 $share_uid = $this->request->get('share_uid');
238 //如果携带分享uid,则按照积分增加 238 //如果携带分享uid,则按照积分增加
239 $person = new Person(); 239 $person = new Person();
240 - $res = $person->getScore($share_uid,'share_purchase');  
241 - if($res){  
242 - $this->error('成功');  
243 - }else{  
244 - $this->error('失败');  
245 - } 240 + $person->getScore($share_uid,'share_purchase');
  241 + $this->error('成功');
246 }else{ 242 }else{
247 $this->error('请求方式错误'); 243 $this->error('请求方式错误');
248 } 244 }
@@ -34,7 +34,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -34,7 +34,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
34 // {field: 'type', title: __('Type'),formatter: Table.api.formatter.label,searchList: {0: __('pre_list'), 1: __('purchase')}}, 34 // {field: 'type', title: __('Type'),formatter: Table.api.formatter.label,searchList: {0: __('pre_list'), 1: __('purchase')}},
35 {field: 'score', title: __('Score')}, 35 {field: 'score', title: __('Score')},
36 {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, 36 {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
37 - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}  
38 ] 37 ]
39 ] 38 ]
40 }); 39 });