| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\plugins\food\controllers;
- use app\models\Option;
- use app\models\District;
- use app\models\Store;
- use app\utils\Alipay\AlipayProfit;
- class SettingController extends BaseController
- {
- public function actionGetSetting()
- {
- $data = Option::get('food_book', get_store_id(), 'store', [
- 'name' => '',
- 'logo' => '',
- 'address' => '',
- 'phone' => '',
- 'service' => '',
- 'open_time' => '',
- 'categroy' => 'B0001',
- 'business_address' => [],
- 'switch' => 1,
- 'person' => 5,
- 'time' => [],
- 'store_pic' => [],
- 'tips' => '',
- 'say_time' => '',
- 'description' => ''
- ]);
- $data = is_string($data['value']) ? json_decode($data['value'], true) : $data['value'];
- if (!empty($data['business_address'])) {
- $province_code = District::findOne(['adcode' => $data['business_address']['province_code']]);
- $city_code = District::findOne(['adcode' => $data['business_address']['city_code']]);
- $district_code = District::findOne(['adcode' => $data['business_address']['district_code']]);
- $data['business_address'] = [
- 'province_id' => $province_code->id,
- 'city_id' => $city_code->id,
- 'district_id' => $district_code->id,
- ];
- }
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ];
- }
- public function actionSetLogo()
- {
- $logo = post_params('logo');
- if (!$logo) {
- return [
- 'code' => 1,
- 'msg' => '缺少必要参数',
- ];
- }
- $data = Option::get('food_book', get_store_id(), 'store', [
- 'name' => '',
- 'logo' => '',
- 'address' => '',
- 'phone' => '',
- 'service' => '',
- 'open_time' => '',
- 'categroy' => 'B0001',
- 'business_address' => [],
- 'switch' => 1,
- 'person' => 5,
- 'time' => [],
- 'store_pic' => [],
- 'tips' => '',
- 'say_time' => '',
- ]);
- $data = is_string($data['value']) ? json_decode($data['value'], true) : $data['value'];
- $data['logo'] = $logo;
- Option::set('food_book', json_encode($data), get_store_id(), 'store');
- return [
- 'code' => 0,
- 'msg' => '保存成功',
- ];
- }
- public function actionSetSetting()
- {
- $data = post_params('data');
- $cityInfo = post_params('cityInfo');
- if (!$data || !$cityInfo) {
- return [
- 'code' => 1,
- 'msg' => '缺少必要参数',
- ];
- }
- $province_code = District::findOne($cityInfo['province_id']);
- $city_code = District::findOne($cityInfo['city_id']);
- $district_code = District::findOne($cityInfo['district_id']);
- $data['business_address'] = [
- 'province_code' => $province_code->adcode,
- 'city_code' => $city_code->adcode,
- 'district_code' => $district_code->adcode,
- ];
- // 创建蚂蚁门店
- $store = Store::findOne(get_store_id());
- if (empty($store->shop_id)) {
- $array = [
- 'business_address' => [
- 'province_code' => $province_code->adcode,
- 'city_code' => $city_code->adcode,
- 'district_code' => $district_code->adcode,
- 'address' => $data['address'],
- ],
- 'contact_mobile' => $data['phone'],
- 'shop_category' => $data['category'],
- 'store_id' => 'NO' . get_store_id(),
- 'shop_type' => '01',
- 'ip_role_id' => Option::getAlipayConfig()['user_id'],
- 'shop_name' => $data['name']
- ];
- $res = AlipayProfit::shop_create($array);
- \Yii::warning(['<========= 创建蚂蚁门店 ==========>', $array, $res]);
- // Todo 暂时不返回
- // if ($res['code'] != 0) {
- // return [
- // 'code' => 1,
- // 'msg' => $res['msg'],
- // ];
- // }
- }
- Option::set('food_book', json_encode($data), get_store_id(), 'store');
- return [
- 'code' => 0,
- 'msg' => '保存成功',
- ];
- }
- }
|