...
|
...
|
@@ -18,7 +18,7 @@ use think\Validate; |
|
|
*/
|
|
|
class User extends Api
|
|
|
{
|
|
|
protected $noNeedLogin = ['third','joinUs','developLogin','notice'];
|
|
|
protected $noNeedLogin = ['third', 'joinUs', 'developLogin', 'notice'];
|
|
|
protected $noNeedRight = '*';
|
|
|
|
|
|
public function _initialize()
|
...
|
...
|
@@ -46,14 +46,14 @@ class User extends Api |
|
|
*/
|
|
|
public function index()
|
|
|
{
|
|
|
$data = [];
|
|
|
$data['nickname'] = $this->auth->nickname;
|
|
|
$data['avatar'] = cdnurl($this->auth->avatar,true);
|
|
|
$data['mobile'] = $this->auth->mobile;
|
|
|
$data['pay'] = Db::name('litestore_order')->where('user_id',$this->auth->id)->where('pay_status','10')->count();
|
|
|
$data['wait_send'] = Db::name('litestore_order')->where('user_id',$this->auth->id)->where('freight_status','10')->count();
|
|
|
$data['wait_collect'] = Db::name('litestore_order')->where('user_id',$this->auth->id)->where('receipt_status','10')->count();
|
|
|
$data['wait_comment'] = Db::name('litestore_order')->where('user_id',$this->auth->id)->where('receipt_status','20')->count();
|
|
|
$data = [];
|
|
|
$data['nickname'] = $this->auth->nickname;
|
|
|
$data['avatar'] = cdnurl($this->auth->avatar, true);
|
|
|
$data['mobile'] = $this->auth->mobile;
|
|
|
$data['pay'] = Db::name('litestore_order')->where('user_id', $this->auth->id)->where('pay_status', '10')->count();
|
|
|
$data['wait_send'] = Db::name('litestore_order')->where('user_id', $this->auth->id)->where('freight_status', '10')->count();
|
|
|
$data['wait_collect'] = Db::name('litestore_order')->where('user_id', $this->auth->id)->where('receipt_status', '10')->count();
|
|
|
$data['wait_comment'] = Db::name('litestore_order')->where('user_id', $this->auth->id)->where('receipt_status', '20')->count();
|
|
|
$this->success('会员中心', ['welcome' => $data]);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -61,16 +61,16 @@ class User extends Api |
|
|
* 修改会员个人信息
|
|
|
*
|
|
|
* @ApiMethod (POST)
|
|
|
* @param string $avatar 头像地址
|
|
|
* @param string $mobile 联系方式
|
|
|
* @param string $avatar 头像地址
|
|
|
* @param string $mobile 联系方式
|
|
|
* @param string $nickname 昵称
|
|
|
*/
|
|
|
public function profile()
|
|
|
{
|
|
|
$user = $this->auth->getUser();
|
|
|
$mobile = $this->request->post('mobile');
|
|
|
$user = $this->auth->getUser();
|
|
|
$mobile = $this->request->post('mobile');
|
|
|
$nickname = $this->request->post('nickname');
|
|
|
$avatar = $this->request->post('avatar', '', 'trim,strip_tags,htmlspecialchars');
|
|
|
$avatar = $this->request->post('avatar', '', 'trim,strip_tags,htmlspecialchars');
|
|
|
if ($mobile) {
|
|
|
$user->mobile = $mobile;
|
|
|
}
|
...
|
...
|
@@ -89,59 +89,59 @@ class User extends Api |
|
|
* 第三方登录
|
|
|
*
|
|
|
* @ApiMethod (POST)
|
|
|
* @param string $code Code码
|
|
|
* @param string $code Code码
|
|
|
* @param string $nickname 微信昵称
|
|
|
* @param string $avatar 微信头像
|
|
|
* @param string $invite_id 邀请人id。默认传0
|
|
|
* @param string $avatar 微信头像
|
|
|
* @param string $invite_id 邀请人id。默认传0
|
|
|
*/
|
|
|
public function third()
|
|
|
{
|
|
|
$code = $this->request->post('code');
|
|
|
$nickname = $this->request->post('nickname');
|
|
|
$avatar = $this->request->post('avatar');
|
|
|
$code = $this->request->post('code');
|
|
|
$nickname = $this->request->post('nickname');
|
|
|
$avatar = $this->request->post('avatar');
|
|
|
$invite_id = $this->request->post('invite_id');
|
|
|
if (!$code || !$nickname || !$avatar){
|
|
|
if (!$code || !$nickname || !$avatar) {
|
|
|
$this->error('后台所需参数缺失请完善参数');
|
|
|
}
|
|
|
$param = [];
|
|
|
$param['js_code'] = $code;
|
|
|
$param = [];
|
|
|
$param['js_code'] = $code;
|
|
|
$param['grant_type'] = 'authorization_code';
|
|
|
$param['secret'] = Config::get('site.secret');
|
|
|
$param['appid'] = Config::get('site.appid');
|
|
|
$wxapi = Http::get('https://api.weixin.qq.com/sns/jscode2session',$param);//请求openid
|
|
|
$wxapi = json_decode($wxapi,true);
|
|
|
if (isset($wxapi['errcode'])){
|
|
|
$param['secret'] = Config::get('site.secret');
|
|
|
$param['appid'] = Config::get('site.appid');
|
|
|
$wxapi = Http::get('https://api.weixin.qq.com/sns/jscode2session', $param);//请求openid
|
|
|
$wxapi = json_decode($wxapi, true);
|
|
|
if (isset($wxapi['errcode'])) {
|
|
|
$this->error($wxapi['errmsg']);
|
|
|
}
|
|
|
$third = new \app\api\model\Third();
|
|
|
$userid = $third->where('openid',$wxapi['openid'])->value('user_id');
|
|
|
if ($userid){
|
|
|
$this->auth->direct($userid,$invite_id);
|
|
|
$third->isUpdate()->save(['session_key'=>$wxapi['session_key']],['user_id'=>$userid]);
|
|
|
$this->success('登录成功',['token'=>$this->auth->getToken(),'user_type'=>$this->auth->user_type]);
|
|
|
}else{
|
|
|
if ($invite_id > 0){
|
|
|
$userid = $this->auth->register($nickname,'','','',['avatar'=>$avatar,'invite_user_id'=>$invite_id,'invite_time'=>time()]);
|
|
|
}else{
|
|
|
$userid = $this->auth->register($nickname,'','','',['avatar'=>$avatar]);
|
|
|
$third = new \app\api\model\Third();
|
|
|
$userid = $third->where('openid', $wxapi['openid'])->value('user_id');
|
|
|
if ($userid) {
|
|
|
$this->auth->direct($userid, $invite_id);
|
|
|
$third->isUpdate()->save(['session_key' => $wxapi['session_key']], ['user_id' => $userid]);
|
|
|
$this->success('登录成功', ['token' => $this->auth->getToken(), 'user_type' => $this->auth->user_type]);
|
|
|
} else {
|
|
|
if ($invite_id > 0) {
|
|
|
$userid = $this->auth->register($nickname, '', '', '', ['avatar' => $avatar, 'invite_user_id' => $invite_id, 'invite_time' => time()]);
|
|
|
} else {
|
|
|
$userid = $this->auth->register($nickname, '', '', '', ['avatar' => $avatar]);
|
|
|
}
|
|
|
if ($userid){
|
|
|
$third->isUpdate(false)->save(['openid'=>$wxapi['openid'],'user_id'=>$userid,'session_key'=>$wxapi['session_key']]);
|
|
|
if ($userid) {
|
|
|
$third->isUpdate(false)->save(['openid' => $wxapi['openid'], 'user_id' => $userid, 'session_key' => $wxapi['session_key']]);
|
|
|
// 注册送优惠券
|
|
|
$coupon = Db::name('coupon')->where('id',3)->find();
|
|
|
$time = time();
|
|
|
if($coupon['register_send_switch'] == '1' && $time >= $coupon['register_send_starttime'] && $time <= $coupon['register_send_endtime']){
|
|
|
$coupon = Db::name('coupon')->where('id', 3)->find();
|
|
|
$time = time();
|
|
|
if ($coupon['register_send_switch'] == '1' && $time >= $coupon['register_send_starttime'] && $time <= $coupon['register_send_endtime']) {
|
|
|
UserCoupon::create([
|
|
|
'user_id' => $userid,
|
|
|
'coupon_id' => $coupon['id'],
|
|
|
'name' => $coupon['name'],
|
|
|
'price' => $coupon['price'],
|
|
|
'user_id' => $userid,
|
|
|
'coupon_id' => $coupon['id'],
|
|
|
'name' => $coupon['name'],
|
|
|
'price' => $coupon['price'],
|
|
|
'full_price' => $coupon['full_price'],
|
|
|
'endtime' => $time+$coupon['days']*86400
|
|
|
'endtime' => $time + $coupon['days'] * 86400,
|
|
|
]);
|
|
|
}
|
|
|
$this->success('登录成功',['token'=>$this->auth->getToken(),'user_type'=>$this->auth->user_type]);
|
|
|
}else{
|
|
|
$this->success('登录成功', ['token' => $this->auth->getToken(), 'user_type' => $this->auth->user_type]);
|
|
|
} else {
|
|
|
$this->error('注册失败');
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -154,30 +154,30 @@ class User extends Api |
|
|
* @ApiParams (name="iv", type="string", required=true, description="小程序iv")
|
|
|
* @ApiParams (name="encryptedData", type="string", required=true, description="小程序encryptedData")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'返回成功',
|
|
|
"data": {
|
|
|
"mobile": "13580006666", //没有区号的手机号
|
|
|
}
|
|
|
'code':'1',
|
|
|
'msg':'返回成功',
|
|
|
"data": {
|
|
|
"mobile": "13580006666", //没有区号的手机号
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function getPhoneNumber()
|
|
|
{
|
|
|
$param = $this->request->param();
|
|
|
$param = $this->request->param();
|
|
|
$validate = new \think\Validate([
|
|
|
'iv' => 'require',
|
|
|
'iv' => 'require',
|
|
|
'encryptedData' => 'require',
|
|
|
]);
|
|
|
$validate->message([
|
|
|
'iv.require' => 'iv参数错误!',
|
|
|
'iv.require' => 'iv参数错误!',
|
|
|
'encryptedData.require' => 'encryptData参数错误!',
|
|
|
]);
|
|
|
if (!$validate->check($param)) {
|
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
// 获取session_key
|
|
|
$user = $this->auth->getUser();
|
|
|
$third = \app\api\model\Third::where('user_id',$user['id'])->field('session_key')->find();
|
|
|
$user = $this->auth->getUser();
|
|
|
$third = \app\api\model\Third::where('user_id', $user['id'])->field('session_key')->find();
|
|
|
empty($third) && $this->error('请先登录');
|
|
|
// 获取小程序配置
|
|
|
$app = Factory::miniProgram([
|
...
|
...
|
@@ -188,7 +188,7 @@ class User extends Api |
|
|
// 更新手机号
|
|
|
$user->mobile = $res['purePhoneNumber'];
|
|
|
$user->save();
|
|
|
$this->success('授权成功',['mobile' => $res['purePhoneNumber']]);
|
|
|
$this->success('授权成功', ['mobile' => $res['purePhoneNumber']]);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -200,18 +200,18 @@ class User extends Api |
|
|
'code':'1',
|
|
|
'msg':'返回成功'
|
|
|
"data": [
|
|
|
{
|
|
|
"id": 1,
|
|
|
"user_id": 1,
|
|
|
"coupon_id": 1,
|
|
|
"name": "手动阀手动阀",
|
|
|
"price": "1.00", 优惠券金额
|
|
|
"full_price": "10.00", 满减金额
|
|
|
"createtime": 111122244,
|
|
|
"endtime": 1641869388,
|
|
|
"status": "0",
|
|
|
"endtime_text": "2022年01月11日到期"
|
|
|
}
|
|
|
{
|
|
|
"id": 1,
|
|
|
"user_id": 1,
|
|
|
"coupon_id": 1,
|
|
|
"name": "手动阀手动阀",
|
|
|
"price": "1.00", 优惠券金额
|
|
|
"full_price": "10.00", 满减金额
|
|
|
"createtime": 111122244,
|
|
|
"endtime": 1641869388,
|
|
|
"status": "0",
|
|
|
"endtime_text": "2022年01月11日到期"
|
|
|
}
|
|
|
]
|
|
|
})
|
|
|
*/
|
...
|
...
|
@@ -220,12 +220,12 @@ class User extends Api |
|
|
$model = new UserCoupon();
|
|
|
|
|
|
// 更新已过期状态
|
|
|
$model->where('status','0')->where('user_id',$this->auth->id)->where('endtime','<',time())->update(['status'=>'2']);
|
|
|
$model->where('status', '0')->where('user_id', $this->auth->id)->where('endtime', '<', time())->update(['status' => '2']);
|
|
|
|
|
|
$type = $this->request->post('type');
|
|
|
if (!in_array($type,[0,1,2])) $this->error('type参数不合法');
|
|
|
$list = $model->where('status',$type)->where('user_id',$this->auth->id)->select();
|
|
|
$this->success('用户优惠券列表',$list);
|
|
|
if (!in_array($type, [0, 1, 2])) $this->error('type参数不合法');
|
|
|
$list = $model->where('status', $type)->where('user_id', $this->auth->id)->select();
|
|
|
$this->success('用户优惠券列表', $list);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -236,27 +236,27 @@ class User extends Api |
|
|
'code':'1',
|
|
|
'msg':'返回成功'
|
|
|
"data": [
|
|
|
{
|
|
|
"id": 1,
|
|
|
"user_id": 1,
|
|
|
"username": "1", 收件人
|
|
|
"address": "阿松大", 地址
|
|
|
"address_detail": "阿松大", 详细地址
|
|
|
"normal_status": "0", 0不默认1默认
|
|
|
"lng": null, 经度
|
|
|
"lat": null, 纬度
|
|
|
"createtime": null,
|
|
|
"mobile_hide": "135****9988" 电话号码
|
|
|
"mobile": "13549059988" 电话号码
|
|
|
}
|
|
|
{
|
|
|
"id": 1,
|
|
|
"user_id": 1,
|
|
|
"username": "1", 收件人
|
|
|
"address": "阿松大", 地址
|
|
|
"address_detail": "阿松大", 详细地址
|
|
|
"normal_status": "0", 0不默认1默认
|
|
|
"lng": null, 经度
|
|
|
"lat": null, 纬度
|
|
|
"createtime": null,
|
|
|
"mobile_hide": "135****9988" 电话号码
|
|
|
"mobile": "13549059988" 电话号码
|
|
|
}
|
|
|
]
|
|
|
})
|
|
|
*/
|
|
|
public function userAddressList()
|
|
|
{
|
|
|
$model = new UserAddress();
|
|
|
$list = $model->where('user_id',$this->auth->id)->order('normal_status','desc')->select();
|
|
|
$this->success('用户地址列表',$list);
|
|
|
$list = $model->where('user_id', $this->auth->id)->order('normal_status', 'desc')->select();
|
|
|
$this->success('用户地址列表', $list);
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
@@ -281,58 +281,58 @@ class User extends Api |
|
|
*/
|
|
|
public function userAddressEdit()
|
|
|
{
|
|
|
$id = $this->request->post('id');
|
|
|
$type = $this->request->post('type');
|
|
|
$username = $this->request->post('username');
|
|
|
$mobile = $this->request->post('mobile');
|
|
|
$address = $this->request->post('address');
|
|
|
$id = $this->request->post('id');
|
|
|
$type = $this->request->post('type');
|
|
|
$username = $this->request->post('username');
|
|
|
$mobile = $this->request->post('mobile');
|
|
|
$address = $this->request->post('address');
|
|
|
$address_detail = $this->request->post('address_detail');
|
|
|
$normal = $this->request->post('normal');
|
|
|
$lat = $this->request->post('lat');
|
|
|
$lng = $this->request->post('lng');
|
|
|
$data = [
|
|
|
'type' => $type,
|
|
|
$normal = $this->request->post('normal');
|
|
|
$lat = $this->request->post('lat');
|
|
|
$lng = $this->request->post('lng');
|
|
|
$data = [
|
|
|
'type' => $type,
|
|
|
'mobile' => $mobile,
|
|
|
'id' => $id,
|
|
|
'id' => $id,
|
|
|
'normal' => $normal,
|
|
|
'lat' => $lat,
|
|
|
'lng' => $lng,
|
|
|
'lat' => $lat,
|
|
|
'lng' => $lng,
|
|
|
];
|
|
|
$rule = [
|
|
|
'type' => 'require|in:1,2',
|
|
|
$rule = [
|
|
|
'type' => 'require|in:1,2',
|
|
|
'mobile' => 'regex:^1\d{10}$',
|
|
|
'id' => 'require|integer',
|
|
|
'id' => 'require|integer',
|
|
|
'normal' => 'in:0,1',
|
|
|
'lat' => 'float',
|
|
|
'lng' => 'float',
|
|
|
'lat' => 'float',
|
|
|
'lng' => 'float',
|
|
|
];
|
|
|
$msg = [
|
|
|
'type' => 'type参数不合法',
|
|
|
$msg = [
|
|
|
'type' => 'type参数不合法',
|
|
|
'mobile' => '电话号码格式不正确',
|
|
|
'id' => '地址id不合法',
|
|
|
'id' => '地址id不合法',
|
|
|
'normal' => '默认状态参数不合法',
|
|
|
'lat' => '纬度请为浮点数格式',
|
|
|
'lng' => '经度请为浮点数格式',
|
|
|
'lat' => '纬度请为浮点数格式',
|
|
|
'lng' => '经度请为浮点数格式',
|
|
|
];
|
|
|
$validate = new \think\Validate();
|
|
|
$validate = new \think\Validate();
|
|
|
$validate->rule($rule);
|
|
|
$validate->message($msg);
|
|
|
if (!$validate->check($data)) $this->error($validate->getError());
|
|
|
$model = new UserAddress();
|
|
|
if ($type == 1){
|
|
|
if ($type == 1) {
|
|
|
$data = [
|
|
|
'mobile' => $mobile,
|
|
|
'normal_status' => $normal,
|
|
|
'lat' => $lat,
|
|
|
'lng' => $lng,
|
|
|
'username' => $username,
|
|
|
'address' => $address,
|
|
|
'mobile' => $mobile,
|
|
|
'normal_status' => $normal,
|
|
|
'lat' => $lat,
|
|
|
'lng' => $lng,
|
|
|
'username' => $username,
|
|
|
'address' => $address,
|
|
|
'address_detail' => $address_detail,
|
|
|
];
|
|
|
if ($normal == 1) $model->isUpdate()->save(['normal_status'=>'0'],['user_id'=>$this->auth->id]);
|
|
|
$model->isUpdate()->save($data,['id'=>$id]);
|
|
|
}else{
|
|
|
$model->where('id',$id)->delete();
|
|
|
if ($normal == 1) $model->isUpdate()->save(['normal_status' => '0'], ['user_id' => $this->auth->id]);
|
|
|
$model->isUpdate()->save($data, ['id' => $id]);
|
|
|
} else {
|
|
|
$model->where('id', $id)->delete();
|
|
|
}
|
|
|
$this->success('SUCCESS');
|
|
|
}
|
...
|
...
|
@@ -356,53 +356,53 @@ class User extends Api |
|
|
*/
|
|
|
public function userAddressAdd()
|
|
|
{
|
|
|
$username = $this->request->post('username');
|
|
|
$mobile = $this->request->post('mobile');
|
|
|
$address = $this->request->post('address');
|
|
|
$username = $this->request->post('username');
|
|
|
$mobile = $this->request->post('mobile');
|
|
|
$address = $this->request->post('address');
|
|
|
$address_detail = $this->request->post('address_detail');
|
|
|
$normal = $this->request->post('normal');
|
|
|
$lat = $this->request->post('lat');
|
|
|
$lng = $this->request->post('lng');
|
|
|
$data = [
|
|
|
'mobile' => $mobile,
|
|
|
$normal = $this->request->post('normal');
|
|
|
$lat = $this->request->post('lat');
|
|
|
$lng = $this->request->post('lng');
|
|
|
$data = [
|
|
|
'mobile' => $mobile,
|
|
|
'username' => $username,
|
|
|
'address' => $address,
|
|
|
'normal' => $normal,
|
|
|
'lat' => $lat,
|
|
|
'lng' => $lng,
|
|
|
'address' => $address,
|
|
|
'normal' => $normal,
|
|
|
'lat' => $lat,
|
|
|
'lng' => $lng,
|
|
|
];
|
|
|
$rule = [
|
|
|
'mobile' => 'require|regex:^1\d{10}$',
|
|
|
$rule = [
|
|
|
'mobile' => 'require|regex:^1\d{10}$',
|
|
|
'username' => 'require',
|
|
|
'address' => 'require',
|
|
|
'normal' => 'require|in:0,1',
|
|
|
'lat' => 'require|float',
|
|
|
'lng' => 'require|float',
|
|
|
'address' => 'require',
|
|
|
'normal' => 'require|in:0,1',
|
|
|
'lat' => 'require|float',
|
|
|
'lng' => 'require|float',
|
|
|
];
|
|
|
$msg = [
|
|
|
'mobile' => '请正确填写电话号码',
|
|
|
$msg = [
|
|
|
'mobile' => '请正确填写电话号码',
|
|
|
'username' => '请填写收件人',
|
|
|
'address' => '请选择地址',
|
|
|
'normal' => '默认状态参数不合法',
|
|
|
'lat' => '请上传纬度且为浮点数格式',
|
|
|
'lng' => '请上传经度且为浮点数格式',
|
|
|
'address' => '请选择地址',
|
|
|
'normal' => '默认状态参数不合法',
|
|
|
'lat' => '请上传纬度且为浮点数格式',
|
|
|
'lng' => '请上传经度且为浮点数格式',
|
|
|
];
|
|
|
$validate = new \think\Validate();
|
|
|
$validate = new \think\Validate();
|
|
|
$validate->rule($rule);
|
|
|
$validate->message($msg);
|
|
|
if (!$validate->check($data)) $this->error($validate->getError());
|
|
|
$model = new UserAddress();
|
|
|
$data = [
|
|
|
'mobile' => $mobile,
|
|
|
'user_id' => $this->auth->id,
|
|
|
'normal_status' => $normal,
|
|
|
'lat' => $lat,
|
|
|
'lng' => $lng,
|
|
|
'username' => $username,
|
|
|
'address' => $address,
|
|
|
$data = [
|
|
|
'mobile' => $mobile,
|
|
|
'user_id' => $this->auth->id,
|
|
|
'normal_status' => $normal,
|
|
|
'lat' => $lat,
|
|
|
'lng' => $lng,
|
|
|
'username' => $username,
|
|
|
'address' => $address,
|
|
|
'address_detail' => $address_detail,
|
|
|
];
|
|
|
if ($normal == 1) $model->isUpdate()->save(['normal_status'=>'0'],['user_id'=>$this->auth->id]);
|
|
|
if ($normal == 1) $model->isUpdate()->save(['normal_status' => '0'], ['user_id' => $this->auth->id]);
|
|
|
$model->isUpdate(false)->save($data);
|
|
|
|
|
|
$this->success('SUCCESS');
|
...
|
...
|
@@ -428,43 +428,43 @@ class User extends Api |
|
|
*/
|
|
|
public function joinUs()
|
|
|
{
|
|
|
$work = $this->request->post('work');
|
|
|
$years = $this->request->post('years');
|
|
|
$work = $this->request->post('work');
|
|
|
$years = $this->request->post('years');
|
|
|
$username = $this->request->post('username');
|
|
|
$mobile = $this->request->post('mobile');
|
|
|
$money = $this->request->post('money');
|
|
|
$team = $this->request->post('team');
|
|
|
$city = $this->request->post('city');
|
|
|
$content = $this->request->post('content');
|
|
|
$data = [
|
|
|
'work' => $work,
|
|
|
'mobile' => $mobile,
|
|
|
$mobile = $this->request->post('mobile');
|
|
|
$money = $this->request->post('money');
|
|
|
$team = $this->request->post('team');
|
|
|
$city = $this->request->post('city');
|
|
|
$content = $this->request->post('content');
|
|
|
$data = [
|
|
|
'work' => $work,
|
|
|
'mobile' => $mobile,
|
|
|
'username' => $username,
|
|
|
'years' => $years,
|
|
|
'money' => $money,
|
|
|
'team' => $team,
|
|
|
'city' => $city,
|
|
|
'content' => $content,
|
|
|
'years' => $years,
|
|
|
'money' => $money,
|
|
|
'team' => $team,
|
|
|
'city' => $city,
|
|
|
'content' => $content,
|
|
|
];
|
|
|
$rule = [
|
|
|
'work' => 'require',
|
|
|
'mobile' => 'require|regex:^1\d{10}$',
|
|
|
'years' => 'require',
|
|
|
$rule = [
|
|
|
'work' => 'require',
|
|
|
'mobile' => 'require|regex:^1\d{10}$',
|
|
|
'years' => 'require',
|
|
|
'username' => 'require',
|
|
|
'money' => 'require',
|
|
|
'team' => 'require|in:0,1',
|
|
|
'city' => 'require',
|
|
|
'content' => 'require|max:100',
|
|
|
'money' => 'require',
|
|
|
'team' => 'require|in:0,1',
|
|
|
'city' => 'require',
|
|
|
'content' => 'require|max:100',
|
|
|
];
|
|
|
$msg = [
|
|
|
'work' => '请填写从事行业',
|
|
|
'mobile' => '请正确填写电话号码',
|
|
|
'years' => '请填写从业时间',
|
|
|
$msg = [
|
|
|
'work' => '请填写从事行业',
|
|
|
'mobile' => '请正确填写电话号码',
|
|
|
'years' => '请填写从业时间',
|
|
|
'username' => '请输入姓名',
|
|
|
'money' => '请输入可投入资金',
|
|
|
'team' => '请选择是否拥有团队',
|
|
|
'city' => '请填写意向城市',
|
|
|
'content' => '请填写描述控制在100字以内',
|
|
|
'money' => '请输入可投入资金',
|
|
|
'team' => '请选择是否拥有团队',
|
|
|
'city' => '请填写意向城市',
|
|
|
'content' => '请填写描述控制在100字以内',
|
|
|
];
|
|
|
$validate = new \think\Validate();
|
|
|
$validate->rule($rule);
|
...
|
...
|
@@ -472,8 +472,8 @@ class User extends Api |
|
|
if (!$validate->check($data)) $this->error($validate->getError());
|
|
|
|
|
|
// 禁止连点
|
|
|
!empty(cache('joinus_'.$username)) && $this->error('操作频繁,请稍后再试');
|
|
|
cache('joinus_'.$username,'123',5);
|
|
|
!empty(cache('joinus_' . $username)) && $this->error('操作频繁,请稍后再试');
|
|
|
cache('joinus_' . $username, '123', 5);
|
|
|
|
|
|
$data['createtime'] = time();
|
|
|
Db::name('join_us')->insert($data);
|
...
|
...
|
@@ -490,21 +490,21 @@ class User extends Api |
|
|
'code':'1',
|
|
|
'msg':'SUCCESS'
|
|
|
"data":
|
|
|
"list": {
|
|
|
"total": 1,
|
|
|
"per_page": 15,
|
|
|
"current_page": 1,
|
|
|
"last_page": 1,
|
|
|
"data": [
|
|
|
{
|
|
|
"id": 1,
|
|
|
"title": "123", 标题
|
|
|
"content": "啊实打实大苏打", 内容
|
|
|
}
|
|
|
]
|
|
|
},
|
|
|
"rider_status": 0 申请骑手状态:0=无,1=申请中,2=成功,3=拒绝
|
|
|
"mobile": 拨号电话号码
|
|
|
"list": {
|
|
|
"total": 1,
|
|
|
"per_page": 15,
|
|
|
"current_page": 1,
|
|
|
"last_page": 1,
|
|
|
"data": [
|
|
|
{
|
|
|
"id": 1,
|
|
|
"title": "123", 标题
|
|
|
"content": "啊实打实大苏打", 内容
|
|
|
}
|
|
|
]
|
|
|
},
|
|
|
"rider_status": 0 申请骑手状态:0=无,1=申请中,2=成功,3=拒绝
|
|
|
"mobile": 拨号电话号码
|
|
|
})
|
|
|
*/
|
|
|
public function helpsList()
|
...
|
...
|
@@ -512,9 +512,9 @@ class User extends Api |
|
|
$page = $this->request->post('page');
|
|
|
if (!is_numeric($page)) $this->error('页数参数不合法');
|
|
|
$list = Db::name('helps')
|
|
|
->order('id','desc')
|
|
|
->paginate(15,false,['page'=>$page]);
|
|
|
$this->success('SUCCESS',['list'=>$list,'rider_status'=>$this->auth->rider,'mobile'=>Config::get('site.work_mobile')]);
|
|
|
->order('id', 'desc')
|
|
|
->paginate(15, false, ['page' => $page]);
|
|
|
$this->success('SUCCESS', ['list' => $list, 'rider_status' => $this->auth->rider, 'mobile' => Config::get('site.work_mobile')]);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -537,13 +537,13 @@ class User extends Api |
|
|
$mobile = $this->request->post('mobile');
|
|
|
if (!$cotent) $this->error('请填写意见描述');
|
|
|
if (mb_strlen($cotent) > 100) $this->error('请将意见描述控制在100字以内');
|
|
|
if (!$mobile || !preg_match('/^1\d{10}$/',$mobile)) $this->error('请正确填写联系方式');
|
|
|
if (!$mobile || !preg_match('/^1\d{10}$/', $mobile)) $this->error('请正确填写联系方式');
|
|
|
$data = [
|
|
|
'user_id' => $this->auth->id,
|
|
|
'cotent' => $cotent,
|
|
|
'images' => $images,
|
|
|
'mobile' => $mobile,
|
|
|
'createtime' => time()
|
|
|
'user_id' => $this->auth->id,
|
|
|
'cotent' => $cotent,
|
|
|
'images' => $images,
|
|
|
'mobile' => $mobile,
|
|
|
'createtime' => time(),
|
|
|
];
|
|
|
Db::name('opinion')->insert($data);
|
|
|
$this->success('SUCCESS');
|
...
|
...
|
@@ -561,10 +561,10 @@ class User extends Api |
|
|
*/
|
|
|
public function riderApply()
|
|
|
{
|
|
|
if (in_array($this->auth->rider,[1,2])){
|
|
|
if (in_array($this->auth->rider, [1, 2])) {
|
|
|
$this->error('您已申请,不可重复申请');
|
|
|
}
|
|
|
$user = $this->auth->getUser();
|
|
|
$user = $this->auth->getUser();
|
|
|
$user->rider = '1';
|
|
|
$user->save();
|
|
|
$this->success('SUCCESS');
|
...
|
...
|
@@ -578,38 +578,38 @@ class User extends Api |
|
|
'code':'1',
|
|
|
'msg':'邀请有奖'
|
|
|
"data":
|
|
|
"price": "10.00", 优惠价格
|
|
|
"full_price": "100.00", 满减价格
|
|
|
"endtime": "2022年04月10日", 到期时间
|
|
|
"rule": "啊实打实大苏打", 规则
|
|
|
"user_list": [
|
|
|
{
|
|
|
"user": {
|
|
|
"nickname": "admin",
|
|
|
"avatar_text": ""
|
|
|
},
|
|
|
"createtime_text": ""
|
|
|
}
|
|
|
],
|
|
|
"invite_id": 1, 邀请人id
|
|
|
"price": "10.00", 优惠价格
|
|
|
"full_price": "100.00", 满减价格
|
|
|
"endtime": "2022年04月10日", 到期时间
|
|
|
"rule": "啊实打实大苏打", 规则
|
|
|
"user_list": [
|
|
|
{
|
|
|
"user": {
|
|
|
"nickname": "admin",
|
|
|
"avatar_text": ""
|
|
|
},
|
|
|
"createtime_text": ""
|
|
|
}
|
|
|
],
|
|
|
"invite_id": 1, 邀请人id
|
|
|
})
|
|
|
*/
|
|
|
public function inviteReward()
|
|
|
{
|
|
|
$model = new \app\api\model\User();
|
|
|
$coupon = Db::name('coupon')->where('id',1)->field('price,full_price,endtime')->find();
|
|
|
$coupon['endtime'] = date('Y年m月d日',$coupon['endtime']);
|
|
|
$coupon['rule'] = Config::get('site.invite_rule');
|
|
|
$model = new \app\api\model\User();
|
|
|
$coupon = Db::name('coupon')->where('id', 1)->field('price,full_price,endtime')->find();
|
|
|
$coupon['endtime'] = date('Y年m月d日', $coupon['endtime']);
|
|
|
$coupon['rule'] = Config::get('site.invite_rule');
|
|
|
$coupon['user_list'] = $model
|
|
|
->where('invite_user_id',$this->auth->id)
|
|
|
->where('invite_status','1')
|
|
|
->where('invite_user_id', $this->auth->id)
|
|
|
->where('invite_status', '1')
|
|
|
->limit(3)
|
|
|
->select();
|
|
|
foreach ($coupon['user_list'] as $key => $value){
|
|
|
foreach ($coupon['user_list'] as $key => $value) {
|
|
|
$value->visible(['nickname']);
|
|
|
}
|
|
|
$coupon['invite_id'] = $this->auth->id;
|
|
|
$this->success('邀请有奖',$coupon);
|
|
|
$this->success('邀请有奖', $coupon);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -621,34 +621,34 @@ class User extends Api |
|
|
'code':'1',
|
|
|
'msg':'发票管理列表'
|
|
|
"data":
|
|
|
"total": 1, 总条数
|
|
|
"per_page": 5, 每页数量
|
|
|
"current_page": 1, 当前页
|
|
|
"last_page": 1, 最后一页
|
|
|
"data": [
|
|
|
{
|
|
|
"id": "1",
|
|
|
"company_name": "asdsd", 公司名称
|
|
|
"username": "asdsa", 个人名称
|
|
|
"type": "1", 1个人发票2公司发票
|
|
|
"price": 0, 发票价格
|
|
|
"tax_time": 1654891234,
|
|
|
"tax_time_text": "2022年01月12日" 开票时间
|
|
|
}
|
|
|
]
|
|
|
"total": 1, 总条数
|
|
|
"per_page": 5, 每页数量
|
|
|
"current_page": 1, 当前页
|
|
|
"last_page": 1, 最后一页
|
|
|
"data": [
|
|
|
{
|
|
|
"id": "1",
|
|
|
"company_name": "asdsd", 公司名称
|
|
|
"username": "asdsa", 个人名称
|
|
|
"type": "1", 1个人发票2公司发票
|
|
|
"price": 0, 发票价格
|
|
|
"tax_time": 1654891234,
|
|
|
"tax_time_text": "2022年01月12日" 开票时间
|
|
|
}
|
|
|
]
|
|
|
})
|
|
|
*/
|
|
|
public function taxList()
|
|
|
{
|
|
|
$page = $this->request->post('page',1);
|
|
|
$page = $this->request->post('page', 1);
|
|
|
$model = new Tax();
|
|
|
$list = $model
|
|
|
->where('user_id',$this->auth->id)
|
|
|
->where('del_status','normal')
|
|
|
$list = $model
|
|
|
->where('user_id', $this->auth->id)
|
|
|
->where('del_status', 'normal')
|
|
|
->field('id,company_name,username,type,price,tax_time')
|
|
|
->order('id','desc')
|
|
|
->paginate(5,false,['page'=>$page]);
|
|
|
$this->success('发票管理列表',$list);
|
|
|
->order('id', 'desc')
|
|
|
->paginate(5, false, ['page' => $page]);
|
|
|
$this->success('发票管理列表', $list);
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
@@ -675,92 +675,92 @@ class User extends Api |
|
|
*/
|
|
|
public function taxApply()
|
|
|
{
|
|
|
$type = $this->request->post('type');
|
|
|
$username = $this->request->post('username');
|
|
|
$company_name = $this->request->post('company_name');
|
|
|
$tax_number = $this->request->post('tax_number');
|
|
|
$type = $this->request->post('type');
|
|
|
$username = $this->request->post('username');
|
|
|
$company_name = $this->request->post('company_name');
|
|
|
$tax_number = $this->request->post('tax_number');
|
|
|
$company_address = $this->request->post('company_address');
|
|
|
$company_mobile = $this->request->post('company_mobile');
|
|
|
$bank = $this->request->post('bank');
|
|
|
$mobile = $this->request->post('mobile');
|
|
|
$eamil = $this->request->post('eamil');
|
|
|
$order_no = $this->request->post('order_no');
|
|
|
$company_mobile = $this->request->post('company_mobile');
|
|
|
$bank = $this->request->post('bank');
|
|
|
$mobile = $this->request->post('mobile');
|
|
|
$eamil = $this->request->post('eamil');
|
|
|
$order_no = $this->request->post('order_no');
|
|
|
//校验数据
|
|
|
if (!in_array($type,[1,2])) $this->error('type参数不合法');
|
|
|
$data = [
|
|
|
'mobile' => $mobile,
|
|
|
'eamil' => $eamil,
|
|
|
if (!in_array($type, [1, 2])) $this->error('type参数不合法');
|
|
|
$data = [
|
|
|
'mobile' => $mobile,
|
|
|
'eamil' => $eamil,
|
|
|
'order_no' => $order_no,
|
|
|
];
|
|
|
$rule = [
|
|
|
'mobile' => 'regex:^1\d{10}$',
|
|
|
'eamil' => 'regex:^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$',
|
|
|
$rule = [
|
|
|
'mobile' => 'regex:^1\d{10}$',
|
|
|
'eamil' => 'regex:^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$',
|
|
|
'order_no' => 'require',
|
|
|
];
|
|
|
$msg = [
|
|
|
'mobile' => '收票人电话号码格式不正确',
|
|
|
'eamil' => '电子邮箱格式不正确',
|
|
|
$msg = [
|
|
|
'mobile' => '收票人电话号码格式不正确',
|
|
|
'eamil' => '电子邮箱格式不正确',
|
|
|
'order_no' => '请输入订单编号',
|
|
|
];
|
|
|
$validate = new \think\Validate($rule,$msg);
|
|
|
$validate = new \think\Validate($rule, $msg);
|
|
|
if (!$validate->check($data)) $this->error($validate->getError());
|
|
|
if ($type == 2){
|
|
|
$data = [
|
|
|
'company_name' => $company_name,
|
|
|
'company_mobile' => $company_mobile,
|
|
|
'tax_number' => $tax_number,
|
|
|
if ($type == 2) {
|
|
|
$data = [
|
|
|
'company_name' => $company_name,
|
|
|
'company_mobile' => $company_mobile,
|
|
|
'tax_number' => $tax_number,
|
|
|
'company_address' => $company_address,
|
|
|
'bank' => $bank,
|
|
|
'bank' => $bank,
|
|
|
];
|
|
|
$rule = [
|
|
|
'company_name' => 'require',
|
|
|
'tax_number' => 'require',
|
|
|
$rule = [
|
|
|
'company_name' => 'require',
|
|
|
'tax_number' => 'require',
|
|
|
'company_address' => 'require',
|
|
|
'bank' => 'require',
|
|
|
'company_mobile' => 'regex:^1\d{10}$',
|
|
|
'bank' => 'require',
|
|
|
'company_mobile' => 'regex:^1\d{10}$',
|
|
|
];
|
|
|
$msg = [
|
|
|
'company_mobile' => '公司电话格式不正确',
|
|
|
'company_name' => '请填写公司名称',
|
|
|
'tax_number' => '请填写纳税人识别号',
|
|
|
$msg = [
|
|
|
'company_mobile' => '公司电话格式不正确',
|
|
|
'company_name' => '请填写公司名称',
|
|
|
'tax_number' => '请填写纳税人识别号',
|
|
|
'company_address' => '请填写公司地址',
|
|
|
'bank' => '请填写开户银行',
|
|
|
'bank' => '请填写开户银行',
|
|
|
];
|
|
|
$validate = new \think\Validate($rule,$msg);
|
|
|
$validate = new \think\Validate($rule, $msg);
|
|
|
if (!$validate->check($data)) $this->error($validate->getError());
|
|
|
}else{
|
|
|
$data = [
|
|
|
} else {
|
|
|
$data = [
|
|
|
'username' => $username,
|
|
|
];
|
|
|
$rule = [
|
|
|
$rule = [
|
|
|
'username' => 'require',
|
|
|
];
|
|
|
$msg = [
|
|
|
$msg = [
|
|
|
'username' => '请填写个人/非企业单位名称',
|
|
|
];
|
|
|
$validate = new \think\Validate($rule,$msg);
|
|
|
$validate = new \think\Validate($rule, $msg);
|
|
|
if (!$validate->check($data)) $this->error($validate->getError());
|
|
|
}
|
|
|
//校验订单编号
|
|
|
$orderModel = new \app\api\model\Order();
|
|
|
$order = $orderModel::get(['order_no'=>$order_no]);
|
|
|
$order = $orderModel::get(['order_no' => $order_no]);
|
|
|
if (!$order) $this->error('订单编号不存在');
|
|
|
if ($order['user_id'] != $this->auth->id) $this->error('当前用户无权使用此订单编号');
|
|
|
// 插入数据
|
|
|
$data = [
|
|
|
'company_name' => $company_name,
|
|
|
'username' => $username,
|
|
|
'company_mobile' => $company_mobile,
|
|
|
'tax_number' => $tax_number,
|
|
|
$data = [
|
|
|
'company_name' => $company_name,
|
|
|
'username' => $username,
|
|
|
'company_mobile' => $company_mobile,
|
|
|
'tax_number' => $tax_number,
|
|
|
'company_address' => $company_address,
|
|
|
'bank' => $bank,
|
|
|
'mobile' => $mobile,
|
|
|
'email' => $eamil,
|
|
|
'order_no' => $order_no,
|
|
|
'type' => $type,
|
|
|
'order_id' => $order['id'],
|
|
|
'price' => $order['total_price'],
|
|
|
'user_id' => $this->auth->id,
|
|
|
'bank' => $bank,
|
|
|
'mobile' => $mobile,
|
|
|
'email' => $eamil,
|
|
|
'order_no' => $order_no,
|
|
|
'type' => $type,
|
|
|
'order_id' => $order['id'],
|
|
|
'price' => $order['total_price'],
|
|
|
'user_id' => $this->auth->id,
|
|
|
];
|
|
|
$model = new Tax();
|
|
|
$model->allowField(true)->isUpdate(false)->save($data);
|
...
|
...
|
@@ -783,28 +783,28 @@ class User extends Api |
|
|
{
|
|
|
$ids = $this->request->post('ids');
|
|
|
//校验数据
|
|
|
$ids = explode(',',$ids);
|
|
|
foreach ($ids as $key => $value){
|
|
|
$ids = explode(',', $ids);
|
|
|
foreach ($ids as $key => $value) {
|
|
|
if (!is_numeric($value)) $this->error('ids参数不合法');
|
|
|
}
|
|
|
$model = new Tax();
|
|
|
$model->isUpdate()->save(['del_status' => 'hidden'],['id' => ['in',$ids]]);
|
|
|
$model->isUpdate()->save(['del_status' => 'hidden'], ['id' => ['in', $ids]]);
|
|
|
$this->success('SUCCESS');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 开发登录
|
|
|
* @ApiMethod (POST)
|
|
|
* @param string $account 账号
|
|
|
* @param string $account 账号
|
|
|
*/
|
|
|
public function developLogin()
|
|
|
{
|
|
|
$account = $this->request->post('account');
|
|
|
$account = $this->request->param('account');
|
|
|
if (!$account) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
$field = Validate::is($account, 'email') ? 'email' : (Validate::regex($account, '/^1\d{10}$/') ? 'mobile' : 'username');
|
|
|
$user = \app\common\model\User::get([$field => $account]);
|
|
|
$user = \app\common\model\User::get([$field => $account]);
|
|
|
if (!$user) {
|
|
|
$this->error('账号格式不正确');
|
|
|
}
|
...
|
...
|
@@ -821,14 +821,15 @@ class User extends Api |
|
|
* 测试
|
|
|
* @ApiInternal
|
|
|
*/
|
|
|
public function notice(){
|
|
|
$client = new Client();
|
|
|
$response = $client->request('POST', request()->domain().":2121/", [
|
|
|
public function notice()
|
|
|
{
|
|
|
$client = new Client();
|
|
|
$response = $client->request('POST', request()->domain() . ":2121/", [
|
|
|
'form_params' => [
|
|
|
'type' => 'publish',
|
|
|
'type' => 'publish',
|
|
|
'content' => '这个是推送的测试数据',
|
|
|
'to' => '',
|
|
|
]
|
|
|
'to' => '',
|
|
|
],
|
|
|
]);
|
|
|
halt($response->getBody()->getContents());
|
|
|
}
|
...
|
...
|
|