|
@@ -10,6 +10,7 @@ import com.chelvc.cloud.vehicle.api.dto.UserCouponDTO;
|
|
|
import com.chelvc.cloud.vehicle.api.param.UserCouponModifyParam;
|
|
|
import com.chelvc.cloud.vehicle.api.param.UserCouponPagingParam;
|
|
|
import com.chelvc.cloud.vehicle.api.param.UserCouponQueryParam;
|
|
|
+import com.chelvc.cloud.vehicle.api.util.PromotionUtils;
|
|
|
import com.chelvc.cloud.vehicle.server.copier.UserCouponCopier;
|
|
|
import com.chelvc.cloud.vehicle.server.dao.UserCouponMapper;
|
|
|
import com.chelvc.cloud.vehicle.server.entity.Coupon;
|
|
@@ -27,9 +28,7 @@ import org.apache.dubbo.config.annotation.DubboService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -70,6 +69,23 @@ public class UserCouponServiceImpl extends ServiceImpl<UserCouponMapper, UserCou
|
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<UserCouponDTO> listUserCanUseCoupons(@NonNull UserCouponQueryParam param) {
|
|
|
+ List<String> merchantIds = new ArrayList<>(Arrays.asList(param.getMerchantId().split(",")));
|
|
|
+ merchantIds.add(PromotionUtils.PLATFORM_ID);
|
|
|
+ param.setMerchantIds(merchantIds);
|
|
|
+ Long userId = SessionContextHolder.getId();
|
|
|
+ // 当前用户对于当前商品可使用的优惠券列表
|
|
|
+ List<UserCoupon> userCoupons = this.baseMapper.listUserCanUseCoupons(userId, param);
|
|
|
+ if (CollectionUtils.isEmpty(userCoupons)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ return userCoupons
|
|
|
+ .stream()
|
|
|
+ .map(o -> UserCouponCopier.INSTANCE.copying(o, o.getCoupon()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Long addUserCoupon(@NonNull UserCouponModifyParam param) {
|
|
|
UserCoupon userCoupon = UserCouponCopier.INSTANCE.copying(param);
|