| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- /*
- * @Author: your name
- * @Date: 2021-05-08 17:28:23
- * @LastEditTime: 2021-05-19 10:57:22
- * @LastEditors: Please set LastEditors
- * @Description: In User Settings Edit
- * @FilePath: \admin_php\modules\client\models\v1\admin\CatForm.php
- */
- namespace app\modules\client\models\v1\admin;
- use app\constants\OptionSetting;
- use app\models\Option;
- use yii\base\Model;
- use yii\helpers\Json;
- class SettingForm extends Model
- {
- public $store_id = 1;
- public function get()
- {
- $key = [
- OptionSetting::STORE_NAME,
- OptionSetting::STORE_CONTACT_TEL,
- OptionSetting::STORE_DELIVERY_TIME,
- OptionSetting::STORE_AFTER_SALE_TIME
- ];
- $data = Option::get($key,$this->store_id);
- $value = [];
- foreach ($data as $val) {
- $value[$val['name']] = json_decode($val['value']) ?: $val['value'];
- }
- $value[OptionSetting::STORE_SEND_TYPE] = Option::get(OptionSetting::STORE_SEND_TYPE, $this->store_id, 'pay', Option::get(OptionSetting::STORE_SEND_TYPE, $this->store_id, 'store')['value'])['value'];
- $value[OptionSetting::STORE_PAYMENT] = Option::get(OptionSetting::STORE_PAYMENT, $this->store_id, 'pay', Option::get(OptionSetting::STORE_PAYMENT, $this->store_id, 'store')['value'])['value'];
- return [
- 'code' => 0,
- 'data' => $value
- ];
- }
- /**
- * 保存分类
- * @return array
- */
- public function save($type, $val)
- {
- if (empty($type)) {
- return [
- 'code' => 1,
- 'msg' => '参数错误'
- ];
- }
- $res = Option::set($type, $val);
- if ($res) {
- return [
- 'code' => 0,
- 'msg' => '保存成功'
- ];
- } else {
- return [
- 'code' => 1,
- 'msg' => "保存失败"
- ];
- }
- }
- }
|