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 @@ +
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}