puzhibing
2023-10-30 d4c3427bbd111f4a005c77a9cc1f131b455fc6cf
ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java
@@ -1229,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());
                //生成自动取消订单延时任务
@@ -1507,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();
@@ -2061,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();
@@ -2079,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) {
@@ -2096,15 +2100,21 @@
                            //分账对象
                            JSONArray acctInfos = new JSONArray();
                            JSONObject jsonObject = new JSONObject();
                            jsonObject.put("div_amt", String.format("%.2f", 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", String.format("%.2f", pt_amount));
                            jsonObject1.put("huifu_id", "6666000141216769");
                            acctInfos.add(jsonObject1);
                            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());