小程序支付

This commit is contained in:
cun-nan 2023-12-20 16:04:56 +08:00
parent b5696f8dec
commit 8a3ee12f1d
11 changed files with 175 additions and 84 deletions

View File

@ -1,4 +1,4 @@
# 数据库配置
# \u6570\u636E\u5E93\u914D\u7F6E
spring.datasource.url=jdbc:mysql://192.168.1.3:3306/fuint-db?useUnicode=true&characterEncoding=UTF8&useSSL=false&allowMultiQueries=true
@ -10,102 +10,110 @@ spring.datasource.password=qqzcy@1014
#spring.datasource.password=root
# Redis配置
# Redis\u914D\u7F6E
spring.session.store-type=redis
spring.session.redis.namespace=fuint
# Redis数据库索引默认为0
# Redis\u6570\u636E\u5E93\u7D22\u5F15\uFF08\u9ED8\u8BA4\u4E3A0\uFF09
spring.redis.database=0
# Redis服务器地址(生产)
# Redis\u670D\u52A1\u5668\u5730\u5740(\u751F\u4EA7)
spring.redis.host=localhost
# Redis服务器连接端口
# Redis\u670D\u52A1\u5668\u8FDE\u63A5\u7AEF\u53E3
spring.redis.port=6379
# Redis服务器连接密码(默认为空)
# Redis\u670D\u52A1\u5668\u8FDE\u63A5\u5BC6\u7801\uFF08\u9ED8\u8BA4\u4E3A\u7A7A\uFF09
spring.redis.password=
# 连接池最大连接数(使用负值表示没有限制)
# \u8FDE\u63A5\u6C60\u6700\u5927\u8FDE\u63A5\u6570\uFF08\u4F7F\u7528\u8D1F\u503C\u8868\u793A\u6CA1\u6709\u9650\u5236\uFF09
spring.redis.pool.max-active=-1
# 连接池最大阻塞等待时间(使用负值表示没有限制)
# \u8FDE\u63A5\u6C60\u6700\u5927\u963B\u585E\u7B49\u5F85\u65F6\u95F4\uFF08\u4F7F\u7528\u8D1F\u503C\u8868\u793A\u6CA1\u6709\u9650\u5236\uFF09
spring.redis.pool.max-wait=-1
# 连接池中的最大空闲连接
# \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5927\u7A7A\u95F2\u8FDE\u63A5
spring.redis.pool.max-idle=8
# 连接池中的最小空闲连接
# \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5C0F\u7A7A\u95F2\u8FDE\u63A5
spring.redis.pool.min-idle=0
# 连接超时时间(毫秒)
# \u8FDE\u63A5\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09
spring.redis.timeout=5000
# 系统名称
system.name = 蓝鲸智慧油站系统
# \u7CFB\u7EDF\u540D\u79F0
system.name = \u84DD\u9CB8\u667A\u6167\u6CB9\u7AD9\u7CFB\u7EDF
# 前端h5地址
# \u524D\u7AEFh5\u5730\u5740
website.url=https://www.fuint.cn/h5/
# 上传图片本地地址
# \u4E0A\u4F20\u56FE\u7247\u672C\u5730\u5730\u5740
images.root=C:/fuintV3.0.1/fuintBackend/fuint-application/target/classes
images.path=/static/uploadImages/
# 上传图片服务器域名
images.upload.url=http://192.168.1.6:8008
# \u4E0A\u4F20\u56FE\u7247\u670D\u52A1\u5668\u57DF\u540D
images.upload.url=http://localhost:8080
# 上传图片允许的大小单位MB
# \u4E0A\u4F20\u56FE\u7247\u5141\u8BB8\u7684\u5927\u5C0F\uFF08\u5355\u4F4D\uFF1AMB\uFF09
images.upload.maxSize=5
################## 定时脚本配置 #########################
# 定时发送消息
################## \u5B9A\u65F6\u811A\u672C\u914D\u7F6E #########################
# \u5B9A\u65F6\u53D1\u9001\u6D88\u606F
message.job.switch = 1
message.job.time = 0 0/1 * * * ?
# 卡券到期处理
# \u5361\u5238\u5230\u671F\u5904\u7406
couponExpire.job.switch = 1
couponExpire.job.time = 0 0/1 * * * ?
# 订单超时取消
# \u8BA2\u5355\u8D85\u65F6\u53D6\u6D88
orderCancel.job.switch = 1
orderCancel.job.time = 0 0/1 * * * ?
################## 阿里云短信配置 #######################
# 短信接口模式[0-关闭 1-打开]
################## \u963F\u91CC\u4E91\u77ED\u4FE1\u914D\u7F6E #######################
# \u77ED\u4FE1\u63A5\u53E3\u6A21\u5F0F[0-\u5173\u95ED 1-\u6253\u5F00]
aliyun.sms.mode = 0
aliyun.sms.accessKeyId=LTAI4GJMjV123oXsrQJLnPZt
aliyun.sms.accessKeySecret=eGVBL30u5Ypj234d7XODlwYKWTaGT
# 阿里云短信签名
aliyun.sms.signName=延禾技术
# \u963F\u91CC\u4E91\u77ED\u4FE1\u7B7E\u540D
aliyun.sms.signName=\u5EF6\u79BE\u6280\u672F
################## 阿里云OSS存储配置######################
# 模式[0-关闭 1-打开]
################## \u963F\u91CC\u4E91OSS\u5B58\u50A8\u914D\u7F6E######################
# \u6A21\u5F0F[0-\u5173\u95ED 1-\u6253\u5F00]
aliyun.oss.mode = 0
aliyun.oss.accessKeyId = LTAI4GJMjVhBa212rQJLnPZtt
aliyun.oss.accessKeySecret = eGVBL30u53456gXd7XODlwYKWTaGT
aliyun.oss.endpoint = https://oss-cn-shenzhen.aliyuncs.com
aliyun.oss.bucketName = fuint-application
# 上传文件夹
# \u4E0A\u4F20\u6587\u4EF6\u5939
aliyun.oss.folder = uploads
# 访问域名
# \u8BBF\u95EE\u57DF\u540D
aliyun.oss.domain = https://fuint-application.oss-cn-shenzhen.aliyuncs.com
################## 微信相关配置 ##########################
# 公众号配置
################## \u5FAE\u4FE1\u76F8\u5173\u914D\u7F6E ##########################
# \u516C\u4F17\u53F7\u914D\u7F6E
weixin.official.appId=wxf4327ef05c27a0
weixin.official.appSecret=1f55e8749332234d9a074873d8e6a3
# 小程序配置
wxpay.appId = wxba517a9bac38fe92
wxpay.appSecret = 8bfcce86abc4e2a461ecc781a09249a5
# \u5C0F\u7A0B\u5E8F\u914D\u7F6E
#wxpay.appId = wxba517a9bac38fe92
wxpay.appId = wx033c30e366eff6ac
#wxpay.appSecret = 8bfcce86abc4e2a461ecc781a09249a5
wxpay.appSecret = e46a9a5947380fb70a1aa33a5b427ba4
wxpay.mchId=1636980812
wxpay.apiV2=34354320201030y323e432342343
wxpay.certPath=/usr/local/fuint/cert/apiclient_cert.p12
wxpay.domain=https://www.fuint.cn/fuint-application
################## 支付宝支付相关配置 ######################
alipay.appId = 应用编号
alipay.privateKey = 应用私钥
alipay.publicKey = 支付宝公钥(通过应用公钥上传到支付宝开放平台换取支付宝公钥)
################## \u652F\u4ED8\u5B9D\u652F\u4ED8\u76F8\u5173\u914D\u7F6E ######################
alipay.appId = \u5E94\u7528\u7F16\u53F7
alipay.privateKey = \u5E94\u7528\u79C1\u94A5
alipay.publicKey = \u652F\u4ED8\u5B9D\u516C\u94A5\uFF08\u901A\u8FC7\u5E94\u7528\u516C\u94A5\u4E0A\u4F20\u5230\u652F\u4ED8\u5B9D\u5F00\u653E\u5E73\u53F0\u6362\u53D6\u652F\u4ED8\u5B9D\u516C\u94A5\uFF09
alipay.serverUrl=https://openapi.alipay.com/gateway.do
alipay.domain=https://www.fuint.cn/fuint-application/clientApi/pay/aliPayCallback
################ 微信订阅模板消息配置 ######################
weixin.subMessage.orderCreated=[{'key':'time', 'name':'订单时间'},{'key':'orderSn', 'name':'订单号'},{'key':'remark', 'name':'备注信息'}]
weixin.subMessage.deliverGoods=[{'key':'receiver', 'name':'收货人'}, {'key':'orderSn', 'name':'订单号'}, {'key':'expressCompany', 'name':'快递公司'}, {'key':'expressNo', 'name':'快递单号'}]
weixin.subMessage.couponExpire=[{'key':'name', 'name':'卡券名称'}, {'key':'expireTime', 'name':'到期时间'},{'key':'tips', 'name':'温馨提示'}]
weixin.subMessage.couponArrival=[{'key':'name', 'name':'卡券名称'},{'key':'amount', 'name':'金额'},{'key':'tips', 'name':'温馨提示'}]
weixin.subMessage.balanceChange=[{'key':'amount', 'name':'变动金额'},{'key':'time', 'name':'变动时间'},{'key':'tips', 'name':'温馨提示'}]
weixin.subMessage.couponConfirm=[{'key':'name', 'name':'卡券名称'},{'key':'time', 'name':'核销时间'}]
weixin.subMessage.pointChange=[{'key':'amount', 'name':'变动数量'},{'key':'time', 'name':'变动时间'},{'key':'remark', 'name':'备注信息'}]
################ \u5FAE\u4FE1\u8BA2\u9605\u6A21\u677F\u6D88\u606F\u914D\u7F6E ######################
weixin.subMessage.orderCreated=[{'key':'time', 'name':'\u8BA2\u5355\u65F6\u95F4'},{'key':'orderSn', 'name':'\u8BA2\u5355\u53F7'},{'key':'remark', 'name':'\u5907\u6CE8\u4FE1\u606F'}]
weixin.subMessage.deliverGoods=[{'key':'receiver', 'name':'\u6536\u8D27\u4EBA'}, {'key':'orderSn', 'name':'\u8BA2\u5355\u53F7'}, {'key':'expressCompany', 'name':'\u5FEB\u9012\u516C\u53F8'}, {'key':'expressNo', 'name':'\u5FEB\u9012\u5355\u53F7'}]
weixin.subMessage.couponExpire=[{'key':'name', 'name':'\u5361\u5238\u540D\u79F0'}, {'key':'expireTime', 'name':'\u5230\u671F\u65F6\u95F4'},{'key':'tips', 'name':'\u6E29\u99A8\u63D0\u793A'}]
weixin.subMessage.couponArrival=[{'key':'name', 'name':'\u5361\u5238\u540D\u79F0'},{'key':'amount', 'name':'\u91D1\u989D'},{'key':'tips', 'name':'\u6E29\u99A8\u63D0\u793A'}]
weixin.subMessage.balanceChange=[{'key':'amount', 'name':'\u53D8\u52A8\u91D1\u989D'},{'key':'time', 'name':'\u53D8\u52A8\u65F6\u95F4'},{'key':'tips', 'name':'\u6E29\u99A8\u63D0\u793A'}]
weixin.subMessage.couponConfirm=[{'key':'name', 'name':'\u5361\u5238\u540D\u79F0'},{'key':'time', 'name':'\u6838\u9500\u65F6\u95F4'}]
weixin.subMessage.pointChange=[{'key':'amount', 'name':'\u53D8\u52A8\u6570\u91CF'},{'key':'time', 'name':'\u53D8\u52A8\u65F6\u95F4'},{'key':'remark', 'name':'\u5907\u6CE8\u4FE1\u606F'}]
# rocketmq\u914D\u7F6E
//1
rocketmq.name-server=127.0.0.1:9876
//2
rocketmq.producer.group=provider

