cloud-server-account/src/main/java/com/dsh/account/service/impl/TAppUserServiceImpl.java
@@ -1700,7 +1700,7 @@ if (coupon!=null){ if (!couponStoreIds.isEmpty()&&!couponStoreIds.contains(-1)){ // 微信商户号 String s2 = storeClient.getmerchantNumberByOperatorId(coupon.getCityManagerId()); String s2 = storeClient.getmerchantNumberByOperatorId(couponStoreIds.get(0)); System.err.println("微信商户号"+s2); if(!StringUtils.hasLength(s2)){ cloud-server-activity/src/main/java/com/dsh/activity/controller/HuiminController.java
@@ -85,8 +85,7 @@ @Autowired private TokenUtil tokenUtil; private String smid = "2088330203191220";//平台支付宝商户号 // todo 待申请 private String smidVx = "2088330203191220";//平台微信商户号 /** @@ -169,7 +168,7 @@ // "/base/huimin/callBack/weixinPayHuiminCallback1",tPayHuimin.getSalesMoney().toString()); case 2: String string = tPayHuimin.getSalesMoney().toString(); return payMoneyUtil.alipay("2088670241691219", "购买玩湃惠民卡", "购买玩湃惠民卡", "", tPayHuimin.getCode(), string, return payMoneyUtil.alipay(smid, "购买玩湃惠民卡", "购买玩湃惠民卡", "", tPayHuimin.getCode(), string, "/base/huimin/callBack/aliPayHuiminCallback"); } cloud-server-competition/src/main/java/com/dsh/competition/feignclient/other/model/Store.java
@@ -87,4 +87,9 @@ * 状态(1=正常,2=冻结,3=删除) */ private Integer state; /** * 运营商id */ private Integer operatorId; } cloud-server-competition/src/main/java/com/dsh/competition/service/impl/CompetitionServiceImpl.java
@@ -300,7 +300,10 @@ } if (paymentCompetitionVo.getPayType() == 1) {//微信 Competition byId = competitionService.getById(paymentCompetitionVo.getId()); Integer operatorId = byId.getOperatorId(); String[] split = byId.getStoreId().split(","); Store store = storeClient.queryStoreById(Integer.valueOf(split[0])); Integer operatorId = store.getOperatorId(); if (operatorId!=null && operatorId != 0){ // 运营商 String s = storeClient.getmerchantNumberByOperatorId(operatorId); @@ -320,7 +323,10 @@ if (paymentCompetitionVo.getPayType() == 2) {//支付宝 // 判断当前赛事属于哪个运营商 Competition byId = competitionService.getById(paymentCompetitionVo.getId()); Integer operatorId = byId.getOperatorId(); String[] split = byId.getStoreId().split(","); Store store = storeClient.queryStoreById(Integer.valueOf(split[0])); Integer operatorId = store.getOperatorId(); if (operatorId == null || operatorId == 0 ){ // 说明是平台 return aliPaymentCompetition(operatorId,smid,code, money); cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TSiteController.java
@@ -619,12 +619,8 @@ Integer storeId = tSiteDTO.getStoreId(); TStore byId = storeService.getById(storeId); if (byId!=null){ if (byId.getType()==1){ if (byId.getOperatorId()==null || byId.getOperatorId()==0){ tSiteDTO.setOperator("平台"); }else{ TOperator byId1 = tOperatorService.getById(tSiteDTO.getOperatorId()); if (byId1!=null) tSiteDTO.setOperator(byId1.getName()); } } } cloud-server-other/src/main/java/com/dsh/other/controller/GameController.java
@@ -206,14 +206,6 @@ } Site site = siteService.getById(spaceId); Store store = storeService.getById(site.getStoreId()); // 是否分账 0否1是 int isFenZhang= 1; String merchantNumber = ""; if (store.getOperatorId()==null || store.getOperatorId()==0){ // 平台 isFenZhang = 0; } //判断当前用户是否是员工 AppUser appUser1 = appUserClient.queryAppUser(uid); List<User> one = userService.list(new QueryWrapper<User>().eq("phone", appUser1.getPhone()).eq("status", 1)); @@ -252,7 +244,7 @@ return ResultUtil.error("运营商未配置微信商户号,获取支付失败!"); } return payMoneyUtil.weixinpayV3(smidVx,"游戏支付" ,code,"/base/huimin/callBack/wechatPaymentGameCallback1", ,code,"/base/game/wechatPaymentGameCallback1", config.getCash().toString(),params); } @@ -264,9 +256,10 @@ gameRecordService.updateById(tGameRecord); String smid1=""; String params = uid + "_" + gameId + "_" + spaceId + "_" + sutuId+"_"+code+"_"+ configId + "_" + gameType; // 判断这个课包属于哪个门店 属于哪个运营商 根据运营商 id 获取对应的商户号 // 判断属于哪个运营商 根据运营商 id 获取对应的商户号 TGame game = gameService.getOne(new QueryWrapper<TGame>().eq("blue", sutuId).or().eq("red", sutuId)); Integer operationId = game.getOperationId(); Store byId = storeService.getById(game.getStoreId()); Integer operationId = byId.getOperatorId(); if (operationId==0){ // 是平台的 smid1 = smid; @@ -277,75 +270,64 @@ ResultUtil alipay = payMoneyUtil.alipay(smid1,"游戏支付", "游戏支付", params, code, config.getCash().toString(), "/base/game/aliPaymentGameCallback"); // if (alipay.getCode() == 200) { // new Thread(new Runnable() { // @Override // public void run() { // try { // int num = 1; // int wait = 0; // while (num <= 10) { // int min = 5000; // wait += (min * num); // Thread.sleep(wait); // List<TGameRecord> list = gameRecordService.list(new QueryWrapper<TGameRecord>().eq("number", code).eq("payType", 2)); // TGameRecord one = list.get(0); // if (one.getStatus() == 1) { // break; // } // AlipayTradeQueryResponse resultUtil = payMoneyUtil.queryALIOrder(code); // if (resultUtil.getCode().equals("10000") && one.getStatus() == 0) { // /** // * WAIT_BUYER_PAY(交易创建,等待买家付款)、 // * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、 // * TRADE_SUCCESS(交易支付成功)、 // * TRADE_FINISHED(交易结束,不可退款) // */ // String tradeNo = resultUtil.getTradeNo(); // String s = resultUtil.getTradeStatus(); // if ("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10) { // break; // } // if ("TRADE_SUCCESS".equals(s)) { // for (TGameRecord gameRecord : list) { // gameRecord.setStatus(1); // gameRecord.setOrderNo(tradeNo); // // CourseCounsum courseCounsum = new CourseCounsum(); // courseCounsum.setChangeType(3); // courseCounsum.setInsertTime(new Date()); // courseCounsum.setReason("智慧球场;" + config.getCash()); // courseCounsum.setAppUserId(uid); // courseRecordClient.save(courseCounsum); // // } // gameRecordService.updateBatchById(list); // Integer integer = startGame(uid, gameType, gameId, spaceId, sutuId); // // 判断这个课包属于哪个门店 属于哪个运营商 根据运营商 id 获取对应的商户号 // TGame game = gameService.getById(gameId); // String smid2=""; // Integer operationId = game.getOperationId(); // if (operationId==0){ // // 是平台的 // smid2 = smid; // }else{ // String smidByOperatorId = siteService.getSMIDByOperatorId(operationId); // smid2 = smidByOperatorId; // } // payMoneyUtil.confirm(smid2,code,tradeNo,config.getCash().toString()); // break; // } // if ("WAIT_BUYER_PAY".equals(s)) { // num++; // } // } // } // } catch (Exception e) { // e.printStackTrace(); // } // } // }).start(); // } if (alipay.getCode() == 200) { new Thread(new Runnable() { @Override public void run() { try { int num = 1; int wait = 0; while (num <= 10) { int min = 5000; wait += (min * num); Thread.sleep(wait); List<TGameRecord> list = gameRecordService.list(new QueryWrapper<TGameRecord>().eq("number", code).eq("payType", 2)); TGameRecord one = list.get(0); if (one.getStatus() == 1) { break; } AlipayTradeQueryResponse resultUtil = payMoneyUtil.queryALIOrder(code); if (resultUtil.getCode().equals("10000") && one.getStatus() == 0) { /** * WAIT_BUYER_PAY(交易创建,等待买家付款)、 * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、 * TRADE_SUCCESS(交易支付成功)、 * TRADE_FINISHED(交易结束,不可退款) */ String tradeNo = resultUtil.getTradeNo(); String s = resultUtil.getTradeStatus(); if ("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10) { break; } if ("TRADE_SUCCESS".equals(s)) { for (TGameRecord gameRecord : list) { gameRecord.setStatus(1); gameRecord.setOrderNo(tradeNo); CourseCounsum courseCounsum = new CourseCounsum(); courseCounsum.setChangeType(3); courseCounsum.setInsertTime(new Date()); courseCounsum.setReason("智慧球场;" + config.getCash()); courseCounsum.setAppUserId(uid); courseRecordClient.save(courseCounsum); } gameRecordService.updateBatchById(list); Integer integer = startGame(uid, gameType, gameId, spaceId, sutuId); break; } if ("WAIT_BUYER_PAY".equals(s)) { num++; } } } } catch (Exception e) { e.printStackTrace(); } } }).start(); } return alipay; } else if (type == 3) { tGameRecord.setMoney(config.getPlayCoin()); @@ -481,50 +463,6 @@ 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 { out = response.getWriter(); cloud-server-other/src/main/java/com/dsh/other/controller/SiteController.java
@@ -505,7 +505,10 @@ @PostMapping("/base/site/aliPaymentSiteCallback") public void aliPaymentSiteCallback(HttpServletRequest request, HttpServletResponse response) { try { System.err.println("预约场地回调"); Map<String, String> map = payMoneyUtil.alipayCallback(request); System.err.println("map"); System.err.println(map); if (null != map) { String code = map.get("out_trade_no"); String trade_no = map.get("trade_no"); cloud-server-other/src/main/java/com/dsh/other/service/impl/SiteServiceImpl.java
@@ -469,16 +469,14 @@ String code = siteBooking.getOrderNo(); Integer id = siteBooking.getId(); Site byId = siteService.getById(siteBooking.getSiteId()); // 是否分账 0否1是 int isFenZhang= 1; String merchantNumber = ""; if (byId.getOperatorId()==null || byId.getOperatorId()==0){ Store store = storeService.getById(byId.getStoreId()); if (store.getOperatorId()==null || store.getOperatorId()==0){ // 平台 ResultUtil weixinpay = payMoneyUtil.weixinpay("预约场地-"+isFenZhang, id.toString(), code, paymentPrice.toString(), ResultUtil weixinpay = payMoneyUtil.weixinpay("预约场地", id.toString(), code, paymentPrice.toString(), "/base/site/weChatPaymentSiteCallback", "APP", ""); return weixinpay; }else{ String smidVx= operatorUserService.getmerchantNumberByOperatorId(byId.getOperatorId()); String smidVx= operatorUserService.getmerchantNumberByOperatorId(store.getOperatorId()); if (!StringUtils.hasLength(smidVx)){ return ResultUtil.error("运营商未配置微信商户号,获取支付失败!"); } @@ -521,71 +519,56 @@ } ResultUtil alipay = payMoneyUtil.alipay(smid1,"预约场地", "预约场地", id.toString(), code, paymentPrice.toString(), "/base/site/aliPaymentSiteCallback"); System.out.println("预约场地----" + alipay.getCode()); // if (alipay.getCode() == 200) { // new Thread(new Runnable() { // @Override // public void run() { // try { // int num = 1; // int wait = 0; // while (num <= 10) { // int min = 5000; // wait += (min * num); // Thread.sleep(wait); // SiteBooking siteBooking = siteBookingService.getById(id); // if (siteBooking.getStatus() != 0) { // break; // } // AlipayTradeQueryResponse resultUtil = payMoneyUtil.queryALIOrder(code); // if (resultUtil.getCode().equals("10000") && siteBooking.getStatus() == 0) { // /** // * WAIT_BUYER_PAY(交易创建,等待买家付款)、 // * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、 // * TRADE_SUCCESS(交易支付成功)、 // * TRADE_FINISHED(交易结束,不可退款) // */ //// Map<String, String> data1 = resultUtil.getData(); //// String s = data1.get("tradeStatus"); // String tradeNo = resultUtil.getTradeNo(); // String s = resultUtil.getTradeStatus(); // System.out.println("ssssss" + s); // if ("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10) { // break; // } // if ("TRADE_SUCCESS".equals(s)) { // siteBooking.setPayTime(new Date()); // siteBooking.setStatus(1); // siteBooking.setPayOrderNo(tradeNo); // siteBookingService.updateById(siteBooking); // System.err.println("======完成支付"); // // 判断预约的门店 属于哪个运营商 // Integer storeId = siteBooking.getStoreId(); // Store byId = storeService.getById(storeId); // Integer operatorId = byId.getOperatorId(); // String smid1 = ""; // if (operatorId == null || operatorId == 0){ // // 平台的门店 不冻结资金不做分账处理 // payMoneyUtil.confirm1(smid1,code,tradeNo,paymentPrice.toString()); // }else{ // smid1 = siteService.getSMIDByOperatorId(operatorId); // payMoneyUtil.confirm(smid1,code,tradeNo,paymentPrice.toString()); // // 分账 // extracted(operatorId, new BigDecimal(paymentPrice.toString()), tradeNo); // } // // break; // } // if ("WAIT_BUYER_PAY".equals(s)) { // num++; // } // } // } // } catch (Exception e) { // e.printStackTrace(); // } // } // }).start(); // } if (alipay.getCode() == 200) { new Thread(new Runnable() { @Override public void run() { try { int num = 1; int wait = 0; while (num <= 10) { int min = 5000; wait += (min * num); Thread.sleep(wait); SiteBooking siteBooking = siteBookingService.getById(id); if (siteBooking.getStatus() != 0) { break; } AlipayTradeQueryResponse resultUtil = payMoneyUtil.queryALIOrder(code); if (resultUtil.getCode().equals("10000") && siteBooking.getStatus() == 0) { /** * WAIT_BUYER_PAY(交易创建,等待买家付款)、 * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、 * TRADE_SUCCESS(交易支付成功)、 * TRADE_FINISHED(交易结束,不可退款) */ // Map<String, String> data1 = resultUtil.getData(); // String s = data1.get("tradeStatus"); String tradeNo = resultUtil.getTradeNo(); String s = resultUtil.getTradeStatus(); System.out.println("ssssss" + s); if ("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10) { break; } if ("TRADE_SUCCESS".equals(s)) { siteBooking.setPayTime(new Date()); siteBooking.setStatus(1); siteBooking.setPayOrderNo(tradeNo); siteBookingService.updateById(siteBooking); System.err.println("======完成支付"); break; } if ("WAIT_BUYER_PAY".equals(s)) { num++; } } } } catch (Exception e) { e.printStackTrace(); } } }).start(); } return alipay; } cloud-server-other/src/main/java/com/dsh/other/util/PayMoneyUtil.java
@@ -241,9 +241,6 @@ SubMerchant subMerchant = new SubMerchant(); subMerchant.setMerchantId(smid); model.setSubMerchant(subMerchant); ExtendParams extendParams = new ExtendParams(); extendParams.setRoyaltyFreeze("true");// 冻结资金 用于后续分账处理 model.setExtendParams(extendParams); request.setBizModel(model); request.setNotifyUrl(callbackPath + notifyUrl); @@ -454,7 +451,7 @@ map.put("appid", appid); map.put("mch_id", mchId); map.put("nonce_str", nonce_str); String temp = ""; map.put("body", body); map.put("attach", attach);//存储订单id map.put("out_trade_no", out_trade_no);//存储的订单code @@ -572,7 +569,7 @@ request.description = description;// 描述 request.outTradeNo = outTradeNo;// 订单号 request.notifyUrl = callbackPath+notifyUrl;// 回调地址 request.attach = attach;// 回调地址 request.attach = attach;// 自定义参数 request.amount = new PartnerAppPrepay.CommonAmountInfo(); request.amount.total = (long) i;// 金额 单位分 request.amount.currency = "CNY"; @@ -602,6 +599,7 @@ map3.put("sign", sign); map3.put("package", "Sign=WXPay"); map3.put("partnerid", WxV3PayConfig.Mch_ID);// 服务商商户号 map3.put("siteBooking", attach); System.err.println(map3); return ResultUtil.success(map3); } cloud-server-other/src/main/resources/mapper/SiteMapper.xml
@@ -109,10 +109,10 @@ select t1.*,t2.name storeName,t3.name siteTypeName ,t4.name operator from t_site t1 inner join t_store t2 on t1.storeId = t2.id left join t_site_type t3 on t1.siteTypeId = t3.id left join t_operator t4 on t1.operatorId = t4.id left join t_operator t4 on t2.operatorId = t4.id <where> <if test="query.objectType == 2"> and t1.operatorId = #{query.objectId} and t2.operatorId = #{query.objectId} </if> <if test="query.objectType == 3"> and t2.id = #{query.objectId} cloud-server-other/src/main/resources/mapper/TOperatorUserMapper.xml
@@ -4,6 +4,6 @@ <select id="getmerchantNumberByOperatorId" resultType="java.lang.String"> select merchantNumber from t_operator_user where id=#{operatorId} select merchantNumber from t_operator where id=#{operatorId} </select> </mapper>