From 147a64dc7f5cdfc335ab967adc622d95f14818f7 Mon Sep 17 00:00:00 2001 From: Anyon Date: Wed, 16 Sep 2020 19:28:26 +0800 Subject: [PATCH] =?UTF-8?q?=E9=82=AE=E8=B4=B9=E6=A8=A1=E6=9D=BF=20?= =?UTF-8?q?=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/data/controller/ShopTruckTemplate.php | 101 ++++++++ app/data/service/TruckService.php | 7 + app/data/view/shop_truck_template/form.html | 234 ++++++++++++++++++ .../view/shop_truck_template/form_item.html | 55 ++++ .../view/shop_truck_template/form_region.html | 98 ++++++++ app/data/view/shop_truck_template/index.html | 66 +++++ .../shop_truck_template/index_search.html | 28 +++ 7 files changed, 589 insertions(+) create mode 100644 app/data/controller/ShopTruckTemplate.php create mode 100644 app/data/view/shop_truck_template/form.html create mode 100644 app/data/view/shop_truck_template/form_item.html create mode 100644 app/data/view/shop_truck_template/form_region.html create mode 100644 app/data/view/shop_truck_template/index.html create mode 100644 app/data/view/shop_truck_template/index_search.html diff --git a/app/data/controller/ShopTruckTemplate.php b/app/data/controller/ShopTruckTemplate.php new file mode 100644 index 000000000..b7988756f --- /dev/null +++ b/app/data/controller/ShopTruckTemplate.php @@ -0,0 +1,101 @@ +title = '快递邮费配置'; + $query = $this->_query($this->table)->like('name'); + $query->where(['deleted' => 0])->order('sort desc,id desc')->page(); + } + + /** + * 添加配送邮费模板 + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function add() + { + $this->title = '添加配送邮费模板'; + $this->_form($this->table, 'form'); + } + + /** + * 表单数据处理 + * @param array $data + */ + protected function _form_filter(array &$data) + { + if (empty($data['code'])) { + $data['code'] = CodeExtend::uniqidDate(12, 'T'); + } + if ($this->request->isGet()) { + $this->citys = TruckService::instance()->region(2); + } + } + + public function region() + { + $this->citys = TruckService::instance()->region(2); + $this->fetch('form_region'); + } + + /** + * 修改快递模板 + * @auth true + * @throws \think\db\exception\DbException + */ + public function edit() + { + [$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('邮费规则配置成功!'); + } + +} \ No newline at end of file diff --git a/app/data/service/TruckService.php b/app/data/service/TruckService.php index ea44cff28..6fd21eb12 100644 --- a/app/data/service/TruckService.php +++ b/app/data/service/TruckService.php @@ -2,6 +2,7 @@ namespace app\data\service; +use think\admin\extend\DataExtend; use think\admin\Service; use think\admin\service\InterfaceService; @@ -31,6 +32,12 @@ class TruckService extends Service } + public function region($level = 3) + { + $items = $this->app->db->name('ShopTruckRegion')->where('level', '<=', $level)->column('id,pid,name', 'id'); + return DataExtend::arr2tree($items, 'id', 'pid', 'subs'); + } + /** * 楚才开放平台快递查询 * @param string $code 快递公司编号 diff --git a/app/data/view/shop_truck_template/form.html b/app/data/view/shop_truck_template/form.html new file mode 100644 index 000000000..fb21ed973 --- /dev/null +++ b/app/data/view/shop_truck_template/form.html @@ -0,0 +1,234 @@ +{extend name="../../admin/view/main"} + +{block name="content"} +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
可配送区域首件(个)运费(元)续件(个)续费(元)
+ + + ({{x.name}}) + + 编辑 + 删除 +
添加可配送区域和运费
+
+ {if auth('edit')} +
+ +
+ {/if} +
+
+ +
+
+
+
+
+
+ 全选 + 取消 +
+
+
+
+ + {{x.name}} +
+
+
+
+
+
+
+ 全选 + 取消 + +
+
+ +
+
+
+
+
+ + +
+
+
+
+ + + + +{/block} diff --git a/app/data/view/shop_truck_template/form_item.html b/app/data/view/shop_truck_template/form_item.html new file mode 100644 index 000000000..2ea51412c --- /dev/null +++ b/app/data/view/shop_truck_template/form_item.html @@ -0,0 +1,55 @@ +
+ + + {$group|default='邮费规则分组'} + + + + {if $group neq '默认邮费模板'} + + + + + {else} + + {/if} + +
+ +
订单总金额满足条件时将减免该订单的所有邮费(请谨慎配置)
+ +
+ +
+ +
+ +
+
+ +
+
+ 根据配送目的地的省份进行运费计算邮费(不在规则内的将使用默认邮费规则) +
+ +
+
首件(个)
+
运费(元)
+
续件(个)
+
续费(元)
+ + + + +
+
+ +
\ No newline at end of file diff --git a/app/data/view/shop_truck_template/form_region.html b/app/data/view/shop_truck_template/form_region.html new file mode 100644 index 000000000..e1195be88 --- /dev/null +++ b/app/data/view/shop_truck_template/form_region.html @@ -0,0 +1,98 @@ +
+
+
+
+
+
+ 全选 + 取消 +
+
+
+
+ + {{x.name}} +
+
+
+
+
+
+
+ 全选 + 取消 + +
+
+ +
+
+
+
{{items}}
+
+
+ + +
+
+
+ + + + diff --git a/app/data/view/shop_truck_template/index.html b/app/data/view/shop_truck_template/index.html new file mode 100644 index 000000000..91ec61e1b --- /dev/null +++ b/app/data/view/shop_truck_template/index.html @@ -0,0 +1,66 @@ +{extend name="../../admin/view/main"} + +{block name="button"} + + + + +{/block} + +{block name="content"} +
+ 注意:快递公司配置不能随意修改或删除,会影响到物流路径查询!如需添加新快递请联系客服! +
+
+
+ {include file='shop_truck_company/index_search'} + + {notempty name='list'} + + + + + + + + + + {/notempty} + + {foreach $list as $key=>$vo} + + + + + + + + {/foreach} + +
+ + + + 模板名称创建时间
+ + + + {$vo.name|default=''}{$vo.create_at|format_datetime} + + 编 辑 + + + 禁 用 + + 启 用 + + + 删 除 + +
+ {empty name='list'}没有记录哦{else}{$pagehtml|raw|default=''}{/empty} +
+
+{/block} \ No newline at end of file diff --git a/app/data/view/shop_truck_template/index_search.html b/app/data/view/shop_truck_template/index_search.html new file mode 100644 index 000000000..d7c0b0756 --- /dev/null +++ b/app/data/view/shop_truck_template/index_search.html @@ -0,0 +1,28 @@ +
+ 条件搜索 + +
+ +