View File

@ -1,38 +1,39 @@
package com.fuint.api.fuyou.controller;
import com.fuint.api.fuyou.entity.Const;
import com.fuint.api.fuyou.service.FyPayService;
import com.fuint.api.fuyou.util.Utils;
import com.fuint.business.order.service.OilOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Enumeration;
import java.util.HashMap;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Map;
@RestController
@RequestMapping("/api/fyPay")
public class FyPayController {
@Autowired
private FyPayService payService;
@Lazy
private OilOrderService orderService;
// 接收支付平台异步通知的接口
@PostMapping("/notify")
public String notifyUrl(HttpServletRequest request,HttpServletResponse response) {
System.out.println("111+"+request);
System.out.println("222+"+response);
// Map paramMap = new HashMap<>();
// Enumeration parameterNames = request.getParameterNames();
// while(parameterNames.hasMoreElements()) {
// String parameterName = (String) parameterNames.nextElement();
// paramMap.put(parameterName, request.getParameter(parameterName));
// }
// boolean isSuccess = processNotify(paramMap); // 处理支付结果并返回成功或失败状态
// if(isSuccess) {
// return "success"; // 返回成功状态通知支付平台异步通知已成功接收
// } else {
// return "fail"; // 返回失败状态通知支付平台异步通知已失败
// }
return "11111111";
public String notifyUrl(HttpServletRequest request,HttpServletResponse response) throws UnsupportedEncodingException {
System.out.println("----------------收到支付回调--------"+request.getParameter("req"));
String notifyData = request.getParameter("req");
String decode = URLDecoder.decode(notifyData, Const.charset);
Map<String, String> reqMap = Utils.xmlStr2Map(decode);
if (reqMap.get("result_msg").equals("SUCCESS")){
String orderNo = reqMap.get("mchnt_order_no");
orderService.updateOrderStatus(orderNo,"paid");
return "1";
}else {
return "0";
}
}
}

View File

@ -160,6 +160,18 @@ public class OilOrderController extends BaseController {
return getSuccessResult(orderService.addOilOrder(oilOrder));
}
/**
* 根据订单号修改订单支付状态
* @param map
* @return
*/
@PostMapping("/orderStatus")
public ResponseObject editStatus(@RequestBody Map<String,String> map){
String orderNo = map.get("orderNo");
String status = map.get("status");
return getSuccessResult(orderService.updateOrderStatus(orderNo,status));
}
/**
* 信息统计

View File

@ -84,7 +84,15 @@ public interface OilOrderService extends IService<OilOrder> {
* 小程序订单支付
* @param map
*/
public boolean appletPay(Map<String,String> map);
public Map<String, String> appletPay(Map<String,String> map);
/**
* 根据订单号修改订单支付状态
* @param orderNo
* @param status
* @return
*/
public int updateOrderStatus(String orderNo,String status);
/**
* 添加油品跟踪信息

View File

@ -435,7 +435,7 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
private OilNumberService oilNumberService;
@Override
public boolean appletPay(Map<String, String> map) {
public Map<String, String> appletPay(Map<String, String> map) {
String orderNo = map.get("orderNo");
// 支付金额
Integer payAmount = (int) (Double.valueOf(map.get("payAmount"))*100);
@ -482,10 +482,13 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
}
if (result){
return false;
return null;
}
oilOrder.setTankId(tankId);
Map<String, String> applet = null;
if (!map.get("payAmount").equals("0")) {
// 调用支付接口
// 判断是否开启支付规则
@ -522,7 +525,8 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
// 调用支付接口
try {
fyPayService.applet(map1);
applet = fyPayService.applet(map1);
applet.put("orderNo",orderNo);
} catch (Exception e) {
e.printStackTrace();
}
@ -536,7 +540,21 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
oilOrder.setOrderStatus("paid");
baseMapper.updateById(oilOrder);
}
return true;
return applet;
}
@Override
public int updateOrderStatus(String orderNo, String status) {
int row = 0;
OilOrder oilOrder = this.selectOilOrderByOrderNo(orderNo);
if (ObjectUtil.isNotEmpty(oilOrder)){
oilOrder.setOrderStatus(status);
if (status.equals("paid")){
oilOrder.setPayTime(new Date());
}
row = baseMapper.updateById(oilOrder);
}
return 0;
}
@Autowired
@ -625,7 +643,7 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
Integer dieselGrowthValue = null;
Integer naturalGrowthValue = null;
LJStore store = storeService.selectStoreByStoreId(storeId);
UserBalance balance = userBalanceService.selectUserBalance(userid,store.getChainStoreId());
UserBalance balance = userBalanceService.selectUserBalance(userid);
int growth = balance.getGrowthValue();
balance.setRefuelMoney(refuelMoney);
// 查询会员等级列表信息
@ -685,7 +703,7 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
// 根据用户id查询用户余额信息
LJStore store = storeService.selectStoreByStoreId(storeId);
UserBalance balance = userBalanceService.selectUserBalance(userId,store.getChainStoreId());
UserBalance balance = userBalanceService.selectUserBalance(userId);
// 修改余额信息
Double beforeBalance = balance.getCardBalance();
Double afterBalance = beforeBalance - amount;

View File

@ -1,7 +1,8 @@
# \u57FA\u672C\u914D\u7F6E
server.port=8008
server.port=8080
env.profile=dev
env.properties.path=D:/code/oilSystem/fuintBackend/configure/
env.properties.path=D:/workspaces/oilSystem/fuintBackend/configure/
# \u6570\u636E\u5E93\u914D\u7F6E
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
@ -20,7 +21,7 @@ spring.servlet.multipart.max-request-size=10MB
# mybatis\u914D\u7F6E
mybatis-plus.mapper-locations = classpath*:/mapper/*Mapper.xml,classpath*:com/fuint/**/xml/*Mapper.xml
# <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
# \uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u0536\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD
mybatis-plus.configuration.intercepts=com.example.MyInterceptor
# \u9ED8\u8BA4\u65F6\u95F4\u683C\u5F0F
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss

View File

@ -50,7 +50,7 @@
/* */
"mp-weixin" : {
"output-path" : "dist/myapp",
"appid" : "wxba517a9bac38fe92",
"appid" : "wx033c30e366eff6ac",
"setting" : {
"urlCheck" : false,
"es6" : true,

View File

@ -151,6 +151,13 @@
"navigationBarTitleText": "支付订单",
"navigationStyle": "custom"
}
},
{
"path": "orderSuccess/index",
"style": {
"navigationBarTitleText": "支付完成页",
"navigationStyle": "custom"
}
}
]
},

