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

修改分享处理问题

... ... @@ -250,16 +250,20 @@ class Person extends Api
*/
public function getScore($share_uid,$type){
$score = config('site.'.$type);
//给分享用户增加积分
$userModel = new \app\admin\model\User();
$user = $userModel->where(['id'=>$share_uid,'status'=>'normal'])->setInc('score', $score);
//成为分享用户的下线
$offlineModel = new Line();
$off = $offlineModel->create(['uid'=>$share_uid,'s_score'=>$score,'off_uid'=>$this->user_id]);
if($user && $off){
return true;
//此处判断不能相互成为下线(你成为我的下线,我就不能成为你的下线)
$offlineModel->where(['off_uid'=>$share_uid,'uid'=>$this->user_id])->find();
//分享人是自己无效
if($share_uid != $this->user_id){
if(!$offlineModel){
//给分享用户增加积分
$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]);
}
}
return false;
}
}
... ...
... ... @@ -47,13 +47,10 @@ class Sell extends Api
if (!$validate->check($sell_data)) {
$this->error($validate->getError());
}
//如果携带分享uid,则按照积分增加
//如果携带分享uid,则按照积分增加,并成为下线
if(!empty($sell_data['share_uid'])){
$person = new Person();
$res = $person->getScore($sell_data['share_uid'],'share_sell');
if(!$res){
$this->error('失败');
}
$person->getScore($sell_data['share_uid'],'share_sell');
}
$sell = new \app\admin\model\Sell();
$data['uid'] = $this->user_id;
... ...
... ... @@ -219,8 +219,8 @@ class Wxpay extends Api
}
/**
* @ApiTitle (分享购买增加积分)
* @ApiSummary (分享购买增加积分)
* @ApiTitle (分享购买成功调用,增加积分并获得相应的积分)
* @ApiSummary (分享购买成功调用,增加积分并获得相应的积分)
* @ApiMethod (GET)
* @ApiRoute (/api/wxpay/addScore)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
... ... @@ -237,12 +237,8 @@ class Wxpay extends Api
$share_uid = $this->request->get('share_uid');
//如果携带分享uid,则按照积分增加
$person = new Person();
$res = $person->getScore($share_uid,'share_purchase');
if($res){
$this->error('成功');
}else{
$this->error('失败');
}
$person->getScore($share_uid,'share_purchase');
$this->error('成功');
}else{
$this->error('请求方式错误');
}
... ...
... ... @@ -34,7 +34,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
// {field: 'type', title: __('Type'),formatter: Table.api.formatter.label,searchList: {0: __('pre_list'), 1: __('purchase')}},
{field: 'score', title: __('Score')},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
... ...