From 50050ada04e8ae7bbbeb6342b4e3e35fba3890ec Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期三, 22 一月 2025 17:36:47 +0800
Subject: [PATCH] 合并代码
---
cloud-server-other/src/main/java/com/dsh/other/controller/GameController.java | 71 ++++++++++++++++++++++++++++++++++-
1 files changed, 68 insertions(+), 3 deletions(-)
diff --git a/cloud-server-other/src/main/java/com/dsh/other/controller/GameController.java b/cloud-server-other/src/main/java/com/dsh/other/controller/GameController.java
index bda7919..b5c911a 100644
--- a/cloud-server-other/src/main/java/com/dsh/other/controller/GameController.java
+++ b/cloud-server-other/src/main/java/com/dsh/other/controller/GameController.java
@@ -177,7 +177,8 @@
-
+ @Autowired
+ private IOperatorUserService operatorUserService;
@ResponseBody
@PostMapping("/api/game/payGame")
@ApiOperation(value = "支付游戏", tags = {"用户—游戏"})
@@ -196,6 +197,16 @@
if (null == uid) {
return ResultUtil.tokenErr();
}
+ Site byId = siteService.getById(spaceId);
+ Store byId1 = storeService.getById(byId.getStoreId());
+
+ // 是否分账 0否1是
+ int isFenZhang= 1;
+ String merchantNumber = "";
+ if (byId1.getOperatorId()==null || byId1.getOperatorId()==0){
+ // 平台
+ isFenZhang = 0;
+ }
//判断当前用户是否是员工
AppUser appUser1 = appUserClient.queryAppUser(uid);
User one = userService.getOne(new QueryWrapper<User>().eq("phone", appUser1.getPhone()).eq("status", 1));
@@ -212,14 +223,17 @@
tGameRecord.setUserId(uid);
tGameRecord.setNumber(code);
tGameRecord.setTime(new Date());
+ tGameRecord.setSiteId(spaceId);
gameRecordService.save(tGameRecord);
+ System.err.println("启动游戏支付");
if (type == 1) {
tGameRecord.setMoney(config.getCash());
gameRecordService.updateById(tGameRecord);
String params = uid + "_" + gameId + "_" + spaceId + "_" + sutuId+"_"+code+"_"+configId + "_" + gameType;
- ResultUtil weixinpay = payMoneyUtil.weixinpay("游戏支付", params, code, config.getCash().toString(),
+ ResultUtil weixinpay = payMoneyUtil.weixinpay("游戏支付-"+isFenZhang, params, code, config.getCash().toString(),
"/base/game/wechatPaymentGameCallback", "APP", "");
+ System.err.println("启动游戏支付");
if (weixinpay.getCode() == 200) {
new Thread(new Runnable() {
@Override
@@ -262,7 +276,9 @@
}
gameRecordService.updateBatchById(list);
Integer integer = startGame(uid, gameType, gameId, spaceId, sutuId);
+
break;
+
}
if ("USERPAYING".equals(s) || "NOTPAY".equals(s)) {
num++;
@@ -462,11 +478,15 @@
}
+ @Resource
+ private StoreService storeService;
@ResponseBody
@PostMapping("/base/game/wechatPaymentGameCallback")
- public void wechatPaymentGameCallback(HttpServletRequest request, HttpServletResponse response){
+ public void wechatPaymentGameCallback(HttpServletRequest request, HttpServletResponse response) throws Exception {
+ System.err.println("进入游戏回调");
Map<String, String> map = payMoneyUtil.weixinpayCallback(request);
+ System.err.println("回调参数"+map);
if(null != map){
String out_trade_no = map.get("out_trade_no");
String transaction_id = map.get("transaction_id");
@@ -492,6 +512,51 @@
gameRecordService.updateBatchById(list);
String[] s = attach.split("_");
Integer integer = startGame(Integer.valueOf(s[0]), Integer.valueOf(s[6]), Integer.valueOf(s[1]), Integer.valueOf(s[2]), Integer.valueOf(s[3]));
+ TGameRecord one = gameRecordService.getOne(new QueryWrapper<TGameRecord>().eq("number", out_trade_no).eq("payType", 1));
+ System.err.println("游戏支付记录"+one);
+ if (one!=null){
+ Integer gameId = one.getGameId();
+ Site byId1 = siteService.getById(one.getSiteId());
+ Store byId = storeService.getById(byId1.getStoreId());
+ if (byId!=null){
+ if (byId.getOperatorId()!=null && byId.getOperatorId()!=0){
+ // 休眠两分钟后再调用分账接口 避免提示订单正在处理中
+ Thread.sleep(120000);
+ // 根据运营商id获取对应运营商分账比例 返回格式: 微信分账比例,支付宝分账比例
+ OperatorUser operatorId = operatorUserService.getOne(
+ new QueryWrapper<OperatorUser>().eq("operatorId",byId.getOperatorId())
+ );
+ if (operatorId.getWechatProportion() == null){
+ operatorId.setWechatProportion("0");
+ }
+ if (operatorId.getAlipayProportion() == null){
+ operatorId.setAlipayProportion("0");
+ }
+ String proportion= operatorId.getWechatProportion()+","+operatorId.getAlipayProportion();
+ String[] split = proportion.split(",");
+ String s1 = split[0];
+ if (!s1.equals("未设置")){
+ BigDecimal bigDecimal = new BigDecimal(s1);
+ // 分账比例
+ BigDecimal bigDecimal1 = bigDecimal.divide(new BigDecimal(100)).setScale(2);
+ // 微信商户号
+ String s2 =siteService.getmerchantNumberByOperatorId(byId.getOperatorId());
+ String nonce_str = UUIDUtil.getRandomCode(16);
+
+ ResultUtil fenzhang = payMoneyUtil.fenzhang(transaction_id, one.getMoney().multiply(bigDecimal1), s2,nonce_str,"玩游戏分账");
+ if (!fenzhang.getCode().equals(200)){
+ System.err.println("分账失败 原因是:"+fenzhang.getMsg());
+ }else{
+ one.setFenzhangNo(fenzhang.getData().toString());
+ one.setFenzhangOrderNo(nonce_str);
+ one.setFenzhangAmount(one.getMoney().multiply(bigDecimal1));
+ gameRecordService.updateById(one);
+ }
+ }
+ }
+ }
+
+ }
PrintWriter out = null;
try {
--
Gitblit v1.7.1