luodangjia
2025-01-15 257d66798aa538f8737980f13d94c547bf0b51ea
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
@@ -6,10 +6,7 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.account.api.feignClient.BalanceChangeRecordClient;
import com.ruoyi.account.api.feignClient.UserCouponClient;
import com.ruoyi.account.api.feignClient.UserPointClient;
import com.ruoyi.account.api.feignClient.*;
import com.ruoyi.account.api.model.*;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.exception.ServiceException;
@@ -30,6 +27,7 @@
import com.ruoyi.order.util.payment.model.RefundCallbackResult;
import com.ruoyi.order.util.payment.model.RefundResult;
import com.ruoyi.order.util.vo.MapTrackKD100Vo;
import com.ruoyi.order.util.vo.QueryKD100ListVo;
import com.ruoyi.order.util.vo.QueryKD100Vo;
import com.ruoyi.order.vo.*;
import com.ruoyi.other.api.domain.*;
@@ -88,9 +86,6 @@
    private UserPointClient userPointClient;
    
    @Resource
    private PointSettingClient pointSettingClient;
    @Resource
    private OrderBalancePaymentService orderBalancePaymentService;
    
    @Resource
@@ -114,6 +109,9 @@
    @Resource
    private UserCouponClient userCouponClient;
    @Resource
    private UserChangeLogClient userChangeLogClient;
    
    
@@ -201,6 +199,12 @@
        orderDetailVO.setLongitude(shop.getLongitude());
        orderDetailVO.setLatitude(shop.getLatitude());
        orderDetailVO.setShopId(shop.getId());
        if(StringUtils.isNotEmpty(order.getExpressResult())){
            MapTrackKD100Vo mapTrackKD100Vo = JSON.parseObject(order.getExpressResult(), MapTrackKD100Vo.class);
            List<QueryKD100ListVo> data = mapTrackKD100Vo.getData();
            orderDetailVO.setExpress(null != data && data.size() > 0 ? data.get(0).getContext() : "");
        }
        if(order.getOrderType() == 1){
            List<TechnicianSubscribe> data = technicianSubscribeClient.getTechnicianSubscribeList(order.getId()).getData();
            if(data.size() > 0){
@@ -251,12 +255,12 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void writeOff(String id,Integer shopId, Integer technicianId) {
    public void writeOff(String id, Integer shopId, String technicianId) {
        LoginUser loginUserApplet = tokenService.getLoginUserApplet();
        Order order = orderMapper.selectById(id);
        boolean check = check(order, shopId, loginUserApplet.getUserid());
        if (!check){
            throw new ServiceException("订单不存在");
            throw new ServiceException("该订单与当前扫码门店不一致");
        }
        // 售后设置
@@ -276,7 +280,9 @@
        order.setAfterSaleTime(LocalDateTime.now().plusDays(days));
        order.setEndTime(LocalDateTime.now());
        order.setCancellerAppUserId(loginUserApplet.getUserid());
        order.setTechnicianId(technicianId);
        if(StringUtils.isNotEmpty(technicianId) && !"null".equals(technicianId)){
            order.setTechnicianId(Integer.valueOf(technicianId));
        }
        orderMapper.updateById(order);
    }
    
@@ -328,10 +334,13 @@
                orderPageListVo.setUserName(appUser.getName());
                orderPageListVo.setPhone(appUser.getPhone());
            }
//            RefundPass one = refundPassService.getOne(new LambdaQueryWrapper<RefundPass>().eq(RefundPass::getOrderId, orderPageListVo.getId()).eq(RefundPass::getDelFlag, 0).last(" order by create_time desc limit 0,1"));
            RefundPass one = refundPassService.lambdaQuery().eq(RefundPass::getOrderId, orderPageListVo.getId()).one();
            RefundPass one = refundPassService.getOne(new LambdaQueryWrapper<RefundPass>().eq(RefundPass::getOrderId, orderPageListVo.getId()).eq(RefundPass::getDelFlag, 0).last(" order by create_time desc limit 0,1"));
            orderPageListVo.setRefundPassId(null != one ? one.getId().toString() : null);
            // 平台分佣
            List<ShopBalanceStatement> data = shopBalanceStatementClient.getShopBalanceStatementList(Arrays.asList(1, 2, 3), Long.valueOf(orderPageListVo.getId())).getData();
            BigDecimal reduce = data.stream().map(ShopBalanceStatement::getVariableAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
            orderPageListVo.setGetCommission(reduce);
        }
        return pageInfo.setRecords(list);
    }
@@ -421,7 +430,7 @@
        if(Arrays.asList(5, 6, 7).contains(order.getOrderStatus())){
            return R.fail("无效的操作");
        }
        if(LocalDateTime.now().isAfter(order.getAfterSaleTime())){
        if(null != order.getAfterSaleTime() && LocalDateTime.now().isAfter(order.getAfterSaleTime())){
            return R.fail("订单取消失败");
        }
        order.setOrderStatus(5);
@@ -506,11 +515,6 @@
            }
            appUser.setTotalPoint(appUser.getTotalPoint() - shopPoint);
            boolean vipDemotion = vipDemotion(appUser.getShopPoint(), appUser.getVipId());
            if(vipDemotion){
                appUser.setVipId(appUser.getVipId() - 1);
            }
            //构建积分流水明细
            UserPoint userPoint = new UserPoint();
            userPoint.setType(1);
@@ -522,6 +526,12 @@
            userPoint.setObjectId(order.getId());
            userPointClient.saveUserPoint(userPoint);
            appUserClient.editAppUserById(appUser);
            //降级检测
            boolean vipDemotion = vipDemotion(appUser.getShopPoint(), appUser.getVipId());
            if(vipDemotion){
                appUserClient.vipDemotion(appUser.getId());
            }
            //回退优惠券状态
            if(null != order.getUserCouponId()){
                UserCoupon userCoupon = userCouponClient.getUserCoupon(order.getUserCouponId()).getData();
@@ -592,6 +602,7 @@
            userPoint.setAppUserId(order.getAppUserId());
            userPoint.setObjectId(order.getId());
            userPointClient.saveUserPoint(userPoint);
            appUserClient.editAppUserById(appUser);
        }
        order.setRefundStatus(2);
@@ -637,11 +648,6 @@
        }
        appUser.setTotalPoint(appUser.getTotalPoint() - shopPoint);
        boolean vipDemotion = vipDemotion(appUser.getShopPoint(), appUser.getVipId());
        if(vipDemotion){
            appUser.setVipId(appUser.getVipId() - 1);
        }
        //构建积分流水明细
        UserPoint userPoint = new UserPoint();
        userPoint.setType(1);
@@ -653,6 +659,12 @@
        userPoint.setObjectId(order.getId());
        userPointClient.saveUserPoint(userPoint);
        appUserClient.editAppUserById(appUser);
        //降级检测
        boolean vipDemotion = vipDemotion(appUser.getShopPoint(), appUser.getVipId());
        if(vipDemotion){
            appUserClient.vipDemotion(appUser.getId());
        }
        //回退优惠券状态
        if(null != order.getUserCouponId()){
@@ -840,8 +852,8 @@
     * @return
     */
    @Override
    public Integer getGoodsSaleNum(Integer goodsId, Integer type) {
        return this.baseMapper.getGoodsSaleNum(goodsId, type);
    public Integer getGoodsSaleNum(Integer goodsId, Integer type, Long userId) {
        return this.baseMapper.getGoodsSaleNum(goodsId, type, userId);
    }