wang hou sheng 8 months ago
parent 7ffcb0d2c5
commit ea2bd4aaad
  1. 37
      app/api/controller/dealer/Apply.php
  2. 35
      app/api/model/dealer/Apply.php

@ -102,4 +102,41 @@ class Apply extends Controller
}
return $this->renderError($model->getError() ?: '提交失败');
}
/**
* @notes:更新申请服务商
* @return Json
* @throws BaseException
* @author: wanghousheng
*/
public function editApplyProviders(): Json
{
$real_name = $this->request->post('real_name');
if (!$real_name) {
return $this->renderError('联系人不能为空');
}
$mobile = $this->request->post('mobile');
if (empty($mobile)) {
return $this->renderError('联系电话不能为空');
}
$shop_type = intval($this->request->post('shop_type', 10));
$shop_name = $this->request->post('shop_name');
if (empty($shop_name)) {
return $this->renderError('店铺名称不能为空');
}
$business = $this->request->post('business');
if (empty($business)) {
return $this->renderError('经营类型不能为空');
}
$city = $this->request->post('city');
if (empty($city)) {
return $this->renderError('所在城市不能为空');
}
$data = compact('business', 'city', 'real_name', 'mobile', 'shop_type', 'shop_name', 'business', 'city');
$model = new DealerApplyModel;
if ($model->editApplyServiceProviders($data)) {
return $this->renderSuccess('提交成功');
}
return $this->renderError($model->getError() ?: '提交失败');
}
}

@ -123,6 +123,41 @@ class Apply extends ApplyModel
return $this->add($data);
}
/**
* @notes:更新服务商申请
* @param $data
* @return bool
* @throws BaseException
* @author: wanghousheng
*/
public function editApplyServiceProviders($data): bool
{
// 当前用户ID
$userId = UserService::getCurrentLoginUserId();
$info = self::get(['user_id' => $userId]);
if ($info->isEmpty()) {
throwError('申请记录不存在');
}
$info = $info->toArray();
if ($info['apply_status'] == ApplyStatusEnum::PASS) {
throwError('您已通过申请,请勿重复提交');
}
// 数据整理
$data = [
'real_name' => trim($data['real_name']),
'mobile' => trim($data['mobile']),
'shop_type' => $data['shop_type'],
'shop_name' => $data['shop_name'],
'business' => $data['business'],
'city' => $data['city'],
];
$res = $this->where(['user_id' => $userId])->update($data);
if ($res->getError()) {
return false;
}
return true;
}
/**
* 更新分销商申请信息
* @param array $data

Loading…
Cancel
Save