diff --git a/app/data/controller/ShopTruckCompany.php b/app/data/controller/ShopTruckCompany.php index a92b5525d..90fc3dc83 100644 --- a/app/data/controller/ShopTruckCompany.php +++ b/app/data/controller/ShopTruckCompany.php @@ -3,7 +3,6 @@ namespace app\data\controller; use app\data\service\TruckService; -use app\store\service\OpenCuciService; use think\admin\Controller; use think\admin\service\SystemService; use think\exception\HttpResponseException; @@ -75,7 +74,10 @@ class ShopTruckCompany extends Controller */ public function state() { - $this->_save($this->table); + $this->_save($this->table, $this->_vali([ + 'status.in:0,1' => '状态值范围异常!', + 'status.require' => '状态值不能为空!', + ])); } /** diff --git a/app/data/controller/ShopTruckTemplate.php b/app/data/controller/ShopTruckTemplate.php index b7988756f..a360aca69 100644 --- a/app/data/controller/ShopTruckTemplate.php +++ b/app/data/controller/ShopTruckTemplate.php @@ -5,10 +5,9 @@ namespace app\data\controller; use app\data\service\TruckService; use think\admin\Controller; use think\admin\extend\CodeExtend; -use think\admin\extend\DataExtend; /** - * 配送运费模板管理 + * 邮费模板管理 * Class ShopTruckTemplate * @package app\data\controller */ @@ -31,12 +30,14 @@ class ShopTruckTemplate extends Controller public function index() { $this->title = '快递邮费配置'; - $query = $this->_query($this->table)->like('name'); + $query = $this->_query($this->table); + $query->like('code,name')->dateBetween('create_at'); $query->where(['deleted' => 0])->order('sort desc,id desc')->page(); } /** * 添加配送邮费模板 + * @auth true * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException @@ -44,7 +45,20 @@ class ShopTruckTemplate extends Controller public function add() { $this->title = '添加配送邮费模板'; - $this->_form($this->table, 'form'); + $this->_form($this->table, 'form', 'code'); + } + + /** + * 编辑配送邮费模板 + * @auth true + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function edit() + { + $this->title = '编辑配送邮费模板'; + $this->_form($this->table, 'form', 'code'); } /** @@ -61,41 +75,38 @@ class ShopTruckTemplate extends Controller } } - public function region() + /** + * 表单结果处理 + * @param boolean $result + */ + protected function _form_result($result) { - $this->citys = TruckService::instance()->region(2); - $this->fetch('form_region'); + if ($result && $this->request->isPost()) { + $this->success('邮费模板保存成功!', 'javascript:history.back()'); + } } /** - * 修改快递模板 + * 启用或禁用邮费模板 * @auth true * @throws \think\db\exception\DbException */ - public function edit() + public function state() { - [$list, $idxs, $post] = [[], [], $this->request->post()]; - foreach (array_keys($post) as $key) if (stripos($key, 'order_reduction_state_') !== false) { - $idxs[] = str_replace('order_reduction_state_', '', $key); - } - foreach (array_unique($idxs) as $index) if (!empty($post["rule_{$index}"])) $list[] = [ - 'rule' => ',' . join(',', $post["rule_{$index}"]) . ',', - // 订单满减配置 - 'order_reduction_state' => $post["order_reduction_state_{$index}"], - 'order_reduction_price' => $post["order_reduction_price_{$index}"], - // 首件邮费配置 - 'first_number' => $post["first_number_{$index}"], - 'first_price' => $post["first_price_{$index}"], - // 首件邮费配置 - 'next_number' => $post["next_number_{$index}"], - 'next_price' => $post["next_price_{$index}"], - // 默认邮费规则 - 'is_default' => $post["is_default_{$index}"], - ]; - if (empty($list)) $this->error('请配置有效的邮费规则'); - $this->app->db->name($this->table)->where('1=1')->delete(); - $this->app->db->name($this->table)->insertAll($list); - $this->success('邮费规则配置成功!'); + $this->_save($this->table, $this->_vali([ + 'status.in:0,1' => '状态值范围异常!', + 'status.require' => '状态值不能为空!', + ]), 'code'); + } + + /** + * 删除邮费模板 + * @auth true + * @throws \think\db\exception\DbException + */ + public function remove() + { + $this->_delete($this->table, 'code'); } } \ No newline at end of file diff --git a/app/data/view/shop_truck_template/form.html b/app/data/view/shop_truck_template/form.html index 2fdfd3b5f..80f226428 100644 --- a/app/data/view/shop_truck_template/form.html +++ b/app/data/view/shop_truck_template/form.html @@ -2,7 +2,7 @@ {block name="content"}