调整支付字段

This commit is contained in:
Anyon 2020-12-30 13:59:23 +08:00
parent ed0d7df3de
commit 71ebe1576e
8 changed files with 90 additions and 60 deletions

View File

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

View File

@ -186,8 +186,8 @@ class Order extends Auth
{
$data = $this->_vali([
'back.default' => '', #支付回跳地址
'paycode.require' => '支付通道不能为空!',
'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;

View File

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

View File

@ -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) {

View File

@ -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'])) {

View File

@ -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']);
}

View File

@ -68,11 +68,13 @@
<div>发货状态:<!--{if empty($vo.truck.send_number)}--><span class="layui-badge layui-bg-black">未发货</span><!--{else}--><span class="layui-badge layui-bg-blue">{$vo.truck.company_name|default='--'}</span>
<a data-title="快递查询" data-modal="{:url('truckQuery')}?code={$vo.truck.company_code|default=''}&number={$vo.truck.send_number|default=''}" class="layui-badge layui-bg-orange">{$vo.truck.send_number|default='--'}</a>
<!--{/if}-->
<!--{if auth('truck') and $vo.status eq 3}-->
<a class="margin-left-5" data-title="填写订单信息" data-modal="{:url('truck')}?order_no={$vo.order_no}">填写发货</a>
<!--{elseif auth('truck') and $vo.status eq 4}-->
<a class="margin-left-5" data-title="修改发货信息" data-modal="{:url('truck')}?order_no={$vo.order_no}">修改发货</a>
<!--{/if}-->
<!--{if auth('cancel') and in_array($vo.status, [1,2])}-->
<a class="margin-left-5" data-confirm="确认要取消订单吗?" data-load="{:url('cancel')}?order_no={$vo.order_no}">取消订单</a>
<!--{/if}-->

View File

@ -1,47 +1,55 @@
<fieldset>
<legend>条件搜索</legend>
<form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
<div class="layui-form-item layui-inline">
<label class="layui-form-label">用户手机</label>
<label class="layui-input-inline">
<input name="member_phone" value="{:input('member_phone')}" placeholder="请输入用户手机" class="layui-input">
</label>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">用户昵称</label>
<label class="layui-input-inline">
<input name="member_nickname" value="{:input('member_nickname')}" placeholder="请输入用户昵称" class="layui-input">
</label>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">推荐手机</label>
<label class="layui-input-inline">
<input name="from_phone" value="{:input('from_phone')}" placeholder="请输入用户手机" class="layui-input">
</label>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">推荐昵称</label>
<label class="layui-input-inline">
<input name="from_nickname" value="{:input('from_nickname')}" placeholder="请输入用户昵称" class="layui-input">
</label>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">订单单号</label>
<label class="layui-input-inline">
<input name="order_no" value="{:input('order_no')}" placeholder="请输入订单单号" class="layui-input">
</label>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">发货单号</label>
<label class="layui-input-inline">
<input name="truck_send_number" value="{:input('truck_send_number')}" placeholder="请输入发货单号" class="layui-input">
</label>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">订单状态</label>
<label class="layui-input-inline">
<select class="layui-select" name="status">
{foreach [''=>'- 全部订单 -','2'=>'待付款','3'=>'待发货','4'=>'已发货','5'=>'已完成'] as $k=>$v}
<option value=''>- 全部订单 -</option>
{foreach ['2'=>'待付款','3'=>'待发货','4'=>'已发货','5'=>'已完成'] as $k=>$v}
{if input('status') eq $k.''}
<option selected value="{$k}">{$v}</option>
{else}
@ -50,50 +58,57 @@
</select>
</label>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">付款状态</label>
<label class="layui-input-inline">
<select class="layui-select" name="payment_status">
{foreach [''=>'- 全部订单 -','0'=>'未支付的订单','1'=>'已支付的订单'] as $k=>$v}
<option value=''>- 全部订单 -</option>
{foreach ['0'=>'未支付的订单','1'=>'已支付的订单'] as $k=>$v}
{if input('payment_status') eq $k.''}
<option selected value="{$k}">{$v}</option>
{else}
<option value="{$k}">{$v}</option>
{/if}
{/foreach}
{/if}{/foreach}
</select>
</label>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">下单时间</label>
<label class="layui-input-inline">
<input data-date-range name="create_at" value="{:input('create_at')}" placeholder="请选择下单时间" class="layui-input">
</label>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">支付时间</label>
<label class="layui-input-inline">
<input data-date-range name="payment_datetime" value="{:input('payment_datetime')}" placeholder="请选择支付时间" class="layui-input">
</label>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">收货姓名</label>
<label class="layui-input-inline">
<input name="truck_address_name" value="{:input('truck_address_name')}" placeholder="请输入收货姓名" class="layui-input">
</label>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">收货手机</label>
<label class="layui-input-inline">
<input name="truck_address_phone" value="{:input('truck_address_phone')}" placeholder="请输入收货手机" class="layui-input">
</label>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">收货地址</label>
<label class="layui-input-inline">
<input name="truck_address_content" value="{:input('truck_address_content')}" placeholder="请输入收货省份" class="layui-input">
</label>
</div>
<div class="layui-form-item layui-inline">
<button type="submit" class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
<button type="button" data-form-export="{:url('index')}?type={$type|default=''}" class="layui-btn layui-btn-primary">
@ -112,7 +127,7 @@
item.order_no,
item.member.phone,
item.member.username || item.member.nickname || '',
item.payment_code || '',
item.payment_trade || '',
item.payment_status ? '已支付' : '未支付',
item.payment_amount || '0.00',
item.payment_datetime || '',