| | |
| | | if (null == uid) { |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | //判断当前用户是否是员工 |
| | | |
| | | AppUser appUser1 = appUserClient.queryAppUser(uid); |
| | | User one = userService.getOne(new QueryWrapper<User>().eq("phone", appUser1.getPhone()).eq("status", 1)); |
| | | if (null != one) { |
| | | //判断当前用户是否是员工 |
| | | List<User> one = userService.list(new QueryWrapper<User>().eq("phone", appUser1.getPhone()).eq("status", 1)); |
| | | if (!one.isEmpty()) { |
| | | return ResultUtil.success(1); |
| | | } |
| | | //普通用户校验当前时间是否在预约时间段内 |
| | |
| | | |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private IOperatorUserService operatorUserService; |
| | | @ResponseBody |
| | | @PostMapping("/api/game/payGame") |
| | | @ApiOperation(value = "支付游戏", tags = {"用户—游戏"}) |
| | |
| | | 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)); |
| | | if (null != one) { |
| | | List<User> one = userService.list(new QueryWrapper<User>().eq("phone", appUser1.getPhone()).eq("status", 1)); |
| | | if (!one.isEmpty()) { |
| | | Integer integer = startGame(uid, gameType, gameId, spaceId, sutuId); |
| | | return ResultUtil.success(); |
| | | } |
| | |
| | | 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 |
| | |
| | | } |
| | | gameRecordService.updateBatchById(list); |
| | | Integer integer = startGame(uid, gameType, gameId, spaceId, sutuId); |
| | | |
| | | break; |
| | | |
| | | } |
| | | if ("USERPAYING".equals(s) || "NOTPAY".equals(s)) { |
| | | num++; |
| | |
| | | Integer code1 = jsonObject.getInteger("code"); |
| | | String message = jsonObject.getString("message"); |
| | | if (200 == code1) { |
| | | System.err.println("--------------启动了世界杯游戏"); |
| | | System.err.println(s); |
| | | return 200; |
| | | } else { |
| | | System.err.println(message); |
| | | return 500; |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | @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"); |
| | | String result = map.get("result"); |
| | | //String params = uid + "_" + gameId + "_" + spaceId + "_" + sutuId+"_"+code+"_"+configId; |
| | | //String params = uid + "_" + gameId + "_" + spaceId + "_" + sutuId+"_"+code+"_"+configId + "_" + gameType; |
| | | //Integer integer = startGame(uid, gameType, gameId, spaceId, sutuId); |
| | | String attach = map.get("attach"); |
| | | |
| | | List<TGameRecord> list = gameRecordService.list(new QueryWrapper<TGameRecord>().eq("number", out_trade_no).eq("payType", 1)); |
| | |
| | | } |
| | | gameRecordService.updateBatchById(list); |
| | | String[] s = attach.split("_"); |
| | | Integer integer = startGame(Integer.valueOf(s[0]), Integer.valueOf(s[4]), Integer.valueOf(s[1]), Integer.valueOf(s[2]), Integer.valueOf(s[3])); |
| | | 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 { |
| | |
| | | if(null != map){ |
| | | String out_trade_no = map.get("out_trade_no"); |
| | | String transaction_id = map.get("trade_no"); |
| | | //String params = uid + "_" + gameId + "_" + spaceId + "_" + sutuId+"_"+code+"_"+configId; |
| | | //String params = uid + "_" + gameId + "_" + spaceId + "_" + sutuId+"_"+code+"_"+ configId + "_" + gameType; |
| | | //Integer integer = startGame(uid, gameType, gameId, spaceId, sutuId); |
| | | String attach = map.get("passback_params"); |
| | | |
| | | List<TGameRecord> list = gameRecordService.list(new QueryWrapper<TGameRecord>().eq("number", out_trade_no).eq("payType", 2)); |
| | |
| | | } |
| | | gameRecordService.updateBatchById(list); |
| | | String[] s = attach.split("_"); |
| | | Integer integer = startGame(Integer.valueOf(s[0]), Integer.valueOf(s[4]), Integer.valueOf(s[1]), Integer.valueOf(s[2]), Integer.valueOf(s[3])); |
| | | Integer integer = startGame(Integer.valueOf(s[0]), Integer.valueOf(s[6]), Integer.valueOf(s[1]), Integer.valueOf(s[2]), Integer.valueOf(s[3])); |
| | | |
| | | PrintWriter out = null; |
| | | try { |