Commit 8e265172 by huluobin

long 序列化

parent 3ad9aa82
......@@ -20,6 +20,7 @@ import com.gogirl.infrastructure.mapper.order.serve.OrderServeMapper;
import com.gogirl.shared.market.command.SetUpOuterCouponCommand;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
......@@ -30,6 +31,7 @@ import java.util.stream.Collectors;
@Service
@Slf4j
@Transactional(rollbackFor = Exception.class)
public class CouponCustomerRelevanceServiceImpl extends ServiceImpl<CouponCustomerRelevanceMapper, CouponCustomerRelevance> implements CouponCustomerRelevanceService {
@Resource
......@@ -65,6 +67,15 @@ public class CouponCustomerRelevanceServiceImpl extends ServiceImpl<CouponCustom
List<Integer> freeCouponIds = discountConfigMapper.selectList(new LambdaQueryWrapper<>()).stream().map(DiscountConfig::getCouponId).filter(Objects::nonNull).collect(Collectors.toList());
canUserServeIds.retainAll(orderServeList.stream()
.map(OrderServe::getServeId)
.collect(Collectors.toList()));
return ListUtil.isNotEmpty(canUserServeIds);
})
.peek(couponCustomerRelevance -> {
List<Integer> canUserServeIds = couponCustomerRelevanceMapper.queryCouponCustomerServeRelevance(couponCustomerRelevance.getCouponId());
List<Integer> freeCouponIds = discountConfigMapper.selectList(new LambdaQueryWrapper<>()).stream().map(DiscountConfig::getCouponId).filter(Objects::nonNull).collect(Collectors.toList());
if (freeCouponIds.contains(couponCustomerRelevance.getCouponId())) {
canUserServeIds.retainAll(orderServeList.stream()
.filter(orderServe -> orderServe.getBindCoupon() == 2)
......@@ -73,13 +84,13 @@ public class CouponCustomerRelevanceServiceImpl extends ServiceImpl<CouponCustom
} else {
canUserServeIds.retainAll(orderServeList.stream()
.filter(orderServe -> orderServe.getBindCoupon() == 2)
.filter(orderServe -> orderServe.getProduceCurrentPrice() == null)
.filter(orderServe -> orderServe.getProduceCurrentPrice().compareTo(orderServe.getProduceBargainPrice()) > -1)
.filter(orderServe -> orderServe.getProducePromotionTimeId() == null)
.filter(orderServe -> orderServe.getLeisureDiscountConfigId() == null)
.filter(orderServe -> orderServe.getLeisureDiscountConfigId() == null || orderServe.getLeisureDiscountConfigId() == 0)
.map(OrderServe::getServeId)
.collect(Collectors.toList()));
}
return ListUtil.isNotEmpty(canUserServeIds);
couponCustomerRelevance.setCanBeUse(ListUtil.isNotEmpty(canUserServeIds));
})
//过滤可用
.filter(CouponCustomerRelevance::isValid)
......
......@@ -223,6 +223,9 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
canUserServeIds.retainAll(orderServeList.stream().map(OrderServe::getServeId).collect(Collectors.toList()));
return ListUtil.isNotEmpty(canUserServeIds);
})
.peek(coupon -> {
})
//过滤达到可用金额
.filter(coupon -> coupon.getReachingAmount().compareTo(orderManage.getTotalPrice()) < 0)
.collect(Collectors.toList());
......
......@@ -2,29 +2,53 @@ package com.gogirl.application.product.mall.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gogirl.application.product.mall.MallShoppingCartQryService;
import com.gogirl.assembler.MallShoppingCartDTOAssembler;
import com.gogirl.domain.order.mall.MallShoppingCart;
import com.gogirl.domain.product.mall.MallProduct;
import com.gogirl.infrastructure.common.util.ListUtil;
import com.gogirl.infrastructure.mapper.order.mall.MallShoppingCartMapper;
import com.gogirl.infrastructure.mapper.product.mall.MallProductMapper;
import com.gogirl.shared.product.query.dto.MallShoppingCartDTO;
import com.gogirl.shared.product.query.dto.MyMallShoppingCartDTO;
import com.gogirl.shared.product.query.qry.MyShoppingCartQuery;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@AllArgsConstructor
public class MallShoppingCartQryServiceImpl implements MallShoppingCartQryService {
private final MallShoppingCartMapper mallShoppingCartMapper;
private final MallShoppingCartDTOAssembler mallShoppingCartDTOAssembler;
private final MallProductMapper mallProductMapper;
@Override
public MyMallShoppingCartDTO queryMyShoppingCart(MyShoppingCartQuery qry) {
List<MallShoppingCart> mallShoppingCartList = mallShoppingCartMapper.selectList(
new LambdaQueryWrapper<MallShoppingCart>().eq(MallShoppingCart::getCustomerId, qry.getCustomerId())
);
List<Long> productIds = mallShoppingCartList.stream().map(MallShoppingCart::getProductId)
.collect(Collectors.toList());
if (ListUtil.isNotEmpty(productIds)) {
Map<Long, List<MallProduct>> map = mallProductMapper.selectBatchIds(productIds)
.stream()
.collect(Collectors.groupingBy(MallProduct::getId));
mallShoppingCartList.forEach(mallShoppingCart -> {
List<MallProduct> mallProductList = map.get(mallShoppingCart.getProductId());
if (ListUtil.isNotEmpty(mallProductList)) {
mallShoppingCart.setMallProduct(mallProductList.stream().findAny().orElse(null));
}
});
}
List<MallShoppingCartDTO> mallShoppingCartDTOList = mallShoppingCartList.stream().map(mallShoppingCartDTOAssembler).collect(Collectors.toList());
MyMallShoppingCartDTO data = new MyMallShoppingCartDTO();
data.setMallShoppingCartDTOList(mallShoppingCartList);
data.setMallShoppingCartDTOList(mallShoppingCartDTOList);
data.setItemSum(mallShoppingCartList.stream()
.map(MallShoppingCart::getNum)
......
......@@ -75,7 +75,6 @@ public class BaseQuestionServiceImpl extends ServiceImpl<BaseQuestionMapper, Bas
complaintMainService.saveComplainsByOrderQuestion(list);
Coupon coupon = couponService.getOne(new LambdaQueryWrapper<Coupon>().eq(Coupon::getName, "问卷调查礼券"));
if (coupon != null) {
couponService.sendCoupon(coupon.getId(), currentCustomerId);
......
package com.gogirl.assembler;
import com.gogirl.domain.product.mall.MallProduct;
import com.gogirl.shared.product.query.dto.MallProductDTO;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import java.util.function.Function;
@Component
@AllArgsConstructor
public class MallProductDTOAssembler implements Function<MallProduct, MallProductDTO> {
private final MallShoppingCartDTOAssembler.PurchaseSkuDTOAssembler purchaseSkuDTOAssembler;
@Override
public MallProductDTO apply(MallProduct mallProduct) {
MallProductDTO mallProductDTO = new MallProductDTO();
BeanUtils.copyProperties(mallProduct, mallProductDTO);
return mallProductDTO;
}
}
package com.gogirl.assembler;
import com.gogirl.domain.order.mall.MallShoppingCart;
import com.gogirl.domain.product.purchase.PurchaseSku;
import com.gogirl.shared.product.query.dto.MallShoppingCartDTO;
import com.gogirl.shared.product.query.dto.PurchaseSkuDTO;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import java.util.function.Function;
@Component
@AllArgsConstructor
public class MallShoppingCartDTOAssembler implements Function<MallShoppingCart, MallShoppingCartDTO> {
private final MallProductDTOAssembler mallProductDTOAssembler;
@Override
public MallShoppingCartDTO apply(MallShoppingCart mallShoppingCart) {
MallShoppingCartDTO mallShoppingCartDTO = new MallShoppingCartDTO();
BeanUtils.copyProperties(mallShoppingCart, mallShoppingCartDTO);
if (mallShoppingCart.getMallProduct() != null) {
mallShoppingCartDTO.setMallProductDTO(mallProductDTOAssembler.apply(mallShoppingCart.getMallProduct()));
}
return mallShoppingCartDTO;
}
@Component
static class PurchaseSkuDTOAssembler implements Function<PurchaseSku, PurchaseSkuDTO> {
@Override
public PurchaseSkuDTO apply(PurchaseSku purchaseSku) {
PurchaseSkuDTO purchaseSkuDTO = new PurchaseSkuDTO();
BeanUtils.copyProperties(purchaseSku, purchaseSkuDTO);
return purchaseSkuDTO;
}
}
}
package com.gogirl.domain.market.coupon;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
......@@ -69,4 +70,7 @@ public class Coupon {
@ApiModelProperty("1-计算 2-不计算")
private Integer isCalcAchievement;
@TableField(exist = false)
private Integer canBeUse;
}
......@@ -31,6 +31,7 @@ public class CouponCustomerRelevance implements Serializable {
private Integer id;
@ApiModelProperty("顾客Id")
private Integer customerId;
@ApiModelProperty("卡券id")
private Integer couponId;
......@@ -39,43 +40,66 @@ public class CouponCustomerRelevance implements Serializable {
@ApiModelProperty("领奖码")
private String code;
@ApiModelProperty("领券时间")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date receiveTime;
@ApiModelProperty("可用开始日期")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date validStartTime;
@ApiModelProperty("可用截止日期")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date validEndTime;
@ApiModelProperty("使用日期")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date useDate;
//冗余coupon字段
@ApiModelProperty("卡券配置备注")
private String remark;
@ApiModelProperty("能否使用")
@TableField(exist = false)
private Boolean canBeUse;
@TableField(exist = false)
private Coupon coupon;
@TableField(exist = false)
private Customer customer;
@ApiModelProperty("卡券名称")
private String couponName;
@ApiModelProperty("优惠金额")
private BigDecimal discountAmount;
@ApiModelProperty("满这个金额才能减")
private BigDecimal reachingAmount;
@ApiModelProperty("优惠折扣")
private BigDecimal discountPercent;
@ApiModelProperty("优惠券类型:1.现金抵扣券;2.免单券;3满减券;4卸甲券")
private Integer type;
@ApiModelProperty("0 = 内部券 1 = 外部券")
private Integer sourceType;
@ApiModelProperty("使用条件:1.重叠使用")
private String condition1;
@ApiModelProperty("客户购买该券时,实际支付的金额(用该金额算业绩)")
private BigDecimal payAmount;
@ApiModelProperty("卡券来源")
private String sourceFrom;
@ApiModelProperty("卡券来源id")
......
......@@ -74,6 +74,9 @@ public class TimesCardCustomerRelevance {
//状态-已过期
public static Integer STATUS_OVER_TIME = 3;
@TableField(exist = false)
private Boolean canBeUse;
/**
* 次卡是否可用
*
......@@ -83,4 +86,5 @@ public class TimesCardCustomerRelevance {
return validStartTime.getTime() < System.currentTimeMillis()
&& validEndTime.getTime() > System.currentTimeMillis();
}
}
package com.gogirl.domain.order.mall;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.gogirl.domain.product.mall.MallProduct;
import com.gogirl.domain.product.purchase.PurchaseSku;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......@@ -37,4 +39,8 @@ public class MallShoppingCart {
private Long lastUpdateTime;
@TableField(exist = false)
private MallProduct mallProduct;
}
......@@ -20,6 +20,7 @@ import com.gogirl.infrastructure.common.exception.RRException;
import com.gogirl.infrastructure.common.util.ListUtil;
import com.gogirl.infrastructure.config.GogirlProperties;
import com.gogirl.infrastructure.feign.wx.WxPayControllerFeign;
import com.gogirl.infrastructure.mapper.market.discount.DiscountConfigMapper;
import com.gogirl.infrastructure.mapper.market.timescard.TimesCardCustomerRelevanceMapper;
import com.gogirl.infrastructure.mapper.market.timescard.TimesCardTypeContentMapper;
import com.gogirl.infrastructure.mapper.market.timescard.TimesCardTypeMapper;
......@@ -150,6 +151,8 @@ public class TimesCardController {
return JsonResult.success(timesCardCustomerRelevance);
}
private final DiscountConfigMapper discountConfigMapper;
@ApiOperation(value = "根据订单号查询我的可用的次卡")
@GetMapping("/customer/timescard/getMyTimesCardByOrderId")
public JsonResult<List<TimesCardCustomerRelevance>> getMyTimesCardByOrderId(@RequestHeader String token,
......@@ -169,10 +172,24 @@ public class TimesCardController {
//次卡可以作用的服务
List<Integer> canUserServeIds = timesCardCustomerRelevanceMapper.queryTimesCardServeIds(timesCardCustomerRelevance.getCardTypeId());
//可用服务与当前服务交集
canUserServeIds.retainAll(orderServeList.stream().map(OrderServe::getServeId).collect(Collectors.toList()));
canUserServeIds.retainAll(orderServeList.stream()
.map(OrderServe::getServeId)
.collect(Collectors.toList()));
//不为空
return ListUtil.isNotEmpty(canUserServeIds);
})
.peek(timesCardCustomerRelevance -> {
List<Integer> canUserServeIds = timesCardCustomerRelevanceMapper.queryTimesCardServeIds(timesCardCustomerRelevance.getCardTypeId());
canUserServeIds.retainAll(orderServeList.stream()
.filter(orderServe -> orderServe.getBindCoupon() == 2)
.filter(orderServe -> orderServe.getProduceCurrentPrice().compareTo(orderServe.getProduceBargainPrice()) > -1)
.filter(orderServe -> orderServe.getProducePromotionTimeId() == null)
.filter(orderServe -> orderServe.getLeisureDiscountConfigId() == null || orderServe.getLeisureDiscountConfigId() == 0)
.map(OrderServe::getServeId)
.collect(Collectors.toList()));
timesCardCustomerRelevance.setCanBeUse(ListUtil.isNotEmpty(canUserServeIds));
})
.collect(Collectors.toList());
return JsonResult.success(timesCardCustomerRelevanceList);
}
......
......@@ -108,4 +108,6 @@ public class OrderServeDTO {
private Integer actualServeDuration;
private Integer bindCoupon;
}
......@@ -14,5 +14,5 @@ public class MyMallShoppingCartDTO {
private Integer itemSum;
private List<MallShoppingCart> mallShoppingCartDTOList;
private List<MallShoppingCartDTO> mallShoppingCartDTOList;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment