From d4c3427bbd111f4a005c77a9cc1f131b455fc6cf Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期一, 30 十月 2023 11:30:40 +0800 Subject: [PATCH] 新增加腾讯地图工具类 --- ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java | 69 +++++++++++++++++++++------------- 1 files changed, 43 insertions(+), 26 deletions(-) diff --git a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java index 1fc14f8..8eaf64d 100644 --- a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java +++ b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java @@ -952,6 +952,9 @@ request.setNotifyUrl(callbackPath + "/order/app/notify/wechatPaymentCallback"); R<com.alibaba.fastjson.JSONObject> r = HuiFuTianXiaUtil.weixinPayment(outTradeNo, description, payMoney.doubleValue(), openid, request.getNotifyUrl()); + if(r.getCode() != 200){ + throw new ServiceException(r.getMsg()); + } com.alibaba.fastjson.JSONObject data = r.getData(); String mainMchId = WxPayConfiguration.getPlatformTyMacId(); // 支付相关信息返回 @@ -1226,7 +1229,12 @@ } appPlaceOrderVo.setEndTime(DateUtils.addMinutes(order.getCreateTime(), delayTime)); // 小程序微信下单支付 - createWxPayInfo(appPlaceOrderVo, userId, order.getShopId(), orderGoods.getGoodsName(), outTradeNo, +// createWxPayInfo(appPlaceOrderVo, userId, order.getShopId(), orderGoods.getGoodsName(), outTradeNo, +// orderId, order.getPayMoney(), appPlaceActivityDto.getOpenid(), +// appPlaceActivityDto.getSpbillCreateIp()); + + // 小程序微信下单支付 TODO 更换支付渠道(汇付天下) + createWxPayInfo1(appPlaceOrderVo, userId, order.getShopId(), orderGoods.getGoodsName(), outTradeNo, orderId, order.getPayMoney(), appPlaceActivityDto.getOpenid(), appPlaceActivityDto.getSpbillCreateIp()); //生成自动取消订单延时任务 @@ -1504,11 +1512,6 @@ Order order = this.getById(orderId); if (order.getOrderStatus() != 2) { throw new ServiceException(AppErrorConstant.VERIFY_USED); - } - //判断商户是否有分账权限 - Shop shop = remoteShopService.getShop(shopId).getData(); - if(shop.getAccountFlag()!=1){ - throw new ServiceException(AppErrorConstant.SHOP_NO_VERIFY); } // 根据订单用户ID获取用户信息 Member member = remoteMemberService.getMember(order.getUserId()).getData(); @@ -2043,6 +2046,8 @@ OrderPayment payment = orderPaymentService.getByOrderId(orderId); String transactionId = payment.getTransactionId(); String outTradeNo = payment.getOutTradeNo(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); + String org_req_date = sdf.format(payment.getCreateTime()); R<ShopAuthenticationHftxVo> resultMch = remoteShopService.getShopHFTXSubMchId(shopId); ShopAuthenticationHftxVo vo = resultMch.getData(); if (StringUtils.isEmpty(vo.getHuifuId())) { @@ -2056,7 +2061,11 @@ BigDecimal proportionPercent = null; //商户订单获取统一分成 活动订单获取活动分成 if(orderFrom==1){ - proportionPercent = new BigDecimal(vo.getShareRatio()); + if(null == vo.getShareRatio()){ + proportionPercent = new BigDecimal(redisService.getCacheObject(SecurityConstant.SHOP_COMMON_PROPORTION).toString()); + }else{ + proportionPercent = new BigDecimal(vo.getShareRatio()); + } }else{ R<ShopProportionVo> resultShopProportion = remoteShopService.getShopProportion(shopId); shopProportion = resultShopProportion.getData(); @@ -2074,7 +2083,7 @@ if(proportionPercent.compareTo(BigDecimal.ZERO)>0){ PaymentDelaytransHFTXVo result = new PaymentDelaytransHFTXVo(); // 计算分成金额 - int amount = orderMoney.multiply(proportionPercent).setScale(0, RoundingMode.UP).intValue(); + int amount = orderMoney.multiply(new BigDecimal(100)).setScale(0, RoundingMode.HALF_EVEN).intValue(); BigDecimal multiply = orderMoney.multiply(proportionPercent.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_EVEN); log.info("订单分账:{} 分账金额: {}", orderNo, amount); if (amount > 0) { @@ -2089,20 +2098,24 @@ // 分账完成 request.setFinish(true); - NumberFormat numberFormat = NumberFormat.getInstance(); - numberFormat.setMaximumFractionDigits(2); //分账对象 JSONArray acctInfos = new JSONArray(); - JSONObject jsonObject = new JSONObject(); - jsonObject.put("div_amt", numberFormat.format(multiply.doubleValue())); - jsonObject.put("huifu_id", vo.getHuifuId()); + if(multiply.compareTo(BigDecimal.ZERO) > 0){ + JSONObject jsonObject = new JSONObject(); + jsonObject.put("div_amt", String.format("%.2f", multiply.doubleValue())); + jsonObject.put("huifu_id", vo.getHuifuId()); + acctInfos.add(jsonObject); + } //平台商户 - double pt_amount = orderMoney.subtract(multiply).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); - JSONObject jsonObject1 = new JSONObject(); - jsonObject1.put("div_amt", numberFormat.format(pt_amount)); - jsonObject1.put("huifu_id", HuiFuTianXiaUtil.huifu_id); - acctInfos.add(jsonObject1); - R<PaymentDelaytransHFTXVo> hftxVoR = HuiFuTianXiaUtil.paymentDelaytrans(request.getOutOrderNo(), outTradeNo, acctInfos); + BigDecimal pt_amount = orderMoney.subtract(multiply).setScale(2, RoundingMode.HALF_EVEN); + if(pt_amount.compareTo(BigDecimal.ZERO) > 0){ + JSONObject jsonObject1 = new JSONObject(); + jsonObject1.put("div_amt", String.format("%.2f", pt_amount.doubleValue())); + jsonObject1.put("huifu_id", "6666000141216769"); + acctInfos.add(jsonObject1); + } + + R<PaymentDelaytransHFTXVo> hftxVoR = HuiFuTianXiaUtil.paymentDelaytrans(request.getOutOrderNo(), org_req_date, outTradeNo, acctInfos); if(hftxVoR.getCode() != 200){ throw new ServiceException(hftxVoR.getMsg()); } @@ -2123,6 +2136,7 @@ log.info(resultMessage); } } catch (Exception e) { + e.printStackTrace(); resultMessage = String.format("订单分账:%s 分账失败:%s", orderNo, e.getMessage()); log.info(resultMessage); throw new ServiceException(resultMessage); @@ -5114,6 +5128,9 @@ // 更新订单状态 outTradeNo String outTradeNo = transaction.getOutTradeNo(); Order order = this.getByOutTradeNo(outTradeNo); + if(order.getOrderStatus() != 1){ + return; + } String orderId = order.getOrderId(); order.setOrderStatus(2); order.setPayTime(new Date()); @@ -5522,10 +5539,10 @@ log.info("调用微信退款---发起退款"); String subMchId = orderPayment.getSubMchId(); - WxPayConfig config = wxService.getConfig(); +// WxPayConfig config = wxService.getConfig(); RefundsRequest request = new RefundsRequest(); - request.setSpAppid(config.getAppId()); +// request.setSpAppid(config.getAppId()); request.setSubMchid(subMchId); request.setTransactionId(orderPayment.getTransactionId()); request.setOutRefundNo(outRefundNo); @@ -5537,7 +5554,7 @@ request.setAmount(amount); request.setNotifyUrl(callbackPath + "/order/app/notify/wechatPaymentRefundCallback"); - RefundsResult result = wxService.getEcommerceService().refunds(request); +// RefundsResult result = wxService.getEcommerceService().refunds(request); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); String org_req_date = sdf.format(orderPayment.getCreateTime()); @@ -5554,14 +5571,14 @@ Gson gson = new Gson(); String refundRequestJson = gson.toJson(request); // 返回参数 - String refundResponseJson = gson.toJson(result); +// String refundResponseJson = gson.toJson(result); - log.info("调用微信退款返回参数---{}", refundResponseJson); +// log.info("调用微信退款返回参数---{}", refundResponseJson); // 保存支付订单统一下单日志 - paymentMessageService.savePaymentMessage("3", orderId, refundRequestJson, refundResponseJson); +// paymentMessageService.savePaymentMessage("3", orderId, refundRequestJson, refundResponseJson); - } catch (WxPayException e) { + } catch (Exception e) { throw new ServiceException(e.getMessage()); } } -- Gitblit v1.7.1