rk
2 天以前 7a38456f48d541d737fb46d19f49484b67a806d0
server/dmmall_service/src/main/java/com/doumee/service/business/impl/GoodsorderServiceImpl.java
@@ -1586,7 +1586,8 @@
                integralBack = payAmount.divide(platformConfigDTO.getReturnShopIntegral(),2,BigDecimal.ROUND_DOWN);
            }
        }
        return integralBack;
        //积分获取向下取整
        return integralBack.setScale(0, BigDecimal.ROUND_DOWN);
    }
@@ -1642,8 +1643,9 @@
        }
        //剩余积分值
        orderPayConfirmResponse.setSurplusIntegral(totalIntegral);
        //实际抵扣使用积分
        orderPayConfirmResponse.setDeductIntegral(totalIntegral.compareTo(maxDeductionIntegral)<=Constants.ZERO?totalIntegral:maxDeductionIntegral);
        //实际抵扣使用积分(向上取整)
        BigDecimal deductIntegralValue = totalIntegral.compareTo(maxDeductionIntegral)<=Constants.ZERO?totalIntegral:maxDeductionIntegral;
        orderPayConfirmResponse.setDeductIntegral(deductIntegralValue.setScale(0, BigDecimal.ROUND_UP));
        return realDeductionCash;
    }
@@ -2141,9 +2143,6 @@
        }
        //加入redis缓存,刷新今天售后编号0开始
        RedisUtil.addObject(redisTemplate,Constants.RedisKeys.WITHDRAW_KEY,countWithdraw);
    }
@@ -2378,9 +2377,60 @@
                this.cancel(goodsorder,null,"订单未支付超时自动取消");
            }
        }
    }
    /**
     * 自动完成 7 天未确认收货的物流发货订单
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void autoCompleteOrder(){
        //查询发货后 7 天未确认收货的订单数据(仅处理快递配送订单)
        List<Goodsorder> goodsOrderList = goodsorderMapper.selectList(
                new QueryWrapper<Goodsorder>()
                        .eq("STATUS", Constants.OrderStatus.WAIT_RECEIVE.getKey())
                        .eq("RECEIVE_TYPE", Constants.ZERO)  // 仅处理快递配送订单
                        .isNotNull("KD_CODE")  // 有物流单号
                        .ne("KD_CODE", "")  // 物流单号不为空
                        .apply(" KD_DATE IS NOT NULL ")  // 有发货时间
                        .apply(" NOW() >= DATE_SUB(KD_DATE, INTERVAL -7 DAY) ")  // 发货后 7 天
        );
        if (!goodsOrderList.isEmpty()) {
            for (Goodsorder order : goodsOrderList) {
                try {
                    Goodsorder updateOrder = new Goodsorder();
                    updateOrder.setId(order.getId());
                    updateOrder.setStatus(Constants.OrderStatus.DONE.getKey());
                    updateOrder.setDoneDate(new Date());
                    updateOrder.setDoneInfo("发货 7 天后系统自动确认收货");
                    goodsorderMapper.updateById(updateOrder);
                    //存在现金支付 赠送 积分
                    if(Constants.equalsInteger(updateOrder.getPayMethod(),Constants.ZERO)){
                        //赠送消费者积分
                        this.orderAddMemberIntegral(order);
                        //下单完成 根据信息确认是否需要赠送邀请者优惠券
                        this.orderDoneRewardInviteCoupon(order);
                        //经销商 添加赠送积分
                        this.orderAddShopIntegral(order);
                        //经销商 结算金额
                        this.orderAddShopCash(order);
                    }
                    System.out.println("订单自动完成:订单 ID=" + order.getId() + ", 订单编号=" + order.getCode());
                } catch (Exception e) {
                    System.out.println("订单自动完成失败:订单 ID=" + order.getId() + ", 错误:" + e.getMessage());
                }
            }
        }
    }
}