puzhibing
2025-01-13 acccff9860b271d55c55dc87486f7c20b9896e6c
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/RefundPassServiceImpl.java
@@ -4,11 +4,13 @@
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kuaidi100.sdk.contant.CompanyConstant;
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.account.api.model.AppUser;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.bean.BeanUtils;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.order.mapper.RefundPassMapper;
import com.ruoyi.order.model.Order;
@@ -75,7 +77,7 @@
      Order order = orderService.getById(applyRefundPass.getId());
      //判断是都已经超过售后时间
      LocalDateTime afterSaleTime = order.getAfterSaleTime();
      if(null != afterSaleTime && afterSaleTime.toEpochSecond(ZoneOffset.UTC) < LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)){
      if(null != afterSaleTime && LocalDateTime.now().isAfter(afterSaleTime)){
         return R.fail("已超过售后期间");
      }
      
@@ -107,7 +109,7 @@
    * @return
    */
   @Override
   public List<OrderRefundPassList> getOrderRefundPassList(OrderRefundPassListVo refundPassListVo) {
   public PageInfo<OrderRefundPassList> getOrderRefundPassList(OrderRefundPassListVo refundPassListVo) {
      Long userid = tokenService.getLoginUser().getUserid();
      SysUser sysUser = sysUserClient.getSysUser(userid).getData();
      Integer shopId = null;
@@ -127,13 +129,16 @@
         List<Long> collect = data.stream().map(AppUser::getId).collect(Collectors.toList());
         appUserIds.addAll(collect);
      }
      List<OrderRefundPassList> orderRefundPassList = this.baseMapper.getOrderRefundPassList(refundPassListVo.getCode(), appUserIds, shopId, refundPassListVo.getRefundMethod(), refundPassListVo.getStatus());
      PageInfo<OrderRefundPassList> pageInfo = new PageInfo(refundPassListVo.getPageCurr(), refundPassListVo.getPageSize());
      List<OrderRefundPassList> orderRefundPassList = this.baseMapper.getOrderRefundPassList(pageInfo, refundPassListVo.getCode(), appUserIds, shopId, refundPassListVo.getRefundMethod(), refundPassListVo.getStatus());
      for (OrderRefundPassList refundPassList : orderRefundPassList) {
         AppUser appUser = appUserClient.getAppUserById(refundPassList.getAppUserId());
         refundPassList.setUserName(appUser.getName());
         refundPassList.setPhone(appUser.getPhone());
         if(null != appUser){
            refundPassList.setUserName(appUser.getName());
            refundPassList.setPhone(appUser.getPhone());
         }
      }
      return orderRefundPassList;
      return pageInfo.setRecords(orderRefundPassList);
   }
   
   
@@ -151,6 +156,7 @@
         return R.fail("不能重复操作");
      }
      refundPass.setPassStatus(status);
      refundPass.setAuthTime(LocalDateTime.now());
      //退货退款
      if(refundPass.getRefundMethod() == 1 && 2 == status){
         refundPass.setStatus(4);
@@ -158,16 +164,22 @@
      if(refundPass.getRefundMethod() == 2 && 2 == status){
         refundPass.setStatus(2);
      }
      if(3 == status){
         refundPass.setStatus(3);
      }
      refundPass.setPassRemark(passRemark);
      this.updateById(refundPass);
      //仅退款的售后需要将支付金额原路返回,然后再扣减支付获得的积分
      if(refundPass.getRefundMethod() == 2 && 2 == status){
         Order order = orderService.getById(refundPass.getOrderId());
         order.setOrderStatus(6);
         orderService.updateById(order);
         //返回订单支付金额和回退积分和会员等级
         orderService.refundPayMoney(order);
         R r = orderService.refundPayMoney(order);
         if(200 != r.getCode()){
            return r;
         }
         orderService.updateById(order);
      }
      this.updateById(refundPass);
      return R.ok();
   }
   
@@ -187,13 +199,16 @@
         return R.fail("操作失败");
      }
      refundPass.setStatus(2);
      this.updateById(refundPass);
      //仅退款的售后需要将支付金额原路返回,然后再扣减支付获得的积分
      Order order = orderService.getById(refundPass.getOrderId());
      order.setOrderStatus(6);
      orderService.updateById(order);
      //返回订单支付金额和回退积分和会员等级
      orderService.refundPayMoney(order);
      R r = orderService.refundPayMoney(order);
      if(200 != r.getCode()){
         return r;
      }
      this.updateById(refundPass);
      orderService.updateById(order);
      return R.ok();
   }
   
@@ -217,6 +232,16 @@
      refundPassInfo.setRefundReason(refundPass.getRefundReason());
      refundPassInfo.setUserRemark(refundPass.getUserRemark());
      refundPassInfo.setPics(refundPass.getPics());
      refundPassInfo.setPassStatus(refundPass.getPassStatus());
      refundPassInfo.setPassRemark(refundPass.getPassRemark());
      refundPassInfo.setStatus(refundPass.getStatus());
      String code = refundPass.getCode();
      if(StringUtils.isNotEmpty(code)){
         JSONObject jsonObject = JSON.parseObject(code);
         refundPassInfo.setExpressCode(jsonObject.getString("num"));
         String com = jsonObject.getString("com");
         refundPassInfo.setExpressName(com);
      }
      return refundPassInfo;
   }
}