提交其他文件
This commit is contained in:
130
app/api/logic/SubmitFormLogic.php
Normal file
130
app/api/logic/SubmitFormLogic.php
Normal file
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\logic;
|
||||
|
||||
use app\common\enum\notice\NoticeEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\teamaster\Teamaster;
|
||||
use app\common\model\teamaster\TeamasterUser;
|
||||
use app\common\model\teamaster\TeamasterReal;
|
||||
use app\common\model\teastore\TeaStoreReal;
|
||||
use app\common\service\sms\SmsDriver;
|
||||
use think\facade\Db;
|
||||
|
||||
class SubmitFormLogic extends BaseLogic
|
||||
{
|
||||
|
||||
public static function addTeamaster($data){
|
||||
Db::startTrans();
|
||||
try {
|
||||
// 校验验证码
|
||||
$smsDriver = new SmsDriver();
|
||||
if (!$smsDriver->verify($data['mobile'], $data['code'], NoticeEnum::FIND_MOBILE_CAPTCHA)) {
|
||||
throw new \Exception('验证码错误');
|
||||
}
|
||||
|
||||
$license_img = isset($data['license_img']) ? $data['license_img'] : '';
|
||||
$certificate = isset($data['certificate']) ? $data['certificate'] : '';
|
||||
$real = TeamasterReal::where([
|
||||
'mobile'=>$data['mobile'],
|
||||
])->whereIn('status',[0,1])->find();
|
||||
if($real){
|
||||
throw new \Exception('当前手机号已申请');
|
||||
}
|
||||
if($data['gender'] == "男"){
|
||||
$data['gender'] = 1;
|
||||
}elseif($data['gender'] == "女"){
|
||||
$data['gender'] = 2;
|
||||
}
|
||||
$data = [
|
||||
'license_img'=>$license_img,
|
||||
'username'=>$data['username'],
|
||||
'gender'=>$data['gender'],
|
||||
'both'=>$data['both'],
|
||||
'user_id'=>$data['user_id'],
|
||||
'height'=>$data['height'],
|
||||
'weight'=>$data['weight'],
|
||||
'hobby_introduce'=>$data['hobby_introduce'],
|
||||
'city_id'=>$data['city_id'],
|
||||
'avatar'=>$data['avatar'],
|
||||
'certificate'=>$certificate,
|
||||
'mobile'=>$data['mobile'],
|
||||
'create_time'=>time()
|
||||
];
|
||||
|
||||
TeamasterReal::create($data);
|
||||
Db::commit();
|
||||
return [];
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function addStore($data){
|
||||
Db::startTrans();
|
||||
try {
|
||||
// 校验验证码
|
||||
$smsDriver = new SmsDriver();
|
||||
if (!$smsDriver->verify($data['mobile'], $data['code'], NoticeEnum::FIND_MOBILE_CAPTCHA)) {
|
||||
throw new \Exception('验证码错误');
|
||||
}
|
||||
|
||||
$license_img = isset($data['license_img']) ? $data['license_img'] : '';
|
||||
$operation_type= isset($data['operation_type']) ? $data['operation_type'] : '';
|
||||
$real = TeaStoreReal::where([
|
||||
'mobile'=>$data['mobile'],
|
||||
])->whereIn('status',[0,1])->find();
|
||||
if($real){
|
||||
throw new \Exception('当前手机号已申请');
|
||||
}
|
||||
|
||||
$data = [
|
||||
'license_img'=>$license_img,
|
||||
'username'=>$data['username'],
|
||||
'address'=>$data['address'],
|
||||
'user_id'=>$data['user_id'],
|
||||
'suggest'=>$data['suggest'],
|
||||
'city_id'=>$data['city_id'],
|
||||
'operation_type'=>$operation_type,
|
||||
'mobile'=>$data['mobile'],
|
||||
'create_time'=>time()
|
||||
];
|
||||
|
||||
TeaStoreReal::create($data);
|
||||
Db::commit();
|
||||
return [];
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function teamasterRealStatus($data){
|
||||
$real = TeamasterReal::where([
|
||||
'user_id'=>$data['user_id'],
|
||||
])->find();
|
||||
$status = 3;
|
||||
if($real){
|
||||
$status = $real['status'];
|
||||
}
|
||||
return ['status'=>$status];
|
||||
}
|
||||
public static function StoreRealStatus($data){
|
||||
$real = TeaStoreReal::where([
|
||||
'user_id'=>$data['user_id'],
|
||||
])->find();
|
||||
$status = 3;
|
||||
if($real){
|
||||
$status = $real['status'];
|
||||
}
|
||||
|
||||
return ['status'=>$status];
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user