|
|
|
@ -16,6 +16,7 @@ use app\admin\model\Page as PageModel; |
|
|
|
|
use app\admin\model\store\User; |
|
|
|
|
use app\common\model\Store as StoreModel; |
|
|
|
|
use app\admin\model\store\User as StoreUserModel; |
|
|
|
|
use app\common\model\User as UserModel; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 商家记录表模型 |
|
|
|
@ -93,29 +94,42 @@ class Store extends StoreModel |
|
|
|
|
public function auditStore(array $data) |
|
|
|
|
{ |
|
|
|
|
$storeInfo = $this->toArray(); |
|
|
|
|
if($storeInfo['status'] != 0){ |
|
|
|
|
if ($storeInfo['status'] != 0) { |
|
|
|
|
$this->error = '状态异常,请勿重复操作'; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
$user = User::where(['user_id' => $storeInfo['user_id']])->find(); |
|
|
|
|
if (StoreUserModel::checkExist($user['mobile'])) { |
|
|
|
|
$user = UserModel::where(['user_id' => $storeInfo['user_id']])->find(); |
|
|
|
|
if (empty($user) || empty($user->mobile)) { |
|
|
|
|
$this->error = '用户不存在,或未绑定手机'; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if (StoreUserModel::checkExist($user->mobile)) { |
|
|
|
|
$this->error = '商家用户名已存在'; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if($data['status'] == 1){ |
|
|
|
|
if ($data['status'] == 1) { |
|
|
|
|
$data['user_id'] = $storeInfo['user_id']; |
|
|
|
|
$data['mobile'] = $user->mobile; |
|
|
|
|
return $this->transaction(function () use ($data) { |
|
|
|
|
// 添加小程序记录 |
|
|
|
|
$data['is_recycle'] = 0; |
|
|
|
|
if ($status = $this->save($data)) { |
|
|
|
|
$update['is_recycle'] = 0; |
|
|
|
|
$update['status'] = 1; |
|
|
|
|
if ($status = $this->save($update)) { |
|
|
|
|
// 新增商家用户信息 |
|
|
|
|
(new StoreUserModel)->add((int)$this['store_id'], $data); |
|
|
|
|
$storeUser = [ |
|
|
|
|
'user_name' => $data['mobile'], |
|
|
|
|
'password' => $data['mobile'], |
|
|
|
|
]; |
|
|
|
|
(new StoreUserModel)->add((int)$this['store_id'], $storeUser); |
|
|
|
|
// 新增默认首页数据 |
|
|
|
|
(new PageModel)->insertDefault((int)$this['store_id']); |
|
|
|
|
//指定用户类型更改为商家 |
|
|
|
|
(new UserModel)->where(['user_id' => $data['user_id']])->update(['user_type' => 40]); |
|
|
|
|
} |
|
|
|
|
return $status; |
|
|
|
|
}); |
|
|
|
|
}else{ |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
return $this->save(['status' => 2]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|