|
|
|
@@ -1,6 +1,7 @@ |
|
|
|
package com.simple.service.impl; |
|
|
|
import com.simple.domain.dto.WxUserCouponDto; |
|
|
|
import com.simple.domain.po.WxCoupon; |
|
|
|
import com.simple.domain.po.WxCouponOrder; |
|
|
|
import com.simple.domain.po.WxOrder; |
|
|
|
import com.simple.mapper.WxCouponMapper; |
|
|
|
import com.simple.mapper.WxCouponOrderMapper; |
|
|
|
@@ -36,35 +37,31 @@ public class WxUserCouponServiceImpl implements WxUserCouponService { |
|
|
|
//TODO 待测试优化 |
|
|
|
List<WxUserCouponDto> wxUserCoupons = new ArrayList<>(); |
|
|
|
//查询订单表 |
|
|
|
WxOrder wxOrder = new WxOrder(); |
|
|
|
wxOrder.setCUserId(userId); |
|
|
|
/* |
|
|
|
wxOrder.setCouponStatus(status); |
|
|
|
List<WxOrder> orders = wxOrderService.findList(wxOrder); |
|
|
|
List<String> ids = orders.stream().map(p->p.getCouponId()+"").distinct().collect(Collectors.toList()); |
|
|
|
if(ids.size()>0){ |
|
|
|
//查询WxCoupon |
|
|
|
WxCoupon wxCoupon = new WxCoupon(); |
|
|
|
wxCoupon.setIds(ids); |
|
|
|
List<WxCoupon> wxCoupons = wxCouponMapper.findList(wxCoupon); |
|
|
|
Map<Long,String> couponNamesMap = wxCoupons.stream().collect(Collectors.toMap(WxCoupon::getId,p->p.getTitle())); |
|
|
|
for (WxOrder temp:orders) { |
|
|
|
wxUserCoupons.add(getWxUserCoupon(temp,couponNamesMap.get(temp.getCouponId()))); |
|
|
|
} |
|
|
|
WxCouponOrder wxCouponOrder = new WxCouponOrder(); |
|
|
|
wxCouponOrder.setCUserId(userId); |
|
|
|
wxCouponOrder.setCouponOrderStatus(status);//状态:0,待使用 1,已核销 2,已过期 3,已退款 |
|
|
|
List<WxCouponOrder> wxCouponOrders = wxCouponOrderMapper.findList(wxCouponOrder); |
|
|
|
if(wxCouponOrders.isEmpty()){ |
|
|
|
return wxUserCoupons; |
|
|
|
} |
|
|
|
List<Long> ids = wxCouponOrders.stream().map(p->p.getCouponId()).distinct().collect(Collectors.toList()); |
|
|
|
WxCoupon wxCoupon = new WxCoupon(); |
|
|
|
wxCoupon.setIds(ids); |
|
|
|
List<WxCoupon> wxCoupons = wxCouponMapper.findList(wxCoupon); |
|
|
|
Map<Long,WxCoupon> couponNamesMap = wxCoupons.stream().collect(Collectors.toMap(WxCoupon::getId,p->p)); |
|
|
|
for (WxCouponOrder temp:wxCouponOrders) { |
|
|
|
wxUserCoupons.add(getWxUserCoupon(temp,couponNamesMap.get(temp.getCouponId()))); |
|
|
|
} |
|
|
|
*/ |
|
|
|
return wxUserCoupons; |
|
|
|
} |
|
|
|
public WxUserCouponDto getWxUserCoupon(WxOrder wxOrder, String title){ |
|
|
|
public WxUserCouponDto getWxUserCoupon(WxCouponOrder wxCouponOrder, WxCoupon wxCoupon){ |
|
|
|
WxUserCouponDto wxUserCoupon = new WxUserCouponDto(); |
|
|
|
wxUserCoupon.setOrderId(wxOrder.getId()); |
|
|
|
wxUserCoupon.setcUserId(wxOrder.getCUserId()); |
|
|
|
/* |
|
|
|
wxUserCoupon.setCouponId(wxOrder.getCouponId()); |
|
|
|
wxUserCoupon.setCouponStatus(wxOrder.getCouponStatus()); |
|
|
|
wxUserCoupon.setValidDate(wxOrder.getValidDate()); |
|
|
|
*/ |
|
|
|
wxUserCoupon.setCouponTitle(title); |
|
|
|
wxUserCoupon.setOrderId(wxCouponOrder.getId()); |
|
|
|
wxUserCoupon.setcUserId(wxCouponOrder.getCUserId()); |
|
|
|
wxUserCoupon.setCouponStatus(wxCouponOrder.getCouponOrderStatus()); |
|
|
|
wxUserCoupon.setCouponId(wxCouponOrder.getCouponId()); |
|
|
|
wxUserCoupon.setValidDate(wxCouponOrder.getExpiredTime()); |
|
|
|
wxUserCoupon.setCouponTitle(wxCoupon.getTitle()); |
|
|
|
return wxUserCoupon; |
|
|
|
} |
|
|
|
} |
|
|
|
|