| | |
| | | import com.dsh.other.feignclient.CourseRecordClient; |
| | | import com.dsh.other.feignclient.account.AppUserClient; |
| | | import com.dsh.other.feignclient.account.model.AppUser; |
| | | import com.dsh.other.model.GetTGameRecord; |
| | | import com.dsh.other.model.QueryMySiteVo; |
| | | import com.dsh.other.model.User; |
| | | import com.dsh.other.service.*; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @RestController |
| | | @RequestMapping("/api/game") |
| | | @RequestMapping("") |
| | | public class GameController { |
| | | |
| | | @Autowired |
| | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/getIntro") |
| | | @PostMapping("/api/game/getIntro") |
| | | @ApiOperation(value = "获取步骤说明", tags = {"用户—游戏"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/queryGameList") |
| | | @PostMapping("/api/game/queryGameList") |
| | | @ApiOperation(value = "获取当前场地的游戏列表配置", tags = {"用户—游戏"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "siteId", name = "siteId", dataType = "int", required = true), |
| | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/gameStartupCheck") |
| | | @PostMapping("/api/game/gameStartupCheck") |
| | | @ApiOperation(value = "扫码启动游戏前的校验(0=不通过,1=通过)", tags = {"用户—游戏"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "三方游戏id", name = "gameId", dataType = "int", required = true), |
| | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/payGame") |
| | | @PostMapping("/api/game/payGame") |
| | | @ApiOperation(value = "支付游戏", tags = {"用户—游戏"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "三方游戏id", name = "gameId", dataType = "int", required = true), |
| | |
| | | gameRecordService.save(tGameRecord); |
| | | |
| | | if (type == 1) { |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay("游戏支付", "", code, config.getCash().toString(), "/base/course/weChatPaymentCourseCallback", "APP", ""); |
| | | tGameRecord.setMoney(config.getCash()); |
| | | gameRecordService.updateById(tGameRecord); |
| | | String params = uid + "_" + gameId + "_" + spaceId + "_" + sutuId+"_"+code+"_"+configId; |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay("游戏支付", params, code, config.getCash().toString(), |
| | | "/base/game/wechatPaymentGameCallback", "APP", ""); |
| | | if (weixinpay.getCode() == 200) { |
| | | new Thread(new Runnable() { |
| | | @Override |
| | |
| | | break; |
| | | } |
| | | if ("SUCCESS".equals(s)) { |
| | | for (TGameRecord coursePackagePayment : list) { |
| | | coursePackagePayment.setStatus(1); |
| | | coursePackagePayment.setMoney(config.getCash()); |
| | | coursePackagePayment.setOrderNo(transaction_id); |
| | | |
| | | for (TGameRecord gameRecord : list) { |
| | | gameRecord.setStatus(1); |
| | | gameRecord.setOrderNo(transaction_id); |
| | | } |
| | | gameRecordService.updateBatchById(list); |
| | | Integer integer = startGame(uid, gameId, spaceId, sutuId); |
| | |
| | | } |
| | | return weixinpay; |
| | | } else if (type == 2) { |
| | | tGameRecord.setMoney(config.getCash()); |
| | | gameRecordService.updateById(tGameRecord); |
| | | String smid1=""; |
| | | String params = uid + "_" + gameId + "_" + spaceId + "_" + sutuId+"_"+code+"_"+configId; |
| | | // 判断这个课包属于哪个门店 属于哪个运营商 根据运营商 id 获取对应的商户号 |
| | | TGame game = gameService.getById(gameId); |
| | | |
| | | TGame game = gameService.getOne(new QueryWrapper<TGame>().eq("blue", sutuId).or().eq("red", sutuId)); |
| | | Integer operationId = game.getOperationId(); |
| | | if (operationId==0){ |
| | | // 是平台的 |
| | |
| | | smid1 = smidByOperatorId; |
| | | } |
| | | |
| | | ResultUtil alipay = payMoneyUtil.alipay(smid1,"游戏支付", "游戏支付", params, code, config.getCash().toString(), "/base/site/gameCallback"); |
| | | ResultUtil alipay = payMoneyUtil.alipay(smid1,"游戏支付", "游戏支付", params, code, config.getCash().toString(), |
| | | "/base/game/aliPaymentGameCallback"); |
| | | if (alipay.getCode() == 200) { |
| | | new Thread(new Runnable() { |
| | | @Override |
| | |
| | | break; |
| | | } |
| | | if ("TRADE_SUCCESS".equals(s)) { |
| | | for (TGameRecord coursePackagePayment : list) { |
| | | coursePackagePayment.setStatus(1); |
| | | coursePackagePayment.setMoney(config.getCash()); |
| | | coursePackagePayment.setOrderNo(tradeNo); |
| | | for (TGameRecord gameRecord : list) { |
| | | gameRecord.setStatus(1); |
| | | gameRecord.setOrderNo(tradeNo); |
| | | |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setChangeType(3); |
| | |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/getTGameBySutuId") |
| | | @PostMapping("/api/game/getTGameBySutuId") |
| | | public TGame getTGameBySutuId(@RequestBody String sutuId){ |
| | | return gameService.getOne(new QueryWrapper<TGame>().eq("blue", sutuId).or() |
| | | .eq("red", sutuId).eq("state", 0)); |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/game/wechatPaymentGameCallback") |
| | | public void wechatPaymentGameCallback(HttpServletRequest request, HttpServletResponse response){ |
| | | Map<String, String> map = payMoneyUtil.weixinpayCallback(request); |
| | | 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 attach = map.get("attach"); |
| | | |
| | | List<TGameRecord> list = gameRecordService.list(new QueryWrapper<TGameRecord>().eq("number", out_trade_no).eq("payType", 1)); |
| | | for (TGameRecord gameRecord : list) { |
| | | gameRecord.setStatus(1); |
| | | gameRecord.setOrderNo(transaction_id); |
| | | |
| | | |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setChangeType(3); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("智慧球场;" + gameRecord.getMoney()); |
| | | courseCounsum.setAppUserId(gameRecord.getUserId()); |
| | | courseRecordClient.save(courseCounsum); |
| | | |
| | | } |
| | | gameRecordService.updateBatchById(list); |
| | | String[] s = attach.split("_"); |
| | | Integer integer = startGame(Integer.valueOf(s[0]), Integer.valueOf(s[1]), Integer.valueOf(s[2]), Integer.valueOf(s[3])); |
| | | |
| | | PrintWriter out = null; |
| | | try { |
| | | out = response.getWriter(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | out.print(result); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/game/aliPaymentGameCallback") |
| | | public void aliPaymentGameCallback(HttpServletRequest request, HttpServletResponse response){ |
| | | Map<String, String> map = payMoneyUtil.alipayCallback(request); |
| | | 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 attach = map.get("passback_params"); |
| | | |
| | | List<TGameRecord> list = gameRecordService.list(new QueryWrapper<TGameRecord>().eq("number", out_trade_no).eq("payType", 2)); |
| | | for (TGameRecord gameRecord : list) { |
| | | gameRecord.setStatus(1); |
| | | gameRecord.setOrderNo(transaction_id); |
| | | |
| | | |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setChangeType(3); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("智慧球场;" + gameRecord.getMoney()); |
| | | courseCounsum.setAppUserId(gameRecord.getUserId()); |
| | | courseRecordClient.save(courseCounsum); |
| | | |
| | | } |
| | | gameRecordService.updateBatchById(list); |
| | | String[] s = attach.split("_"); |
| | | Integer integer = startGame(Integer.valueOf(s[0]), Integer.valueOf(s[1]), Integer.valueOf(s[2]), Integer.valueOf(s[3])); |
| | | |
| | | PrintWriter out = null; |
| | | try { |
| | | out = response.getWriter(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | out.print("success"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/game/getTGameRecord") |
| | | public List<TGameRecord> getTGameRecord(@RequestBody GetTGameRecord getTGameRecord){ |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | return gameRecordService.list(new QueryWrapper<TGameRecord>().eq("userId", getTGameRecord.getAppUserId()).eq("status", 1).in("payType", Arrays.asList(1, 2)) |
| | | .last(" and DATE_FORMAT(time, '%Y-%m-%d %H:%i:%s') between '" + sdf.format(getTGameRecord.getStartTiem()) +"' and '" + sdf.format(getTGameRecord.getEndTime()) + "'")); |
| | | } |
| | | } |