123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- // +----------------------------------------------------------------------
- // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
- // +----------------------------------------------------------------------
- // | Author: 萤火科技 <admin@yiovo.com>
- // +----------------------------------------------------------------------
- declare (strict_types = 1);
- namespace app\store\model;
- use app\common\model\DeliveryLimit as DeliveryLimitModel;
- /**
- * 配送模板区域及运费模型
- * Class DeliveryRule
- * @package app\store\model
- */
- class DeliveryLimit extends DeliveryLimitModel
- {
- /**
- * 添加新记录
- * @param array $data
- * @return bool
- */
- public function add(array $data)
- {
- // 表单验证
- if (!$this->onValidate($data)) {
- return false;
- }
- $upd = [
- 'region' => $data['region'],
- 'region_text' => $data['region_text'],
- 'store_id' => self::$storeId
- ];
- $this->save($upd);
- return true;
- }
- /**
- * 编辑记录
- * @param array $data
- * @return bool
- */
- public function edit(array $data)
- {
- // 表单验证
- if (!$this->onValidate($data)) {
- return false;
- }
- $upd = [
- 'limit_id' => $data['limit_id'],
- 'region' => $data['region'],
- 'region_text' => $data['region_text']
- ];
- $this->save($upd);
- return true;
- }
- /**
- * 表单验证
- * @param $data
- * @return bool
- */
- private function onValidate(array $data)
- {
- if (!isset($data['region']) || empty($data['region'])) {
- $this->error = '请选择可配送区域';
- return false;
- }
- return true;
- }
- }
|