From 988532dc3fc025fbfa2eb552f0e57abdca31188f Mon Sep 17 00:00:00 2001 From: Anyon Date: Sat, 9 Jan 2021 18:42:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E9=A1=B9=E7=9B=AE=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/data/controller/StoreItem.php | 91 ---------------------- app/data/controller/StoreUsed.php | 48 ------------ app/data/controller/StoreUser.php | 83 -------------------- app/data/controller/api/auth/Address.php | 2 +- app/data/controller/api/auth/Order.php | 49 ++++++++++-- app/data/service/PaymentService.php | 5 +- app/data/service/UserService.php | 2 +- app/data/view/store_item/form.html | 23 ------ app/data/view/store_item/index.html | 68 ---------------- app/data/view/store_item/index_search.html | 35 --------- app/data/view/store_used/form.html | 23 ------ app/data/view/store_used/index.html | 68 ---------------- app/data/view/store_used/index_search.html | 35 --------- app/data/view/store_user/form.html | 23 ------ app/data/view/store_user/index.html | 68 ---------------- app/data/view/store_user/index_search.html | 35 --------- vendor/composer/autoload_classmap.php | 3 - vendor/composer/autoload_static.php | 3 - vendor/services.php | 2 +- 19 files changed, 50 insertions(+), 616 deletions(-) delete mode 100644 app/data/controller/StoreItem.php delete mode 100644 app/data/controller/StoreUsed.php delete mode 100644 app/data/controller/StoreUser.php delete mode 100644 app/data/view/store_item/form.html delete mode 100644 app/data/view/store_item/index.html delete mode 100644 app/data/view/store_item/index_search.html delete mode 100644 app/data/view/store_used/form.html delete mode 100644 app/data/view/store_used/index.html delete mode 100644 app/data/view/store_used/index_search.html delete mode 100644 app/data/view/store_user/form.html delete mode 100644 app/data/view/store_user/index.html delete mode 100644 app/data/view/store_user/index_search.html diff --git a/app/data/controller/StoreItem.php b/app/data/controller/StoreItem.php deleted file mode 100644 index f6ee6c067..000000000 --- a/app/data/controller/StoreItem.php +++ /dev/null @@ -1,91 +0,0 @@ -title = '实体门店管理'; - $query = $this->_query($this->table); - // code,name,cover,slider,username,phone,remark,sort,type,status,deleted,business_hours_start,business_hours_after - ### 地理位置标志 - // region_province,region_city,region_area,region_address,region_longitude,region_latitude - ### 字段描述 - // type 0 支持自提,1 不支持自提 - // status 0 禁用,0 启用 - // business_weeks_works // 每周工作 - // business_hours_start // 开始时间 - // business_hours_after // 结束时间 - $query->like('name')->equal('status')->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 - */ - public function add() - { - $this->_form($this->table, 'form'); - } - - /** - * 编辑实体门店 - * @auth true - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function edit() - { - $this->_form($this->table, 'form'); - } - - /** - * 修改实体门店状态 - * @auth true - * @throws \think\db\exception\DbException - */ - public function state() - { - $this->_save($this->table, $this->_vali([ - 'status.in:0,1' => '状态值范围异常!', - 'status.require' => '状态值不能为空!', - ])); - } - - /** - * 删除实体门店 - * @auth true - * @throws \think\db\exception\DbException - */ - public function remove() - { - $this->_delete($this->table); - } -} \ No newline at end of file diff --git a/app/data/controller/StoreUsed.php b/app/data/controller/StoreUsed.php deleted file mode 100644 index d79444cc7..000000000 --- a/app/data/controller/StoreUsed.php +++ /dev/null @@ -1,48 +0,0 @@ -title = '门店核销管理'; - $query = $this->_query($this->table); - $query->order('id desc')->equal('status')->dateBetween('create_at')->page(); - } - - /** - * 修改核销状态 - * @auth true - * @throws \think\db\exception\DbException - */ - public function state() - { - $this->_save($this->table, $this->_vali([ - 'status.in:0,1' => '状态值范围异常!', - 'status.require' => '状态值不能为空!', - ])); - } - -} \ No newline at end of file diff --git a/app/data/controller/StoreUser.php b/app/data/controller/StoreUser.php deleted file mode 100644 index 1c96b22eb..000000000 --- a/app/data/controller/StoreUser.php +++ /dev/null @@ -1,83 +0,0 @@ -title = '门店店员管理'; - $query = $this->_query($this->table); - $query->like('name')->equal('status')->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 - */ - public function add() - { - $this->_form($this->table, 'form'); - } - - /** - * 编辑门店店员 - * @auth true - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function edit() - { - $this->_form($this->table, 'form'); - } - - /** - * 修改门店店员状态 - * @auth true - * @throws \think\db\exception\DbException - */ - public function state() - { - $this->_save($this->table, $this->_vali([ - 'status.in:0,1' => '状态值范围异常!', - 'status.require' => '状态值不能为空!', - ])); - } - - /** - * 删除门店店员 - * @auth true - * @throws \think\db\exception\DbException - */ - public function remove() - { - $this->_delete($this->table); - } - -} \ No newline at end of file diff --git a/app/data/controller/api/auth/Address.php b/app/data/controller/api/auth/Address.php index 89613edb6..0b320115e 100644 --- a/app/data/controller/api/auth/Address.php +++ b/app/data/controller/api/auth/Address.php @@ -26,9 +26,9 @@ class Address extends Auth { $data = $this->_vali([ 'uid.value' => $this->uuid, + 'type.default' => 0, 'code.default' => '', 'idcode.default' => '', - 'type.default' => 0, 'type.in:0,1' => '地址状态不在范围!', 'name.require' => '收货姓名不能为空!', 'phone.mobile' => '收货手机格式错误!', diff --git a/app/data/controller/api/auth/Order.php b/app/data/controller/api/auth/Order.php index f10bab8ea..29324b2e5 100644 --- a/app/data/controller/api/auth/Order.php +++ b/app/data/controller/api/auth/Order.php @@ -114,13 +114,16 @@ class Order extends Auth $order['amount_total'] = $order['amount_goods'] - $order['amount_reduct']; // 支付金额不能为零 if ($order['amount_total'] <= 0) $order['amount_total'] = 0.01; - // 订单数据写入 + // 写入订单商品数据 $this->app->db->name('ShopOrder')->insert($order); $this->app->db->name('ShopOrderItem')->insertAll($items); - // 同步商品库存及销量 + // 同步商品库存销量 foreach ($codes as $code) GoodsService::instance()->syncStock($code); - // 返回订单数据给接口 + // 返回订单数据接口 $order['items'] = $items; + // 触发订单创建事件 + $this->app->event->trigger('ShopOrderCreate', $order['order_no']); + // 返回处理成功数据 $this->success('预购订单创建成功,请补全收货地址', $order); } catch (HttpResponseException $exception) { throw $exception; @@ -129,6 +132,32 @@ class Order extends Auth } } + /** + * 模拟计算订单运费 + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function express() + { + $data = $this->_vali([ + 'code.require' => '收货地址不能为空!', + 'order_no.require' => '订单单号不能为空!', + ]); + // 用户收货地址 + $map = ['uid' => $this->uuid, 'code' => $data['code']]; + $addr = $this->app->db->name('DataUserAddress')->where($map)->find(); + if (empty($addr)) $this->error('用户收货地址异常!'); + // 订单状态检查 + $map = ['uid' => $this->uuid, 'order_no' => $data['order_no']]; + $tCount = $this->app->db->name('ShopOrderItem')->where($map)->sum('truck_count'); + // 根据地址计算运费 + $map = ['status' => 1, 'deleted' => 0, 'order_no' => $data['order_no']]; + $tCode = $this->app->db->name('ShopOrderItem')->where($map)->column('truck_tcode'); + [$amount, , , $remark] = TruckService::instance()->amount($tCode, $addr['province'], $addr['city'], $tCount); + $this->success('计算运费成功', ['amount' => $amount, 'remark' => $remark]); + } + /** * 订单信息完成 * @throws \think\db\exception\DataNotFoundException @@ -152,8 +181,8 @@ class Order extends Auth if (empty($order)) $this->error('不能修改收货地址哦!'); // 根据地址计算运费 $map = ['status' => 1, 'deleted' => 0, 'order_no' => $data['order_no']]; - $tCode = $this->app->db->name('ShopOrderItem')->where($map)->column('truck_tcode'); - [$amount, $tCount, $tCode, $remark] = TruckService::instance()->amount($tCode, $addr['province'], $addr['city'], $tCount); + $tCodes = $this->app->db->name('ShopOrderItem')->where($map)->column('truck_tcode'); + [$amount, $tCount, $tCode, $remark] = TruckService::instance()->amount($tCodes, $addr['province'], $addr['city'], $tCount); // 创建订单发货信息 $express = [ 'template_code' => $tCode, 'template_count' => $tCount, 'uid' => $this->uuid, @@ -176,6 +205,9 @@ class Order extends Auth // 支付金额不能为零 if ($update['amount_total'] <= 0) $update['amount_total'] = 0.01; if ($this->app->db->name('ShopOrder')->where($map)->update($update) !== false) { + // 触发订单确认事件 + $this->app->event->trigger('ShopOrderPerfect', $order['order_no']); + // 返回处理成功数据 $this->success('订单确认成功!', ['order_no' => $order['order_no']]); } else { $this->error('订单确认失败,请稍候再试!'); @@ -237,6 +269,9 @@ class Order extends Auth 'cancel_datetime' => date('Y-m-d H:i:s'), ]); if ($result !== false && OrderService::instance()->syncStock($order['order_no'])) { + // 触发订单取消事件 + $this->app->event->trigger('ShopOrderCancel', $order['order_no']); + // 返回处理成功数据 $this->success('订单取消成功!'); } else { $this->error('订单取消失败,请稍候再试!'); @@ -262,7 +297,9 @@ class Order extends Auth if (empty($order)) $this->error('订单查询失败,请稍候再试!'); if (in_array($order['status'], [4])) { if ($this->app->db->name('ShopOrder')->where($map)->update(['status' => 5]) !== false) { - // OrderService::instance()->syncConfrimOrderAmount($order['order_no']); + // 触发订单确认事件 + $this->app->event->trigger('ShopOrderConfirm', $order['order_no']); + // 返回处理成功数据 $this->success('订单确认成功!'); } else { $this->error('订单确认失败,请稍候再试!'); diff --git a/app/data/service/PaymentService.php b/app/data/service/PaymentService.php index c8fa36b88..0b937a13a 100644 --- a/app/data/service/PaymentService.php +++ b/app/data/service/PaymentService.php @@ -219,7 +219,10 @@ abstract class PaymentService if (empty($data['payment_type'])) unset($data['payment_type']); $this->app->db->name('ShopOrder')->where($map)->update($data); // 调用用户升级机制 - return OrderService::instance()->syncAmount($order['order_no']); + OrderService::instance()->syncAmount($order['order_no']); + // 触发订单更新事件 + $this->app->event->trigger('ShopOrderPayment', $orderNo); + return true; } /** diff --git a/app/data/service/UserService.php b/app/data/service/UserService.php index 7d018dd8c..622b01f6c 100644 --- a/app/data/service/UserService.php +++ b/app/data/service/UserService.php @@ -191,7 +191,7 @@ class UserService extends Service if (count($list) < 1) return $list; $uids = array_unique(array_column($list, $keys)); $users = $this->app->db->name('DataUser')->whereIn('id', $uids)->column($column, 'id'); - foreach ($list as &$vo) $vo[$bind] = $users[$keys] ?? []; + foreach ($list as &$vo) $vo[$bind] = $users[$vo['uid']] ?? []; return $list; } diff --git a/app/data/view/store_item/form.html b/app/data/view/store_item/form.html deleted file mode 100644 index e75eac2c2..000000000 --- a/app/data/view/store_item/form.html +++ /dev/null @@ -1,23 +0,0 @@ -
-
- -
- 标签描述 - Mark Remark - -
-
-
- {notempty name='vo.id'}{/notempty} -
- - -
-
\ No newline at end of file diff --git a/app/data/view/store_item/index.html b/app/data/view/store_item/index.html deleted file mode 100644 index c1c53e437..000000000 --- a/app/data/view/store_item/index.html +++ /dev/null @@ -1,68 +0,0 @@ -{extend name="../../admin/view/main"} - -{block name="button"} - - - - - - - -{/block} - -{block name='content'} -
- {include file='store_item/index_search'} - - {notempty name='list'} - - - - - - - - - - - {/notempty} - - {foreach $list as $key=>$vo} - - - - - - - - - {/foreach} - -
- - - - 标签名称标签状态创建时间
- - - - {$vo.name|default=''}{if $vo.status eq 0}已禁用{elseif $vo.status eq 1}已激活{/if}{$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/store_item/index_search.html b/app/data/view/store_item/index_search.html deleted file mode 100644 index a764e0445..000000000 --- a/app/data/view/store_item/index_search.html +++ /dev/null @@ -1,35 +0,0 @@ -
- 条件搜索 - -
- - \ No newline at end of file diff --git a/app/data/view/store_used/form.html b/app/data/view/store_used/form.html deleted file mode 100644 index e75eac2c2..000000000 --- a/app/data/view/store_used/form.html +++ /dev/null @@ -1,23 +0,0 @@ -
-
- -
- 标签描述 - Mark Remark - -
-
-
- {notempty name='vo.id'}{/notempty} -
- - -
-
\ No newline at end of file diff --git a/app/data/view/store_used/index.html b/app/data/view/store_used/index.html deleted file mode 100644 index 822053083..000000000 --- a/app/data/view/store_used/index.html +++ /dev/null @@ -1,68 +0,0 @@ -{extend name="../../admin/view/main"} - -{block name="button"} - - - - - - - -{/block} - -{block name='content'} -
- {include file='store_used/index_search'} - - {notempty name='list'} - - - - - - - - - - - {/notempty} - - {foreach $list as $key=>$vo} - - - - - - - - - {/foreach} - -
- - - - 标签名称标签状态创建时间
- - - - {$vo.name|default=''}{if $vo.status eq 0}已禁用{elseif $vo.status eq 1}已激活{/if}{$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/store_used/index_search.html b/app/data/view/store_used/index_search.html deleted file mode 100644 index a764e0445..000000000 --- a/app/data/view/store_used/index_search.html +++ /dev/null @@ -1,35 +0,0 @@ -
- 条件搜索 - -
- - \ No newline at end of file diff --git a/app/data/view/store_user/form.html b/app/data/view/store_user/form.html deleted file mode 100644 index e75eac2c2..000000000 --- a/app/data/view/store_user/form.html +++ /dev/null @@ -1,23 +0,0 @@ -
-
- -
- 标签描述 - Mark Remark - -
-
-
- {notempty name='vo.id'}{/notempty} -
- - -
-
\ No newline at end of file diff --git a/app/data/view/store_user/index.html b/app/data/view/store_user/index.html deleted file mode 100644 index 40b13b28e..000000000 --- a/app/data/view/store_user/index.html +++ /dev/null @@ -1,68 +0,0 @@ -{extend name="../../admin/view/main"} - -{block name="button"} - - - - - - - -{/block} - -{block name='content'} -
- {include file='store_user/index_search'} - - {notempty name='list'} - - - - - - - - - - - {/notempty} - - {foreach $list as $key=>$vo} - - - - - - - - - {/foreach} - -
- - - - 标签名称标签状态创建时间
- - - - {$vo.name|default=''}{if $vo.status eq 0}已禁用{elseif $vo.status eq 1}已激活{/if}{$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/store_user/index_search.html b/app/data/view/store_user/index_search.html deleted file mode 100644 index a764e0445..000000000 --- a/app/data/view/store_user/index_search.html +++ /dev/null @@ -1,35 +0,0 @@ -
- 条件搜索 - -
- - \ No newline at end of file diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index f876100b3..4ac940254 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -205,9 +205,6 @@ return array( 'app\\data\\controller\\ShopOrderService' => $baseDir . '/app/data/controller/ShopOrderService.php', 'app\\data\\controller\\ShopTruckCompany' => $baseDir . '/app/data/controller/ShopTruckCompany.php', 'app\\data\\controller\\ShopTruckTemplate' => $baseDir . '/app/data/controller/ShopTruckTemplate.php', - 'app\\data\\controller\\StoreItem' => $baseDir . '/app/data/controller/StoreItem.php', - 'app\\data\\controller\\StoreUsed' => $baseDir . '/app/data/controller/StoreUsed.php', - 'app\\data\\controller\\StoreUser' => $baseDir . '/app/data/controller/StoreUser.php', 'app\\data\\controller\\User' => $baseDir . '/app/data/controller/User.php', 'app\\data\\controller\\UserMessage' => $baseDir . '/app/data/controller/UserMessage.php', 'app\\data\\controller\\api\\Auth' => $baseDir . '/app/data/controller/api/Auth.php', diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 4f5aef716..9c0dd5251 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -328,9 +328,6 @@ class ComposerStaticInit4f89fd0e0503ccf740f2fa5757825d7b 'app\\data\\controller\\ShopOrderService' => __DIR__ . '/../..' . '/app/data/controller/ShopOrderService.php', 'app\\data\\controller\\ShopTruckCompany' => __DIR__ . '/../..' . '/app/data/controller/ShopTruckCompany.php', 'app\\data\\controller\\ShopTruckTemplate' => __DIR__ . '/../..' . '/app/data/controller/ShopTruckTemplate.php', - 'app\\data\\controller\\StoreItem' => __DIR__ . '/../..' . '/app/data/controller/StoreItem.php', - 'app\\data\\controller\\StoreUsed' => __DIR__ . '/../..' . '/app/data/controller/StoreUsed.php', - 'app\\data\\controller\\StoreUser' => __DIR__ . '/../..' . '/app/data/controller/StoreUser.php', 'app\\data\\controller\\User' => __DIR__ . '/../..' . '/app/data/controller/User.php', 'app\\data\\controller\\UserMessage' => __DIR__ . '/../..' . '/app/data/controller/UserMessage.php', 'app\\data\\controller\\api\\Auth' => __DIR__ . '/../..' . '/app/data/controller/api/Auth.php', diff --git a/vendor/services.php b/vendor/services.php index dafa83df0..c3a309721 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\admin\\Library',