| | |
| | | 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; |
| | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 通过运营商id查询运营商对应的支付宝商户号 |
| | | */ |
| | |
| | | /** |
| | | * 通过运营商id查询运营商对应的微信商户号 |
| | | */ |
| | | @RequestMapping("/base/getmerchantNumberByOperatorId") |
| | | @RequestMapping("/base/getmerchantNumberByOperatorId/{id}") |
| | | @ResponseBody |
| | | public String getmerchantNumberByOperatorId(Integer id) { |
| | | public String getmerchantNumberByOperatorId(@PathVariable("id")Integer id) { |
| | | return siteService.getmerchantNumberByOperatorId(id); |
| | | } |
| | | /** |
| | | * 根据运营商id获取对应运营商分账比例 返回格式: 微信分账比例,支付宝分账比例 |
| | | */ |
| | | @RequestMapping("/base/getProportionByOperatorId") |
| | | @RequestMapping("/base/getProportionByOperatorId/{id}") |
| | | @ResponseBody |
| | | public String getProportionByOperatorId(Integer id) { |
| | | public String getProportionByOperatorId(@PathVariable("id")Integer id) { |
| | | OperatorUser operatorId = operatorUserService.getOne( |
| | | new QueryWrapper<OperatorUser>().eq("operatorId",id) |
| | | ); |
| | |
| | | if (operatorId.getAlipayProportion() == null){ |
| | | operatorId.setAlipayProportion("0"); |
| | | } |
| | | System.err.println("查询分账比例"+operatorId); |
| | | return operatorId.getWechatProportion()+","+operatorId.getAlipayProportion(); |
| | | } |
| | | /** |
| | |
| | | @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"); |
| | |
| | | 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(); |
| | | } |
| | | |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | public ResultUtil<Map<String, Object>> queryMySiteById(Integer id) { |
| | | try { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | 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(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()); |
| | |
| | | BeanUtils.copyProperties(siteBooking, siteBookingVo); |
| | | siteBookingVo.setStartTime(siteBooking.getStartTime().getTime()); |
| | | siteBookingVo.setEndTime(siteBooking.getEndTime().getTime()); |
| | | siteBookingVo.setPayTime(siteBooking.getPayTime().getTime()); |
| | | if (siteBooking.getPayTime()!=null){ |
| | | siteBookingVo.setPayTime(siteBooking.getPayTime().getTime()); |
| | | } |
| | | map.put("data", siteBookingVo); |
| | | map.put("ids", ids); |
| | | return ResultUtil.success(map); |