From 9486766c806fe1d9e082b2fd02ea1cc558f1b443 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期四, 08 五月 2025 09:21:57 +0800 Subject: [PATCH] bug修改 --- cloud-server-other/src/main/java/com/dsh/other/controller/SiteController.java | 213 +++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 150 insertions(+), 63 deletions(-) diff --git a/cloud-server-other/src/main/java/com/dsh/other/controller/SiteController.java b/cloud-server-other/src/main/java/com/dsh/other/controller/SiteController.java index 87ad7a7..b1d4ebc 100644 --- a/cloud-server-other/src/main/java/com/dsh/other/controller/SiteController.java +++ b/cloud-server-other/src/main/java/com/dsh/other/controller/SiteController.java @@ -15,6 +15,7 @@ import com.dsh.other.feignclient.model.BillingDataRequestVo; import com.dsh.other.feignclient.model.SiteChangeStateVO; import com.dsh.other.feignclient.model.SiteVo; +import com.dsh.other.mapper.TOperatorUserMapper; import com.dsh.other.model.*; import com.dsh.other.model.dto.siteDto.TSiteDTO; import com.dsh.other.model.vo.siteVo.ExpireSiteSearchVO; @@ -24,6 +25,7 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.web.bind.annotation.*; @@ -33,6 +35,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.PrintWriter; +import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -62,8 +65,36 @@ @Resource private UserCouponClient userCouponClient; - @Autowired + + @Resource private CityManagerClient cityManagerClient; + @Autowired + private IOperatorUserService operatorUserService; + + @Autowired + private TGameConfigService gameConfigService; + + @Autowired + private TGameRecordService gameRecordService; + + @Resource + private CourseRecordClient courseRecordClient; +@Resource +private StoreService storeService; + + @Autowired + private RedisUtil redisUtil; + + + + + + + + + + + /** * 通过运营商id查询运营商对应的支付宝商户号 @@ -71,8 +102,33 @@ @RequestMapping("/base/getSMIDByOperatorId") @ResponseBody public String getSMIDByOperatorId(Integer id) { - // 获取运营商的管理员 return siteService.getSMIDByOperatorId(id); + } + /** + * 通过运营商id查询运营商对应的微信商户号 + */ + @RequestMapping("/base/getmerchantNumberByOperatorId/{id}") + @ResponseBody + public String getmerchantNumberByOperatorId(@PathVariable("id")Integer id) { + return siteService.getmerchantNumberByOperatorId(id); + } + /** + * 根据运营商id获取对应运营商分账比例 返回格式: 微信分账比例,支付宝分账比例 + */ + @RequestMapping("/base/getProportionByOperatorId/{id}") + @ResponseBody + public String getProportionByOperatorId(@PathVariable("id")Integer id) { + OperatorUser operatorId = operatorUserService.getOne( + new QueryWrapper<OperatorUser>().eq("operatorId",id) + ); + if (operatorId.getWechatProportion() == null){ + operatorId.setWechatProportion("0"); + } + if (operatorId.getAlipayProportion() == null){ + operatorId.setAlipayProportion("0"); + } + System.err.println("查询分账比例"+operatorId); + return operatorId.getWechatProportion()+","+operatorId.getAlipayProportion(); } /** * 获取所有场地 @@ -164,14 +220,14 @@ } @RequestMapping("/base/site/listById") - public Site listById(@RequestParam("id") Integer id) { + public Site listById(@RequestBody Integer id) { Site byId = siteService.getById(id); return byId; } @RequestMapping("/base/site/listBooks") - public List<SiteBooking> listBooks(@RequestParam("id") Integer id) { + public List<SiteBooking> listBooks(@RequestBody Integer id) { List<SiteBooking> siteId = siteBookingService.list(new QueryWrapper<SiteBooking>().eq("siteId", id)); return siteId; } @@ -226,9 +282,6 @@ } } - @Autowired - private RedisUtil redisUtil; - @ResponseBody @PostMapping("/base/site/querySiteTimes") @ApiOperation(value = "获取场地详情时间段数据", tags = {"用户—预约场地"}) @@ -268,6 +321,22 @@ return null; } } + /** + * 根据id获取数据 + * + * @param ids + * @return + */ + @ResponseBody + @PostMapping("/site/querySiteByStoreIds") + public List<Site> querySiteByStoreIds(@RequestBody String ids) { + try { + return siteService.lambdaQuery().in(Site::getStoreId,Arrays.asList(ids.split(","))).list(); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } @ResponseBody @@ -289,20 +358,6 @@ } } -// public ResultUtil<List<QuerySiteTimes>> querySiteTimes(Integer id, String day, String halfName, String siteName) throws Exception { -// -// if (redisUtil.acquireLock(day,day)) { -// try { -// List<QuerySiteTimes> list = siteService.querySiteTimes(id, day,halfName,siteName); -// return ResultUtil.success(list); -// } finally { -// redisUtil.releaseLock(day); -// } -// } else { -// return ResultUtil.error("系统繁忙,请稍后再试!"); -// } -// -// } /** @@ -315,6 +370,7 @@ @PostMapping("/base/site/weChatPaymentSiteCallback") public void weChatPaymentSiteCallback(HttpServletRequest request, HttpServletResponse response) { try { + System.err.println("预约场地回调"); Map<String, String> map = payMoneyUtil.weixinpayCallback(request); if (null != map) { String code = map.get("out_trade_no"); @@ -326,11 +382,49 @@ siteBooking.setStatus(1); siteBooking.setPayOrderNo(transaction_id); siteBookingService.updateById(siteBooking); + Store byId = service.getById(siteBooking.getStoreId()); + if (byId.getOperatorId()!=null && byId.getOperatorId()!=0){ + System.err.println("预约场地分账"); + // 休眠两分钟后再调用分账接口 避免提示订单正在处理中 + 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); + BigDecimal bigDecimal2 = new BigDecimal(siteBooking.getPayMoney()); + ResultUtil fenzhang = payMoneyUtil.fenzhang(transaction_id, bigDecimal2.multiply(bigDecimal1), s2,nonce_str,"预约场地分账"); + if (!fenzhang.getCode().equals(200)){ + System.err.println("分账失败 原因是:"+fenzhang.getMsg()); + }else{ + siteBooking.setFenzhangNo(fenzhang.getData().toString()); + siteBooking.setFenzhangOrderNo(nonce_str); + siteBooking.setFenzhangAmount(bigDecimal2.multiply(bigDecimal1)); + siteBookingService.updateById(siteBooking); + } + } + } + PrintWriter out = response.getWriter(); + out.write(result); + out.flush(); + out.close(); } - PrintWriter out = response.getWriter(); - out.write(result); - out.flush(); - out.close(); + } } catch (Exception e) { e.printStackTrace(); @@ -347,7 +441,6 @@ @PostMapping("/base/site/aliPaymentSiteCallback") public void aliPaymentSiteCallback(HttpServletRequest request, HttpServletResponse response) { try { - System.out.println("回调回调回调"); Map<String, String> map = payMoneyUtil.alipayCallback(request); if (null != map) { String code = map.get("out_trade_no"); @@ -359,24 +452,21 @@ siteBooking.setStatus(1); siteBooking.setPayOrderNo(trade_no); siteBookingService.updateById(siteBooking); + PrintWriter out = response.getWriter(); + out.write("success"); + out.flush(); + out.close(); } - PrintWriter out = response.getWriter(); - out.write("success"); - out.flush(); - out.close(); } } catch (Exception e) { e.printStackTrace(); } } - @Autowired - private TGameConfigService gameConfigService; - @Autowired - private TGameRecordService gameRecordService; - @Resource - private CourseRecordClient courseRecordClient; + + + /** * 启动游戏支付宝回调 * @@ -387,10 +477,8 @@ @PostMapping("/base/site/gameCallback") public void gameCallback(HttpServletRequest request, HttpServletResponse response) { try { - System.out.println("回调回调回调"); Map<String, String> map = payMoneyUtil.alipayCallback(request); if (null != map) { - String code = map.get("passback_params"); String trade_no = map.get("trade_no"); String[] s = code.split("_"); @@ -412,7 +500,6 @@ } gameRecordService.updateBatchById(list); - System.err.println("===========游戏回调游戏回调=========" + i); PrintWriter out = response.getWriter(); out.write("success"); out.flush(); @@ -432,7 +519,7 @@ map.put("space_id", spaceId + ""); map.put("sutu_id", sutuId + ""); - String s = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/gameStart", map); + String s = HttpRequestUtil.postRequest("https://port.daowepark.com/v7/user_api/general/gameStart", map); JSONObject jsonObject = JSONObject.parseObject(s); Object code = jsonObject.get("code"); if (String.valueOf(code) != null && "200".equals(String.valueOf(code))) { @@ -477,12 +564,15 @@ public ResultUtil<Map<String, Object>> queryMySiteById(Integer id) { try { HashMap<String, Object> map = new HashMap<>(); - SiteBooking byId = siteBookingService.getById(id); - Integer storeId = byId.getStoreId(); + System.err.println("预约id"+id); + SiteBooking siteBooking = siteBookingService.getById(id); + System.err.println("预约"+siteBooking); + Integer storeId = siteBooking.getStoreId(); Store byId1 = service.getById(storeId); - Site site = siteService.getById(byId.getSiteId()); + Site site = siteService.getById(siteBooking.getSiteId()); map.put("siteName", byId1.getName()); SiteType siteType = siteTypeService.getById(site.getSiteTypeId()); + System.err.println("预约类型"+siteType); map.put("siteType", siteType.getName()); map.put("shopName", byId1.getName()); map.put("shopAddress", byId1.getAddress()); @@ -490,29 +580,32 @@ map.put("name", site.getName()); - List<Integer> ids = getIds(byId.getSiteId()); - byId.setStorePhone(byId1.getPhone()); + List<Integer> ids = getIds(siteBooking.getSiteId()); + siteBooking.setStorePhone(byId1.getPhone()); //拼接开始结束时间 - Date startTime = byId.getStartTime(); - Date endTime = byId.getEndTime(); + Date startTime = siteBooking.getStartTime(); + Date endTime = siteBooking.getEndTime(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); String startTimeString = sdf.format(startTime); String endTimeString = sdf.format(endTime); String result = startTimeString + "-" + endTimeString.substring(11); - byId.setTimes(result); + siteBooking.setTimes(result); - byId.setSid(Arrays.asList(storeId)); -// List<Site> list = siteService.list(new LambdaQueryWrapper<Site>() -// .eq(Site::getStoreId, storeId) -// .eq(Site::getSign, 1)); -// List<Integer> collect = list.stream().map(Site::getId).collect(Collectors.toList()); - Integer siteId = byId.getSiteId(); + siteBooking.setSid(Arrays.asList(storeId)); + Integer siteId = siteBooking.getSiteId(); ArrayList<Integer> list1 = new ArrayList<>(); list1.add(siteId); - byId.setRid(list1); - map.put("data", byId); + siteBooking.setRid(list1); + SiteBookingVo siteBookingVo = new SiteBookingVo(); + BeanUtils.copyProperties(siteBooking, siteBookingVo); + siteBookingVo.setStartTime(siteBooking.getStartTime().getTime()); + siteBookingVo.setEndTime(siteBooking.getEndTime().getTime()); + if (siteBooking.getPayTime()!=null){ + siteBookingVo.setPayTime(siteBooking.getPayTime().getTime()); + } + map.put("data", siteBookingVo); map.put("ids", ids); return ResultUtil.success(map); } catch (Exception e) { @@ -522,7 +615,7 @@ } public List<Integer> getIds(Integer siteId) { - HttpRequest httpRequest = HttpRequest.get("https://try.daowepark.com/v7/user_api/general/get_space_area?space_id=" + siteId); + HttpRequest httpRequest = HttpRequest.get("https://port.daowepark.com/v7/user_api/general/get_space_area?space_id=" + siteId); HttpResponse execute = httpRequest.execute(); String body = execute.body(); JSONObject jsonObject = JSONObject.parseObject(body); @@ -553,8 +646,6 @@ if (null == uid) { return ResultUtil.tokenErr(); } - - return siteService.cancelMySite(uid, id); } catch (Exception e) { e.printStackTrace(); @@ -686,10 +777,6 @@ @Autowired private StoreService service; - - @Autowired - private IOperatorUserService operatorUserService; - @ResponseBody @PostMapping("/base/site/game") -- Gitblit v1.7.1