View File

@ -264,12 +264,12 @@
method: 'get',
}).then(res => {
// console.log(res,111222)
if (res.code == 200) {
this.cardBalance = res.data.cardBalance,
if (res.data.refuelMoney!=null && res.data.refuelMoney!=""){
this.refuelMoney = JSON.parse(res.data.refuelMoney);
}
}
// if (res.code == 200) {
// this.cardBalance = res.data.cardBalance,
// if (res.data.refuelMoney!=null && res.data.refuelMoney!=""){
// this.refuelMoney = JSON.parse(res.data.refuelMoney);
// }
// }
})
},
getGiftRecords() {

View File

@ -73,7 +73,7 @@
userInfo: {
storeId: 0,
staffId: "",
phone: '17753808121'
phone: '18475962147'
},
type: 'phone',

View File

@ -282,6 +282,7 @@
isOilStorageCard:false,
// 使
isUseGrade:false,
orderInfo:{},
}
},
onLoad(e) {
@ -393,6 +394,41 @@
data: map,
}).then(res => {
console.log(res)
let payProvider = "wxpay"
// if (_this.appltType== "WECHAT"){
// payProvider = "wxpay"
// }else{
// payProvider = "alipay"
// }
_this.orderInfo = JSON.parse(res.data.reserved_pay_info);
uni.requestPayment({
// provider: 'wxpay' 'alipay'
provider: payProvider,
timeStamp: _this.orderInfo.timeStamp,
nonceStr: _this.orderInfo.nonceStr,
package: _this.orderInfo.package,
signType: 'MD5',
paySign: _this.orderInfo.paySign,
success: function (res) {
console.log('success:',res);
uni.reLaunch({
url: '/pagesRefuel/orderSuccess/index'
})
},
fail: function (err) {
request({
url: "business/oilOrder/orderStatus",
method: 'post',
data: {"orderNo":res.data.orderNo,"status":"payFail"},
}).then((res)=>{
uni.showToast({
title:"支付失败!",
icon:"error"
})
})
console.log('fail:',err);
}
});
})
},
//