配置修改
This commit is contained in:
@ -35,7 +35,28 @@ class Distribution extends Api
|
|||||||
return JsonServer::error('请求方式错误');
|
return JsonServer::error('请求方式错误');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 扫码成为分销会员
|
||||||
|
*/
|
||||||
|
public function wxCodeApply()
|
||||||
|
{
|
||||||
|
if($this->request->isPost()){
|
||||||
|
$post = $this->request->post();
|
||||||
|
$user_id = $this->user_id;
|
||||||
|
try{
|
||||||
|
validate(DistributionValidate::class)->scene('apply')->check($post);
|
||||||
|
}catch(ValidateException $e) {
|
||||||
|
return JsonServer::error($e->getError());
|
||||||
|
}
|
||||||
|
$result = DistributionLogic::wxCodeApply($post,$user_id);
|
||||||
|
if($result) {
|
||||||
|
return JsonServer::success('成功');
|
||||||
|
}
|
||||||
|
return JsonServer::error('失败');
|
||||||
|
}else{
|
||||||
|
return JsonServer::error('请求方式错误');
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 判断是否为分销会员
|
* 判断是否为分销会员
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -105,7 +105,49 @@ class DistributionLogic extends Logic
|
|||||||
];
|
];
|
||||||
return DistributionMemberApply::create($data);
|
return DistributionMemberApply::create($data);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 申请分销会员
|
||||||
|
*/
|
||||||
|
public static function wxCodeApply($post,$user_id)
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
$user_msg = User::where('id', $user_id)->find();
|
||||||
|
$time = time();
|
||||||
|
$data = [
|
||||||
|
'user_id' => $user_id,
|
||||||
|
'real_name' => $post['nickname'],
|
||||||
|
'mobile' => $post['mobile'],
|
||||||
|
'province' => $post['province'],
|
||||||
|
'city' => $post['city'],
|
||||||
|
'district' => $post['district'],
|
||||||
|
// 'reason' => $post['reason'],
|
||||||
|
'status' => 1,
|
||||||
|
'create_time' => $time,
|
||||||
|
'update_time' => $time,
|
||||||
|
];
|
||||||
|
DistributionMemberApply::create($data);
|
||||||
|
|
||||||
|
$defaultLevelId = DistributionLevel::where('is_default', 1)->value('id');
|
||||||
|
$data = [
|
||||||
|
'user_id' => $user_id,
|
||||||
|
'level_id' => $defaultLevelId,
|
||||||
|
'is_freeze' => 0,
|
||||||
|
'remark' => '',
|
||||||
|
'is_distribution' => 1,
|
||||||
|
'distribution_time' => time()
|
||||||
|
];
|
||||||
|
|
||||||
|
Distribution::create($data);
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
static::$error = $e->getMessage();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 最新分销申请详情
|
* 最新分销申请详情
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user