From 46ae91d150985e38ecec8768634cc1ee15c5151b Mon Sep 17 00:00:00 2001 From: liujie <1793218484@qq.com> Date: 星期四, 07 八月 2025 19:02:06 +0800 Subject: [PATCH] 赛事模块 --- cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupServiceImpl.java | 77 ++++++++++++++++++++++++++++++-------- 1 files changed, 60 insertions(+), 17 deletions(-) diff --git a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupServiceImpl.java b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupServiceImpl.java index d6e4137..635b821 100644 --- a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupServiceImpl.java +++ b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupServiceImpl.java @@ -513,7 +513,8 @@ return payment; } - private String smidVx = "2088330203191220";//平台微信商户号 + private String smid = "2088330203191220";//平台支付宝商户号 + /** * 支付逻辑 @@ -569,30 +570,29 @@ } //支付宝 if(payType == 2){ + String smidRes = smid;// 结算资金到商户号 + worldCupPayment.setAmount(new BigDecimal(num).multiply(worldCup.getCash())); worldCupPayment.setUnitPrice(worldCupPayment.getAmount().divide(new BigDecimal(num))); worldCupPaymentService.save(worldCupPayment); List<WorldCupStore> list = worldCupStoreService.lambdaQuery().eq(WorldCupStore::getWorldCupId, worldCup.getId()).list(); if (list.isEmpty()){ - return payMoneyUtil.alipay("2088330203191220", "社区世界杯报名", "世界杯报名", "", worldCupPayment.getCode(), - worldCupPayment.getAmount().toString(), "/base/worldCup/aliPayWorldCupCallback"); }else{ Integer storeId = list.get(0).getStoreId(); Store store = storeClient.queryStoreById(storeId); if (store.getOperatorId()==null||store.getOperatorId()==0){ - return payMoneyUtil.alipay("2088330203191220", "社区世界杯报名", "世界杯报名", "", worldCupPayment.getCode(), - worldCupPayment.getAmount().toString(), "/base/worldCup/aliPayWorldCupCallback"); }else{ String s2 = storeClient.getmerchantNumberAliByOperatorId(store.getOperatorId()); System.err.println("支付宝商户号"+s2); if(!StringUtils.hasLength(s2)){ return ResultUtil.error("运营商未配置支付宝商户号,获取支付失败!"); } - return payMoneyUtil.alipay(s2, "社区世界杯报名", "世界杯报名", "", worldCupPayment.getCode(), - worldCupPayment.getAmount().toString(), "/base/worldCup/aliPayWorldCupCallback"); + smidRes=s2; } } + return payMoneyUtil.alipay(smidRes, "社区世界杯报名", "世界杯报名", "", worldCupPayment.getCode(), + worldCupPayment.getAmount().toString(), "/base/worldCup/aliPayWorldCupCallback"); } //玩湃币 if(payType == 3){ @@ -756,7 +756,7 @@ * @return */ @Override - public ResultUtil paymentWorldCupCallback(String code, String outTradeNo) { + public ResultUtil paymentWorldCupCallback(String code, String outTradeNo) throws AlipayApiException { WorldCupPayment worldCupPayment = worldCupPaymentService.getOne(new QueryWrapper<WorldCupPayment>().eq("code", code)); Integer worldCupId = worldCupPayment.getWorldCupId(); worldCupPayment.setPayStatus(2); @@ -784,6 +784,35 @@ worldCupPaymentParticipant.setCreateTime(new Date()); worldCupPaymentParticipantService.save(worldCupPaymentParticipant); } + if (worldCupPayment.getPayType()==2){ + List<WorldCupStore> list = worldCupStoreService.lambdaQuery().eq(WorldCupStore::getWorldCupId, worldCupPayment.getWorldCupId()).list(); + String resSmid = smid; + if (!list.isEmpty()){ + Integer storeId = list.get(0).getStoreId(); + Store store = storeClient.queryStoreById(storeId); + if (store.getOperatorId()==null||store.getOperatorId()==0){ + }else{ + String s2 = storeClient.getmerchantNumberAliByOperatorId(store.getOperatorId()); + System.err.println("支付宝商户号"+s2); + if(!StringUtils.hasLength(s2)){ + return ResultUtil.error("运营商未配置支付宝商户号,获取支付失败!"); + } + resSmid=s2; + } + } + String finalResSmid = resSmid; + new Thread(new Runnable() { + @Override + public void run() { + try { + Thread.sleep(30000); + payMoneyUtil.confirm(finalResSmid, code, outTradeNo, worldCupPayment.getAmount().toString()); + }catch (Exception e){ + } + } + }).start(); + } + return ResultUtil.success(); } @@ -820,10 +849,13 @@ * @param id */ @Override - public void cancelWorldCupRefund(Integer id) { + public void cancelWorldCupRefund(Integer id) throws Exception { //免费除外 List<WorldCupPayment> list2 = worldCupPaymentService.list(new QueryWrapper<WorldCupPayment>().eq("worldCupId", id) .ne("payType", 0).eq("payStatus", 2).eq("state", 1)); + List<WorldCupStore> list = worldCupStoreService.lambdaQuery().eq(WorldCupStore::getWorldCupId, id).list(); + Integer storeId = list.get(0).getStoreId(); + Store store = storeClient.queryStoreById(storeId); for (WorldCupPayment worldCupPayment : list2) { List<WorldCupPaymentParticipant> list1 = worldCupPaymentParticipantService.list(new QueryWrapper<WorldCupPaymentParticipant>() .eq("worldCupId", id).eq("worldCupPaymentId", worldCupPayment.getId()).eq("alreadyEntered", 0)); @@ -831,14 +863,25 @@ BigDecimal multiply = worldCupPayment.getUnitPrice().multiply(new BigDecimal(list1.size())); //微信支付 if(worldCupPayment.getPayType() == 1){ - Map<String, String> map = payMoneyUtil.wxRefund(worldCupPayment.getPayOrderNo(), worldCupPayment.getCode(), - worldCupPayment.getAmount().toString(), multiply.toString(), "/base/worldCup/wxRefundWorldCupCallback"); - if(!"SUCCESS".equals(map.get("return_code"))){ - System.err.println("-------------微信退款失败---------"); - System.err.println(map.get("return_msg")); - }else{ - worldCupPayment.setRefundAmount(multiply); - worldCupPaymentService.updateById(worldCupPayment); + if (store.getOperatorId()!=null && store.getOperatorId()!=0){ + String smidVx= storeClient.getmerchantNumberByOperatorId(store.getOperatorId()); + if (!StringUtils.hasLength(smidVx)){ + System.err.println("运营商未配置微信商户号,获取支付失败!"); + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + String codeRefund = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5);// 退款单号 + // 运营商退款 + payMoneyUtil.weixinRefundV3(smidVx, codeRefund, worldCupPayment.getPayOrderNo(), worldCupPayment.getAmount().toString(), "/base/worldCup/wxRefundWorldCupCallback1"); + }else { + Map<String, String> map = payMoneyUtil.wxRefund(worldCupPayment.getPayOrderNo(), worldCupPayment.getCode(), + worldCupPayment.getAmount().toString(), multiply.toString(), "/base/worldCup/wxRefundWorldCupCallback"); + if (!"SUCCESS".equals(map.get("return_code"))) { + System.err.println("-------------微信退款失败---------"); + System.err.println(map.get("return_msg")); + } else { + worldCupPayment.setRefundAmount(multiply); + worldCupPaymentService.updateById(worldCupPayment); + } } } //支付宝支付 -- Gitblit v1.7.1