From 71ebe1576e3cb00a361534fac1dd5cedbe58461e Mon Sep 17 00:00:00 2001 From: Anyon Date: Wed, 30 Dec 2020 13:59:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=94=AF=E4=BB=98=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin_v6.sql | 23 ++++++++--- app/data/controller/api/auth/Order.php | 8 ++-- app/data/service/PaymentService.php | 38 +++++++++---------- .../service/payment/AlipayPaymentService.php | 20 +++++----- .../service/payment/JoinPaymentService.php | 18 ++++----- .../service/payment/WechatPaymentService.php | 16 ++++---- app/data/view/shop_order/index.html | 2 + app/data/view/shop_order/index_search.html | 25 +++++++++--- 8 files changed, 90 insertions(+), 60 deletions(-) diff --git a/admin_v6.sql b/admin_v6.sql index cc1625a30..5218bbb20 100644 --- a/admin_v6.sql +++ b/admin_v6.sql @@ -11,7 +11,7 @@ Target Server Version : 50562 File Encoding : 65001 - Date: 28/12/2020 13:00:05 + Date: 30/12/2020 13:54:24 */ SET NAMES utf8mb4; @@ -473,7 +473,7 @@ CREATE TABLE `shop_order` ( `amount_express` decimal(20, 2) NULL DEFAULT 0.00 COMMENT '快递费用金额', `amount_discount` decimal(20, 2) NULL DEFAULT 0.00 COMMENT '策略优惠金额', `payment_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '实际支付平台', - `payment_code` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '实际支付单号', + `payment_trade` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '实际支付单号', `payment_status` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '实际支付状态', `payment_amount` decimal(20, 2) NULL DEFAULT 0.00 COMMENT '实际支付金额', `payment_remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '支付结果描述', @@ -4494,8 +4494,8 @@ INSERT INTO `system_config` VALUES ('base', 'site_name', 'ThinkAdmin'); INSERT INTO `system_config` VALUES ('base', 'xpath', 'admin'); INSERT INTO `system_config` VALUES ('storage', 'allow_exts', 'doc,gif,icon,jpg,mp3,mp4,p12,pem,png,rar,xls,xlsx'); INSERT INTO `system_config` VALUES ('storage', 'link_type', 'none'); -INSERT INTO `system_config` VALUES ('storage', 'local_http_protocol', 'follow'); INSERT INTO `system_config` VALUES ('storage', 'local_http_domain', ''); +INSERT INTO `system_config` VALUES ('storage', 'local_http_protocol', 'follow'); INSERT INTO `system_config` VALUES ('storage', 'type', 'local'); -- ---------------------------- @@ -4591,12 +4591,24 @@ CREATE TABLE `system_oplog` ( `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '操作人用户名', `create_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统-日志' ROW_FORMAT = COMPACT; +) ENGINE = InnoDB AUTO_INCREMENT = 14 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统-日志' ROW_FORMAT = COMPACT; -- ---------------------------- -- Records of system_oplog -- ---------------------------- INSERT INTO `system_oplog` VALUES (1, 'admin/config/storage', '127.0.0.1', '系统配置管理', '修改系统存储参数', 'admin', '2020-12-28 04:40:54'); +INSERT INTO `system_oplog` VALUES (2, 'admin/config/system', '127.0.0.1', '系统配置管理', '修改系统参数成功', 'admin', '2020-12-28 04:52:25'); +INSERT INTO `system_oplog` VALUES (3, 'admin/api.plugs/optimize', '127.0.0.1', '系统运维管理', '创建数据库优化任务', 'admin', '2020-12-28 05:16:55'); +INSERT INTO `system_oplog` VALUES (4, 'admin/api.queue/start', '127.0.0.1', '系统运维管理', '尝试启动后台服务主进程', 'admin', '2020-12-28 05:17:02'); +INSERT INTO `system_oplog` VALUES (5, 'admin/api.queue/stop', '127.0.0.1', '系统运维管理', '尝试停止后台服务主进程', 'admin', '2020-12-28 05:17:57'); +INSERT INTO `system_oplog` VALUES (6, 'admin/api.plugs/clearconfig', '127.0.0.1', '系统运维管理', '清理系统参数配置成功', 'admin', '2020-12-28 05:39:22'); +INSERT INTO `system_oplog` VALUES (7, 'admin/config/storage', '127.0.0.1', '系统配置管理', '修改系统存储参数', 'admin', '2020-12-28 05:42:30'); +INSERT INTO `system_oplog` VALUES (8, 'admin/api.plugs/debug', '127.0.0.1', '系统运维管理', '由开发模式切换为产品模式', 'admin', '2020-12-28 05:42:33'); +INSERT INTO `system_oplog` VALUES (9, 'admin/api.plugs/debug', '127.0.0.1', '系统运维管理', '由产品模式切换为开发模式', 'admin', '2020-12-28 05:42:34'); +INSERT INTO `system_oplog` VALUES (10, 'admin/api.plugs/clearconfig', '127.0.0.1', '系统运维管理', '清理系统参数配置成功', 'admin', '2020-12-28 05:42:37'); +INSERT INTO `system_oplog` VALUES (11, 'admin/config/system', '127.0.0.1', '系统配置管理', '修改系统参数成功', 'admin', '2020-12-28 05:42:47'); +INSERT INTO `system_oplog` VALUES (12, 'admin/api.plugs/debug', '127.0.0.1', '系统运维管理', '由开发模式切换为产品模式', 'admin', '2020-12-28 05:43:07'); +INSERT INTO `system_oplog` VALUES (13, 'admin/api.plugs/debug', '127.0.0.1', '系统运维管理', '由产品模式切换为开发模式', 'admin', '2020-12-28 05:43:08'); -- ---------------------------- -- Table structure for system_queue @@ -4625,11 +4637,12 @@ CREATE TABLE `system_queue` ( INDEX `idx_system_queue_rscript`(`rscript`) USING BTREE, INDEX `idx_system_queue_create_at`(`create_at`) USING BTREE, INDEX `idx_system_queue_exec_time`(`exec_time`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统-任务' ROW_FORMAT = COMPACT; +) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统-任务' ROW_FORMAT = COMPACT; -- ---------------------------- -- Records of system_queue -- ---------------------------- +INSERT INTO `system_queue` VALUES (1, 'Q202012284835692', '优化数据库所有数据表', 'xadmin:database optimize', 4744, '[]', 1609133735, '已完成对 38 张数据表优化操作', 1609133743.1638, 1609133747.7311, 0, 1, 0, 3, '2020-12-28 05:16:55'); -- ---------------------------- -- Table structure for system_user diff --git a/app/data/controller/api/auth/Order.php b/app/data/controller/api/auth/Order.php index 0675f535d..e52bc99a0 100644 --- a/app/data/controller/api/auth/Order.php +++ b/app/data/controller/api/auth/Order.php @@ -185,9 +185,9 @@ class Order extends Auth public function payment() { $data = $this->_vali([ - 'back.default' => '', #支付回跳地址 - 'paycode.require' => '支付通道不能为空!', - 'order_no.require' => '订单单号不能为空!', + 'back.default' => '', #支付回跳地址 + 'order_no.require' => '订单单号不能为空!', + 'payment_code.require' => '支付通道不能为空!', ]); $map = ['order_no' => $data['order_no']]; $order = $this->app->db->name('ShopOrder')->where($map)->find(); @@ -200,7 +200,7 @@ class Order extends Auth $openid = $this->user[UserService::TYPES[$this->type]['auth']] ?? ''; if (empty($openid)) $this->error("无法创建支付,未获取到OPENID"); } - $params = PaymentService::build($data['paycode'])->create($openid, $order['order_no'], $order['amount_total'], '商城订单支付', '', $data['back']); + $params = PaymentService::build($data['payment_code'])->create($openid, $order['order_no'], $order['amount_total'], '商城订单支付', '', $data['back']); $this->success('获取支付参数成功!', $params); } catch (HttpResponseException $exception) { throw $exception; diff --git a/app/data/service/PaymentService.php b/app/data/service/PaymentService.php index fbbd423e0..95c7d0b16 100644 --- a/app/data/service/PaymentService.php +++ b/app/data/service/PaymentService.php @@ -153,29 +153,29 @@ abstract class PaymentService extends Service /** * 订单更新操作 - * @param string $code 订单单号 - * @param string $payno 交易单号 - * @param string $amount 支付金额 - * @param null|string $paytype 支付类型 + * @param string $orderNo 订单单号 + * @param string $paymentTrade 交易单号 + * @param string $paymentAmount 支付金额 + * @param null|string $paymentType 支付类型 * @return boolean * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public function updateOrder(string $code, string $payno, string $amount, ?string $paytype = null): bool + public function updateOrder(string $orderNo, string $paymentTrade, string $paymentAmount, ?string $paymentType = null): bool { // 检查订单支付状态 - $map = ['order_no' => $code, 'payment_status' => 0, 'status' => 2]; + $map = ['order_no' => $orderNo, 'payment_status' => 0, 'status' => 2]; $order = $this->app->db->name('ShopOrder')->where($map)->find(); if (empty($order)) return false; // 更新订单支付状态 $data = [ 'status' => 3, - 'payment_code' => $payno, - 'payment_type' => $paytype, + 'payment_type' => $paymentType, + 'payment_trade' => $paymentTrade, 'payment_status' => 1, - 'payment_amount' => $amount, - 'payment_remark' => '微信在线支付', + 'payment_amount' => $paymentAmount, + 'payment_remark' => '在线支付', 'payment_datetime' => date('Y-m-d H:i:s'), ]; if (empty($data['payment_type'])) unset($data['payment_type']); @@ -188,10 +188,10 @@ abstract class PaymentService extends Service * 创建支付行为 * @param string $param 通道-编号 * @param string $orderNo 商户订单单号 - * @param string $payTitle 商户订单标题 - * @param string $payAmount + * @param string $paymentTitle 商户订单标题 + * @param string $paymentAmount 需要支付金额 */ - protected function createPaymentAction(string $param, string $orderNo, string $payTitle, string $payAmount) + protected function createPaymentAction(string $param, string $orderNo, string $paymentTitle, string $paymentAmount) { if (is_numeric(stripos($param, '-'))) { [$paymentType, $paymentCode] = explode('-', $param); @@ -201,7 +201,7 @@ abstract class PaymentService extends Service // 创建支付记录 $this->app->db->name('DataPaymentItem')->insert([ 'payment_code' => $paymentCode, 'payment_type' => $paymentType, - 'order_name' => $payTitle, 'order_amount' => $payAmount, 'order_no' => $orderNo, + 'order_name' => $paymentTitle, 'order_amount' => $paymentAmount, 'order_no' => $orderNo, ]); } @@ -258,11 +258,11 @@ abstract class PaymentService extends Service * 创建支付订单 * @param string $openid 会员OPENID * @param string $orderNo 交易订单单号 - * @param string $payAmount 交易订单金额(元) - * @param string $payTitle 交易订单名称 - * @param string $payRemark 交易订单描述 - * @param string $returnUrl 支付回跳地址 + * @param string $paymentAmount 交易订单金额(元) + * @param string $paymentTitle 交易订单名称 + * @param string $paymentRemark 交易订单描述 + * @param string $returnLocation 支付回跳地址 * @return array */ - abstract public function create(string $openid, string $orderNo, string $payAmount, string $payTitle, string $payRemark, string $returnUrl = ''): array; + abstract public function create(string $openid, string $orderNo, string $paymentAmount, string $paymentTitle, string $paymentRemark, string $returnLocation = ''): array; } \ No newline at end of file diff --git a/app/data/service/payment/AlipayPaymentService.php b/app/data/service/payment/AlipayPaymentService.php index 59121fad5..24ea5476d 100644 --- a/app/data/service/payment/AlipayPaymentService.php +++ b/app/data/service/payment/AlipayPaymentService.php @@ -96,14 +96,14 @@ class AlipayPaymentService extends PaymentService * 创建订单支付参数 * @param string $openid 会员OPENID * @param string $orderNo 交易订单单号 - * @param string $payAmount 交易订单金额(元) - * @param string $payTitle 交易订单名称 - * @param string $payRemark 订单订单描述 - * @param string $returnUrl 完成回跳地址 + * @param string $paymentAmount 交易订单金额(元) + * @param string $paymentTitle 交易订单名称 + * @param string $paymentRemark 订单订单描述 + * @param string $returnLocation 完成回跳地址 * @return array * @throws \think\Exception */ - public function create(string $openid, string $orderNo, string $payAmount, string $payTitle, string $payRemark, string $returnUrl = ''): array + public function create(string $openid, string $orderNo, string $paymentAmount, string $paymentTitle, string $paymentRemark, string $returnLocation = ''): array { try { if (isset(static::TYPES[static::$type])) { @@ -114,10 +114,10 @@ class AlipayPaymentService extends PaymentService } $this->params['notify_url'] = sysuri("@data/api.notify/alipay/scene/order/param/{$tradeParam}", [], false, true); if (in_array($tradeType, [static::PAYMENT_ALIPAY_WAP, static::PAYMENT_ALIPAY_WEB])) { - if (empty($returnUrl)) { + if (empty($returnLocation)) { throw new \think\Exception('支付回跳地址不能为空!'); } else { - $this->params['return_url'] = $returnUrl; + $this->params['return_url'] = $returnLocation; } } if ($tradeType === static::PAYMENT_WECHAT_APP) { @@ -129,11 +129,11 @@ class AlipayPaymentService extends PaymentService } else { throw new \think\Exception("支付类型[{$tradeType}]暂时不支持!"); } - $data = ['out_trade_no' => $orderNo, 'total_amount' => $payAmount, 'subject' => $payTitle]; - if (!empty($payRemark)) $data['body'] = $payRemark; + $data = ['out_trade_no' => $orderNo, 'total_amount' => $paymentAmount, 'subject' => $paymentTitle]; + if (!empty($paymentRemark)) $data['body'] = $paymentRemark; $result = $payment->apply($data); // 创建支付记录 - $this->createPaymentAction($tradeParam, $orderNo, $payTitle, $payAmount); + $this->createPaymentAction($tradeParam, $orderNo, $paymentTitle, $paymentAmount); // 返回支付参数 return ['result' => $result]; } catch (\think\Exception $exception) { diff --git a/app/data/service/payment/JoinPaymentService.php b/app/data/service/payment/JoinPaymentService.php index e24348acd..5a7c66bf4 100644 --- a/app/data/service/payment/JoinPaymentService.php +++ b/app/data/service/payment/JoinPaymentService.php @@ -59,14 +59,14 @@ class JoinPaymentService extends PaymentService * 创建订单支付参数 * @param string $openid 会员OPENID * @param string $orderNo 交易订单单号 - * @param string $payAmount 交易订单金额(元) - * @param string $payTitle 交易订单名称 - * @param string $payRemark 订单订单描述 - * @param string $returnUrl 支付回跳地址 + * @param string $paymentAmount 交易订单金额(元) + * @param string $paymentTitle 交易订单名称 + * @param string $paymentRemark 订单订单描述 + * @param string $returnLocation 支付回跳地址 * @return array * @throws \think\Exception */ - public function create(string $openid, string $orderNo, string $payAmount, string $payTitle, string $payRemark, string $returnUrl = ''): array + public function create(string $openid, string $orderNo, string $paymentAmount, string $paymentTitle, string $paymentRemark, string $returnLocation = ''): array { try { if (isset(static::TYPES[static::$type])) { @@ -79,10 +79,10 @@ class JoinPaymentService extends PaymentService 'p0_Version' => '1.0', 'p1_MerchantNo' => $this->mchid, 'p2_OrderNo' => $orderNo, - 'p3_Amount' => $payAmount * 100, + 'p3_Amount' => $paymentAmount * 100, 'p4_Cur' => '1', - 'p5_ProductName' => $payTitle, - 'p6_ProductDesc' => $payRemark, + 'p5_ProductName' => $paymentTitle, + 'p6_ProductDesc' => $paymentRemark, 'p9_NotifyUrl' => sysuri("@data/api.notify/joinpay/scene/order/param/{$tradeParam}", [], false, true), 'q1_FrpCode' => $tradeType ?? '', 'q5_OpenId' => $openid, @@ -94,7 +94,7 @@ class JoinPaymentService extends PaymentService $result = $this->_doReuest($data); if (is_array($result) && isset($result['ra_Code']) && intval($result['ra_Code']) === 100) { // 创建支付记录 - $this->createPaymentAction($tradeParam, $orderNo, $payTitle, $payAmount); + $this->createPaymentAction($tradeParam, $orderNo, $paymentTitle, $paymentAmount); // 返回支付参数 return json_decode($result['rc_Result'], true); } elseif (is_array($result) && isset($result['rb_CodeMsg'])) { diff --git a/app/data/service/payment/WechatPaymentService.php b/app/data/service/payment/WechatPaymentService.php index 8dc89f91a..bb6edaee5 100644 --- a/app/data/service/payment/WechatPaymentService.php +++ b/app/data/service/payment/WechatPaymentService.php @@ -37,14 +37,14 @@ class WechatPaymentService extends PaymentService * 创建微信支付订单 * @param string $openid 会员OPENID * @param string $orderNo 交易订单单号 - * @param string $payAmount 交易订单金额(元) - * @param string $payTitle 交易订单名称 - * @param string $payRemark 订单订单描述 - * @param string $returnUrl 支付回跳地址 + * @param string $paymentAmount 交易订单金额(元) + * @param string $paymentTitle 交易订单名称 + * @param string $paymentRemark 订单订单描述 + * @param string $returnLocation 支付回跳地址 * @return array * @throws \think\Exception */ - public function create(string $openid, string $orderNo, string $payAmount, string $payTitle, string $payRemark, string $returnUrl = ''): array + public function create(string $openid, string $orderNo, string $paymentAmount, string $paymentTitle, string $paymentRemark, string $returnLocation = ''): array { try { if (isset(static::TYPES[static::$type])) { @@ -53,13 +53,13 @@ class WechatPaymentService extends PaymentService } else { throw new \think\Exception('支付类型[' . static::$type . ']未配置定义!'); } - $body = empty($payRemark) ? $payTitle : ($payTitle . '-' . $payRemark); + $body = empty($paymentRemark) ? $paymentTitle : ($paymentTitle . '-' . $paymentRemark); $data = [ 'body' => $body, 'openid' => $openid, 'attach' => $tradeParam, 'out_trade_no' => $orderNo, - 'total_fee' => $payAmount * 100, + 'total_fee' => $paymentAmount * 100, 'trade_type' => $tradeType ?: '', 'notify_url' => sysuri("@data/api.notify/wxpay/scene/order/param/{$tradeParam}", [], false, true), 'spbill_create_ip' => $this->app->request->ip(), @@ -68,7 +68,7 @@ class WechatPaymentService extends PaymentService $info = $this->payment->create($data); if ($info['return_code'] === 'SUCCESS' && $info['result_code'] === 'SUCCESS') { // 创建支付记录 - $this->createPaymentAction($tradeParam, $orderNo, $payTitle, $payAmount); + $this->createPaymentAction($tradeParam, $orderNo, $paymentTitle, $paymentAmount); // 返回支付参数 return $this->payment->jsapiParams($info['prepay_id']); } diff --git a/app/data/view/shop_order/index.html b/app/data/view/shop_order/index.html index 0ba9d89a1..9e6cb27e4 100644 --- a/app/data/view/shop_order/index.html +++ b/app/data/view/shop_order/index.html @@ -68,11 +68,13 @@
发货状态:未发货{$vo.truck.company_name|default='--'} {$vo.truck.send_number|default='--'} + 填写发货 修改发货 + 取消订单 diff --git a/app/data/view/shop_order/index_search.html b/app/data/view/shop_order/index_search.html index 42132e097..2bc46c2b2 100644 --- a/app/data/view/shop_order/index_search.html +++ b/app/data/view/shop_order/index_search.html @@ -1,47 +1,55 @@
条件搜索