From 67d06a785d5fc4524639ace27651c01ff05a4b58 Mon Sep 17 00:00:00 2001 From: liujie <1793218484@qq.com> Date: 星期四, 29 五月 2025 22:31:33 +0800 Subject: [PATCH] 修改bug --- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TExchangeOrderServiceImpl.java | 121 ++++++++++++++++++++++++++++++++------- 1 files changed, 98 insertions(+), 23 deletions(-) diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TExchangeOrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TExchangeOrderServiceImpl.java index ab3b9ba..7b112a6 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TExchangeOrderServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TExchangeOrderServiceImpl.java @@ -3,9 +3,17 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.account.api.feignClient.AppUserAddressClient; +import com.ruoyi.account.api.feignClient.AppUserClient; +import com.ruoyi.account.api.feignClient.AppUserIntegralChangeClient; +import com.ruoyi.account.api.model.TAppUser; import com.ruoyi.account.api.model.TAppUserAddress; +import com.ruoyi.account.api.model.TAppUserIntegralChange; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.order.api.model.TExchangeOrder; +import com.ruoyi.order.api.model.TShoppingOrder; +import com.ruoyi.order.api.query.ShoppingOrderQuery; import com.ruoyi.order.dto.ExchangeOrderGoodsInfo; import com.ruoyi.order.dto.GetMyExchangeOrder; import com.ruoyi.order.dto.MyExchangeOrderList; @@ -17,11 +25,14 @@ import com.ruoyi.other.api.feignClient.GoodsClient; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; import javax.annotation.Resource; import java.time.format.DateTimeFormatter; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * <p> @@ -45,8 +56,12 @@ @Resource private AppUserAddressClient appUserAddressClient; + + @Resource + private AppUserClient appUserClient; - + @Resource + private AppUserIntegralChangeClient appUserIntegralChangeClient; @@ -57,7 +72,7 @@ * @return */ @Override - public List<MyExchangeOrderList> getMyExchangeOrder(GetMyExchangeOrder query) { + public Map<String, Object> getMyExchangeOrder(GetMyExchangeOrder query) { Long userid = tokenService.getLoginUserApplet().getUserId(); LambdaQueryWrapper<TExchangeOrder> wrapper = new LambdaQueryWrapper<TExchangeOrder>().eq(TExchangeOrder::getDelFlag, 0).eq(TExchangeOrder::getAppUserId, userid); if(query.getStatus() == 0){ @@ -65,7 +80,9 @@ }else{ wrapper.eq(TExchangeOrder::getStatus, query.getStatus()); } - List<TExchangeOrder> list = this.list(wrapper.orderByDesc(TExchangeOrder::getCreateTime).last(" limit " + query.getPageCurr() + "," + query.getPageSize())); + long count = this.count(wrapper); + Integer pageCurr = (query.getPageCurr() - 1) * query.getPageSize(); + List<TExchangeOrder> list = this.list(wrapper.orderByDesc(TExchangeOrder::getCreateTime).last(" limit " + pageCurr + "," + query.getPageSize())); List<MyExchangeOrderList> pageList = new ArrayList<>(); for (TExchangeOrder tExchangeOrder : list) { MyExchangeOrderList exchangeOrderList = new MyExchangeOrderList(); @@ -79,18 +96,25 @@ String imgUrl = ""; if(tExchangeOrder.getOrderType() == 1){ TGoods goods = goodsClient.getGoodsById(tExchangeOrder.getGoodsId()).getData(); - name = goods.getName(); - imgUrl = goods.getCoverPicture(); + if(null != goods){ + name = goods.getName(); + imgUrl = goods.getCoverPicture(); + } }else{ - TCoupon coupon = couponClient.getCouponById(tExchangeOrder.getGoodsId()).getData(); - name = coupon.getName(); - imgUrl = coupon.getCoverPicture(); + TCoupon coupon = couponClient.getCouponById1(tExchangeOrder.getCouponId()).getData(); + if(null != coupon){ + name = coupon.getName(); + imgUrl = coupon.getCoverPicture(); + } } exchangeOrderList.setName(name); exchangeOrderList.setImgUrl(imgUrl); pageList.add(exchangeOrderList); } - return pageList; + Map<String, Object> map = new HashMap<>(); + map.put("list", pageList); + map.put("total", count); + return map; } @@ -105,25 +129,31 @@ ExchangeOrderGoodsInfo info = new ExchangeOrderGoodsInfo(); info.setId(id); info.setStatus(exchangeOrder.getStatus()); - TAppUserAddress userAddress = appUserAddressClient.getAppUserAddressById(exchangeOrder.getAppUserAddressId()).getData(); - info.setConsignee(userAddress.getName()); - info.setPhone(userAddress.getPhone()); - info.setAddress(userAddress.getAddress()); + if(null != exchangeOrder.getAppUserAddressId()){ + TAppUserAddress userAddress = appUserAddressClient.getAppUserAddressById(exchangeOrder.getAppUserAddressId()).getData(); + info.setConsignee(userAddress.getName()); + info.setPhone(userAddress.getPhone()); + info.setAddress(userAddress.getAddress()); + } info.setExpressCompany(exchangeOrder.getExpressCompany()); info.setExpressNumber(exchangeOrder.getExpressNumber()); String name = ""; String imgUrl = ""; if(exchangeOrder.getOrderType() == 1){ TGoods goods = goodsClient.getGoodsById(exchangeOrder.getGoodsId()).getData(); - name = goods.getName(); - imgUrl = goods.getCoverPicture(); + if(null != goods){ + name = goods.getName(); + imgUrl = goods.getCoverPicture(); + } }else{ - TCoupon coupon = couponClient.getCouponById(exchangeOrder.getGoodsId()).getData(); - info.setCouponType(coupon.getType()); - info.setDays(coupon.getDays()); - info.setEndTime(coupon.getEndTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); - name = coupon.getName(); - imgUrl = coupon.getCoverPicture(); + TCoupon coupon = couponClient.getCouponById1(exchangeOrder.getCouponId()).getData(); + if(null != coupon){ + info.setCouponType(coupon.getType()); + info.setDays(coupon.getDays()); + info.setEndTime(coupon.getEndTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + name = coupon.getName(); + imgUrl = coupon.getCoverPicture(); + } } info.setName(name); info.setImgUrl(imgUrl); @@ -133,8 +163,53 @@ info.setCreateTime(exchangeOrder.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); info.setPoints(exchangeOrder.getPoints()); info.setRemark(exchangeOrder.getRemark()); - info.setDeliveryTime(exchangeOrder.getConsignerTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); - info.setFinishTime(exchangeOrder.getReceivingTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + if(null != exchangeOrder.getConsignerTime()){ + info.setDeliveryTime(exchangeOrder.getConsignerTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + } + if(null != exchangeOrder.getReceivingTime()){ + info.setFinishTime(exchangeOrder.getReceivingTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + } return info; } + + @Override + public PageInfo<TExchangeOrder> pageList(ShoppingOrderQuery query) { + String startTime1 = null; + String startTime2 = null; + + + if (StringUtils.hasLength(query.getStartTime())){ + String[] split = query.getStartTime().split(" - "); + startTime1 = split[0]; + startTime2 = split[1]; + } + PageInfo<TExchangeOrder> pageInfo = new PageInfo<>(query.getPageCurr(),query.getPageSize()); + List<TExchangeOrder> list = this.baseMapper.pageList(pageInfo,query,startTime1,startTime2); + for (TExchangeOrder tShoppingOrder : list) { + tShoppingOrder.setUid(tShoppingOrder.getId().toString()); + switch (tShoppingOrder.getOrderType()){ + case 1: + TGoods data = goodsClient.getGoodsById(tShoppingOrder.getGoodsId()).getData(); + if (data!=null){ + tShoppingOrder.setName(data.getName()); + } + break; + case 2: + TCoupon data1 = couponClient.getCouponById1(tShoppingOrder.getCouponId()).getData(); + if (data1!=null){ + tShoppingOrder.setName(data1.getName()); + } + break; + } + if (tShoppingOrder.getAppUserId() != null){ + TAppUser data = appUserClient.getUserById(tShoppingOrder.getAppUserId()).getData(); + if (data!=null){ + tShoppingOrder.setPhone(data.getPhone()); + } + } + } + pageInfo.setRecords(list); + return pageInfo; + } + } -- Gitblit v1.7.1