diff --git a/app/api/controller/Wholesaler.php b/app/api/controller/Wholesaler.php index cca416ee..44d90bb4 100644 --- a/app/api/controller/Wholesaler.php +++ b/app/api/controller/Wholesaler.php @@ -109,13 +109,17 @@ class Wholesaler extends Controller if (!$business) { return $this->renderError('经营类目不能为空'); } + $avatar_id = intval($this->request->post('avatar_id')); + if (!$avatar_id) { + return $this->renderError('头像不能为空'); + } // 验证短信验证码是否匹配 try { CaptchaApi::checkSms($mobile_code, $mobile); } catch (Exception $e) { return $this->renderError($e->getMessage() ?: '短信验证码不正确'); } - $data = compact('company_name', 'credit_code', 'city_id', 'province_id', 'door_img_id', 'business', 'card_no'); + $data = compact('company_name', 'credit_code', 'city_id', 'province_id', 'door_img_id', 'business', 'card_no', 'avatar_id'); $data = array_merge($data, compact('username', 'mobile', 'card_back_img_id', 'card_front_img_id', 'license_img_id')); $data['total_price'] = $priceInfo['price']; $data['pay_price'] = $priceInfo['price']; @@ -135,7 +139,7 @@ class Wholesaler extends Controller */ public function applyInfo(): Json { - $info = Apply::info(['cardFrontImg', 'cardBackImg', 'licenseImg', 'doorImg']); + $info = Apply::info(['cardFrontImg', 'cardBackImg', 'licenseImg', 'doorImg', 'avatarImg']); if (!empty($info->cardFrontImg)) { unset($info->cardFrontImg); } @@ -148,6 +152,9 @@ class Wholesaler extends Controller if (!empty($info->doorImg)) { unset($info->doorImg); } + if (!empty($info->avatarImg)) { + unset($info->avatarImg); + } return $this->renderSuccess(compact('info')); } @@ -211,13 +218,17 @@ class Wholesaler extends Controller if (!$business) { return $this->renderError('经营类目不能为空'); } + $avatar_id = intval($this->request->post('avatar_id')); + if (!$avatar_id) { + return $this->renderError('头像不能为空'); + } // 验证短信验证码是否匹配 try { CaptchaApi::checkSms($mobile_code, $mobile); } catch (Exception $e) { return $this->renderError($e->getMessage() ?: '短信验证码不正确'); } - $data = compact('company_name', 'credit_code', 'city_id', 'province_id', 'door_img_id', 'business', 'card_no'); + $data = compact('company_name', 'credit_code', 'city_id', 'province_id', 'door_img_id', 'business', 'card_no', 'avatar_id'); $data = array_merge($data, compact('username', 'mobile', 'card_back_img_id', 'card_front_img_id', 'license_img_id')); if ((new Apply())->edit($data)) { return $this->renderSuccess('操作成功'); diff --git a/app/api/service/wholesaler/PaySuccess.php b/app/api/service/wholesaler/PaySuccess.php index 3c74d79b..528212f7 100644 --- a/app/api/service/wholesaler/PaySuccess.php +++ b/app/api/service/wholesaler/PaySuccess.php @@ -338,6 +338,7 @@ class PaySuccess extends BaseService $add['credit_code'] = $orderInfo['credit_code']; $add['business'] = $orderInfo['business']; $add['user_id'] = $orderInfo['user_id']; + $add['avatar_id'] = $orderInfo['avatar_id']; $info = Apply::detail(['user_id' => $orderInfo['user_id']]); if (empty($info->id)) { (new Apply())->add($add); diff --git a/app/common/model/wholesaler/Apply.php b/app/common/model/wholesaler/Apply.php index 5a0e8582..e3fc5fea 100644 --- a/app/common/model/wholesaler/Apply.php +++ b/app/common/model/wholesaler/Apply.php @@ -72,6 +72,16 @@ class Apply extends BaseModel ->bind(['door_img' => 'preview_url']); } + /** + * 门头照片 + * @return HasOne + */ + public function avatarImg(): HasOne + { + return $this->hasOne(UploadFile::class, 'file_id', 'avatar_id') + ->bind(['avatar_img' => 'preview_url']); + } + /** * @notes:地区名称 * @param $value