| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\admin\models;
- use app\models\OrderRulesBuyerLocation;
- use yii\base\Model;
- use yii\helpers\Json;
- class OrderRulesBuyerLocationForm extends Model
- {
- public $rule;
- public $store_id = 1;
- public $province_list;
- /**
- * 保存运费规则
- * @return array
- */
- public function save()
- {
- if (empty($this->rule) || empty($this->rule['name'])) {
- return [
- 'code' => 1,
- 'msg' => '规则名称不能为空'
- ];
- }
- $model = OrderRulesBuyerLocation::findOne($this->rule['id'])?: new OrderRulesBuyerLocation();
- $model->store_id = $this->store_id;
- $model->attributes = $this->rule;
- $model->detail = Json::encode($this->province_list);
- if ($model->save()) {
- return [
- 'code' => 0,
- 'msg' => '保存成功'
- ];
- } else {
- return [
- 'code' => 1,
- 'msg' => '保存失败',
- 'err' => $model->errors
- ];
- }
- }
- }
|