diff --git a/app/api/controller/LocalStore.php b/app/api/controller/LocalStore.php index a64fffc5..f0faf74b 100755 --- a/app/api/controller/LocalStore.php +++ b/app/api/controller/LocalStore.php @@ -15,7 +15,7 @@ use think\facade\Db; class LocalStore extends Api { - public $like_not_need_login = ['makeMyPayImage', 'getLocalShopById', 'getLocalList', 'getLocation']; + public $like_not_need_login = ['makeMyPayImage', 'getLocalShopById', 'getLocalList', 'getLocation', 'addPostStation']; public function getLocalStore() { @@ -242,10 +242,6 @@ class LocalStore extends Api $model = new LocalStoreLogic; $result['distance'] = round($model->distance($result['latitude'], $result['longitude'], $latitude, $longitude) / 1000, 2) . "公里"; $result['header_image'] = FileConfig::get('aliyunoss.domain') . 'local_life_shop/' . $result['header_image']; - - if ($result['post_station']) { - $result['post_station'] = json_decode($result['post_station'], true); - } return JsonServer::success('成功获取', $result); } @@ -354,11 +350,11 @@ class LocalStore extends Api } // 设置自提站点 - public function setPostStation() + public function addPostStation() { try { $post = $this->request->post(); - LocalStoreLogic::setPostStation($post, $this->user_id); + LocalStoreLogic::addPostStation($post, $this->user_id); return JsonServer::success('设置成功'); } catch (\Exception $e) { return JsonServer::error($e->getMessage()); diff --git a/app/api/logic/LocalStoreLogic.php b/app/api/logic/LocalStoreLogic.php index ffada980..5f0fd15f 100644 --- a/app/api/logic/LocalStoreLogic.php +++ b/app/api/logic/LocalStoreLogic.php @@ -6,8 +6,10 @@ use app\common\basics\Logic; use app\common\model\LocalStore; use app\common\model\localstore\LocalGoodsStore; use app\common\model\LocalStoreOrder; +use app\common\model\LocalStorePostStation; use think\facade\Db; use think\facade\Config; + class LocalStoreLogic extends Logic { public function getLocalList($data) @@ -353,7 +355,7 @@ class LocalStoreLogic extends Logic ]; } - public static function setPostStation($post, $user_id) + public static function addPostStation($post, $user_id) { if (!$post['province'] && !$post['city'] && !$post['area'] && !$post['address']) { throw new \Exception('未选择区域'); @@ -366,10 +368,7 @@ class LocalStoreLogic extends Logic $lstore_id = $post['lstore_id']; unset($post['lstore_id']); - $result = LocalStore::where(['user_id' => $user_id, 'lstore_id' => $lstore_id])->update([ - 'post_station' => json_encode($post, JSON_UNESCAPED_UNICODE), - 'update_time' => date('Y-m-d H:i:s') - ]); + $result = LocalStorePostStation::where(['user_id' => $user_id, 'lstore_id' => $lstore_id])->insert($post); if ($result) { return true; diff --git a/app/common/model/LocalStore.php b/app/common/model/LocalStore.php index 1bccf927..07826eb8 100755 --- a/app/common/model/LocalStore.php +++ b/app/common/model/LocalStore.php @@ -13,4 +13,9 @@ class LocalStore extends Model { return $this->belongsTo(User::class, 'user_id', 'id')->field('id, nickname'); } + + public function post_station() + { + + } } \ No newline at end of file diff --git a/app/common/model/LocalStorePostStation.php b/app/common/model/LocalStorePostStation.php new file mode 100755 index 00000000..a41efcf7 --- /dev/null +++ b/app/common/model/LocalStorePostStation.php @@ -0,0 +1,11 @@ +