puzhibing
2024-12-26 e93aad02d2dd2a6e624e81ea0adb3611a8fc43e5
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
@@ -12,6 +12,7 @@
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.order.enums.OrderStatus;
import com.ruoyi.order.mapper.OrderGoodMapper;
@@ -129,9 +130,6 @@
            orderGoodsVO.setOriginalPrice(goods.getOriginalPrice());
            goodsList.add(orderGoodsVO);
        }
        // 收货地址
        String addressJson = order.getAddressJson();
        UserAddress userAddress = new UserAddress();
@@ -139,7 +137,6 @@
            userAddress = JSONObject.parseObject(addressJson, UserAddress.class);
        }
        // 优惠券
        String couponJson = order.getCouponJson();
        CouponInfo couponInfo = new CouponInfo();
@@ -153,7 +150,6 @@
        if (StringUtils.isNotEmpty(activityJson)){
            orderActivityInfo = JSONObject.parseObject(activityJson, OrderActivityInfo.class);
        }
        OrderDetailVO orderDetailVO = new OrderDetailVO();
        if (CollectionUtil.isNotEmpty(orderGoods)){
@@ -234,8 +230,6 @@
        if (!check){
            throw new ServiceException("订单不存在");
        }
        order.setOrderStatus(OrderStatus.COMPLETED.getCode());
        orderMapper.updateById(order);
        Integer orderType = order.getOrderType();
        // 售后设置
@@ -250,9 +244,10 @@
        String content = baseSetting.getContent();
        JSONObject jsonObject = JSONObject.parseObject(content);
        Long days = jsonObject.getLong("days");
        if (days != null && days > 0){
            commissionService.addToCommissionDelayQueue(order.getId(), LocalDateTime.now().plusDays(days));
        }
        order.setOrderStatus(OrderStatus.COMPLETED.getCode());
        order.setIsCommission(0);
        order.setAfterSaleTime(LocalDateTime.now().plusDays(days));
        orderMapper.updateById(order);
    }
    
    
@@ -262,7 +257,7 @@
     * @return
     */
    @Override
    public List<OrderPageListVo> getOrderPageList(OrderPageList orderPageList) {
    public PageInfo<OrderPageListVo> getOrderPageList(OrderPageList orderPageList) {
        Long userid = tokenService.getLoginUser().getUserid();
        SysUser sysUser = sysUserClient.getSysUser(userid).getData();
        if(2 == sysUser.getRoleType()){
@@ -293,14 +288,16 @@
            }
        }
        
        List<OrderPageListVo> list = this.baseMapper.getOrderPageList(orderPageList);
        PageInfo<OrderPageListVo> pageInfo = new PageInfo(orderPageList.getPageCurr(), orderPageList.getPageSize());
        List<OrderPageListVo> list = this.baseMapper.getOrderPageList(pageInfo, orderPageList);
        for (OrderPageListVo orderPageListVo : list) {
            Long appUserId = orderPageListVo.getAppUserId();
            AppUser appUser = appUserClient.getAppUserById(appUserId);
            orderPageListVo.setUserName(appUser.getName());
            orderPageListVo.setPhone(appUser.getPhone());
        }
        return list;
        return pageInfo.setRecords(list);
    }
    
    
@@ -311,7 +308,7 @@
     * @return
     */
    @Override
    public R confirmDelivery(String orderId, String code) {
    public R confirmDelivery(Long orderId, String code) {
        Order order = this.getById(orderId);
        if(1 == order.getPayStatus()){
            return R.fail("订单还未完成支付");
@@ -364,8 +361,10 @@
            //余额退款
            OrderBalancePayment orderBalancePayment = orderBalancePaymentService.getOne(new LambdaQueryWrapper<OrderBalancePayment>().eq(OrderBalancePayment::getOrderId, order.getId()));
            BigDecimal balance = appUser.getBalance();
            appUser.setTotalRedPacketAmount(appUser.getTotalRedPacketAmount().add(orderBalancePayment.getRedPacketAmount()).setScale(2, RoundingMode.HALF_EVEN));
            appUser.setTotalDistributionAmount(appUser.getTotalDistributionAmount().add(orderBalancePayment.getDistributionAmount()).setScale(2, RoundingMode.HALF_EVEN));
            if(null != orderBalancePayment){
                appUser.setTotalRedPacketAmount(appUser.getTotalRedPacketAmount().add(orderBalancePayment.getRedPacketAmount()).setScale(2, RoundingMode.HALF_EVEN));
                appUser.setTotalDistributionAmount(appUser.getTotalDistributionAmount().add(orderBalancePayment.getDistributionAmount()).setScale(2, RoundingMode.HALF_EVEN));
            }
            appUser.setBalance(balance.add(paymentAmount).setScale(2, RoundingMode.HALF_EVEN));
            appUser.setShopAmount(appUser.getShopAmount().subtract(paymentAmount).setScale(2, RoundingMode.HALF_EVEN));
        
@@ -454,10 +453,7 @@
        VipSetting vipSetting = vipSettingClient.getVipSetting(vipId).getData();
        Integer vipLevelUpShopRole = vipSetting.getVipLevelUpShopRole();
        Integer vipLevelUpShop = vipSetting.getVipLevelUpShop();
        if(1 == vipLevelUpShopRole && shopPoint < vipLevelUpShop){
            return true;
        }
        return false;
        return 1 == vipLevelUpShopRole && shopPoint < vipLevelUpShop;
    }