| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- /*
- * @Author: 凯
- * @Date: 2021-04-26 17:20:17
- * @LastEditTime: 2021-04-26 17:43:35
- * @LastEditors: Please set LastEditors
- * @Description: In User Settings Edit
- * @FilePath: \admin_php\modules\client\models\v1\ShopApplyForm.php
- */
- namespace app\modules\client\models\v1;
- use app\models\Shop;
- use app\models\ShopPic;
- use app\modules\client\models\ApiModel;
- class ShopApplyForm extends ApiModel
- {
- public $id;
- public $name;
- public $mobile;
- public $address;
- public $longitude;
- public $latitude;
- public $cover_url;
- public $province;
- public $city;
- public $district;
- public function rules()
- {
- return [
- [['id'], 'integer'],
- [['name', 'mobile', 'address', 'longitude', 'latitude', 'cover_url', 'province', 'city', 'district'], 'string'],
- [['name', 'mobile', 'address', 'longitude', 'latitude', 'cover_url', 'province', 'city', 'district'], 'required']
- ];
- }
- public function attributeLabels()
- {
- return [
- 'name' => '名称',
- 'mobile' => '联系电话',
- 'address' => '详细地址',
- 'longitude' => '经纬度',
- 'latitude' => '经纬度',
- 'cover_url' => '头像',
- 'province' => '省',
- 'city' => '市',
- 'district' => '区',
- ];
- }
- public function search()
- {
- if (!$this->validate()) {
- return [
- 'code' => 1,
- 'msg' => $this->getErrorSummary(false)[0],
- ];
- }
- $shop = Shop::findOne(['user_id' => get_user_id(), 'is_delete' => 0]);
- if(empty($shop)) {
- $shop = new Shop();
- $shop->store_id = get_store_id();
- $shop->user_id = get_user_id();
- }
- $shop->shop_audit = 0;
- $shop->address = $this->address;
- $shop->name = $this->name;
- $shop->mobile = $this->mobile;
- $shop->cover_url = $this->cover_url;
- $shop->pic_url = $this->cover_url;
- $shop->province = $this->province;
- $shop->city = $this->city;
- $shop->district = $this->district;
- $shop->longitude = $this->longitude;
- $shop->latitude = $this->latitude;
- if ($shop->save()) {
- return [
- 'code' => 0,
- 'msg' => '保存成功'
- ];
- } else {
- return [
- 'code' => 1,
- 'msg' => $shop->errors[0]
- ];
- }
-
- }
- }
|