From f432ce693d6e4557c9ee21d87265216957a25d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Wed, 17 Mar 2021 17:52:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=91=E8=B4=A7=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/data/controller/ShopOrder.php | 52 +++++++++++++++++++ .../service/payment/VoucherPaymentService.php | 2 +- app/data/view/shop_order/audit.html | 47 +++++++++++++++++ app/data/view/shop_order/index.html | 30 +++++++++-- config/view.php | 2 +- 5 files changed, 127 insertions(+), 6 deletions(-) create mode 100644 app/data/view/shop_order/audit.html diff --git a/app/data/controller/ShopOrder.php b/app/data/controller/ShopOrder.php index f22ab980a..b11f634b2 100644 --- a/app/data/controller/ShopOrder.php +++ b/app/data/controller/ShopOrder.php @@ -7,6 +7,7 @@ use app\data\service\PaymentService; use app\data\service\ExpressService; use app\data\service\UserAdminService; use think\admin\Controller; +use think\admin\extend\CodeExtend; use think\exception\HttpResponseException; /** @@ -156,6 +157,57 @@ class ShopOrder extends Controller } } + /** + * 单据凭证支付审核 + * @auth true + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function audit() + { + if ($this->request->isGet()) { + $this->_form($this->table, '', 'order_no'); + } else { + $data = $this->_vali([ + 'order_no.require' => '订单单号不能为空!', + 'status.in:0,1' => '审核状态数值异常!', + 'status.require' => '审核状态不能为空!', + 'remark.default' => '', + ]); + if (empty($data['status'])) { + $data['status'] = 0; + $data['cancel_status'] = 1; + $data['cancel_remark'] = $data['remark'] ?: '后台审核驳回并取消订单'; + $data['cancel_datetime'] = date('Y-m-d H:i:s'); + } else { + $data['status'] = 4; + $data['payment_code'] = CodeExtend::uniqidDate(20, 'T'); + $data['payment_status'] = 1; + $data['payment_remark'] = $data['remark'] ?: '后台审核支付凭证通过'; + $data['payment_datetime'] = date('Y-m-d H:i:s'); + } + $order = $this->app->db->name($this->table)->where(['order_no' => $data['order_no']])->find(); + if (empty($order) || $order['status'] !== 3) $this->error('不允许操作审核!'); + // 无需发货时的处理 + if ($data['status'] === 4 && empty($order['truck_type'])) $data['status'] = 5; + // 更新订单支付状态 + $map = ['status' => 3, 'order_no' => $data['order_no']]; + if ($this->app->db->name($this->table)->strict(false)->where($map)->update($data) !== false) { + if (in_array($data['status'], [4, 5])) { + $this->app->event->trigger('ShopOrderPayment', $data['order_no']); + $this->success('订单审核通过成功!'); + } else { + $this->app->event->trigger('ShopOrderCancel'); + OrderService::instance()->stock($data['order_no']); + $this->success('审核驳回并取消成功!'); + } + } else { + $this->error('订单审核失败!'); + } + } + } + /** * 清理订单数据 * @auth true diff --git a/app/data/service/payment/VoucherPaymentService.php b/app/data/service/payment/VoucherPaymentService.php index 4c44f8d4d..85fa3b67a 100644 --- a/app/data/service/payment/VoucherPaymentService.php +++ b/app/data/service/payment/VoucherPaymentService.php @@ -53,7 +53,7 @@ class VoucherPaymentService extends PaymentService if (empty($order)) throw new Exception("订单不存在"); if ($order['status'] !== 2) throw new Exception("不可发起支付"); if (empty($paymentImage)) throw new Exception('支付凭证不能为空'); - $this->updateOrder($orderNo, CodeExtend::uniqidDate(20), $paymentAmount, '支付凭证', $paymentImage); + $this->updateOrder($orderNo, CodeExtend::uniqidDate(20), $paymentAmount, '单据凭证支付', $paymentImage); return ['info' => '支付凭证上传成功!', 'status' => 1]; } } \ No newline at end of file diff --git a/app/data/view/shop_order/audit.html b/app/data/view/shop_order/audit.html new file mode 100644 index 000000000..e7ff33f72 --- /dev/null +++ b/app/data/view/shop_order/audit.html @@ -0,0 +1,47 @@ +
+ +
+ +
+ + 支付单证凭证 + {$vo.order_no} + 订单需要支付 {$vo.amount_real+0} 元 + +
+ img +
+
+ +
+ 审核操作类型 + Audit type +
+ {php} $status = 0; {/php} + {foreach [1 => '审核通过并完成订单支付', 0 => '驳回审核并取消订单'] as $k => $v} + {if $k eq $status} + + {else} + + {/if}{/foreach} +
+
+ + + + +
+ {notempty name='vo.id'}{/notempty} + {notempty name='vo.order_no'}{/notempty} + +
+ + +
+
+ +
diff --git a/app/data/view/shop_order/index.html b/app/data/view/shop_order/index.html index 1f1996ec0..219b24072 100644 --- a/app/data/view/shop_order/index.html +++ b/app/data/view/shop_order/index.html @@ -63,17 +63,38 @@ {eq name='vo.status' value='5'}已发货{/eq} {eq name='vo.status' value='6'}已完成{/eq}
- 订单单号:{$vo.order_no|default=''}
- 订单总计:{$vo.amount_total+0}{if $vo.amount_express>0}(含邮费{$vo.amount_express+0}元){else}(包邮){/if}已支付 {$vo.payment_amount+0}
- 下单时间:{$vo.create_at|format_datetime}
+
+ 订单单号:{$vo.order_no|default=''} + + 凭证审核 + +
+
+ 订单总计:{$vo.amount_total+0} 元 + {if $vo.amount_express>0}(含邮费{$vo.amount_express+0}元){else}(包邮){/if} + 已支付 {$vo.payment_amount+0} 元 +
+
下单时间:{$vo.create_at|format_datetime}
- 支付时间:{$vo.payment_datetime|format_datetime} {notempty name='vo.payment_name'} ({$vo.payment_name|default='-'}){/notempty}
+
+ 支付时间:{$vo.payment_datetime|format_datetime} + {notempty name='vo.payment_name'} + + ({$vo.payment_name|default='-'}) + + ({$vo.payment_name|default='-'}) + + {/notempty} +
支付状态:还未支付
+ {empty name='vo.truck_type'} + 无需发货 + {else}
收货信息:{$vo.truck.address_name|default='--'}{$vo.truck.address_phone|default=''}
收货地址:{$vo.truck.address_province|default='--'}{$vo.truck.address_city|default=''}{$vo.truck.address_area|default=''}{$vo.truck.address_content|default=''}
发货状态:未发货{$vo.truck.company_name|default='--'} @@ -91,6 +112,7 @@
发货时间:{$vo.truck.send_datetime|default='--'}
+ {/empty} {foreach $vo.items as $item} diff --git a/config/view.php b/config/view.php index a24ab1c70..93621cb6f 100644 --- a/config/view.php +++ b/config/view.php @@ -25,7 +25,7 @@ return [ // 模板文件名分隔符 'view_depr' => DIRECTORY_SEPARATOR, // 去除HTML空格换行 - 'strip_space' => false, + 'strip_space' => true, // 模板缓存配置 'tpl_cache' => !app()->isDebug(), // 模板引擎普通标签开始标记