diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapperExt.java index 0d31cc76..7c332ce1 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapperExt.java @@ -9,6 +9,7 @@ import org.apache.ibatis.annotations.Select; import org.apache.ibatis.type.JdbcType; import java.util.List; +import java.util.Map; /** @@ -54,4 +55,28 @@ public interface HighCouponAgentRelMapperExt { " LEFT JOIN high_coupon_agent_rel b on b.id = a.coupon_agent_id " + " where a.agent_id = #{agentId} and a.`status` in (${status}) and a.type = #{type} ") Integer getAgentCodePrice(@Param("agentId") Long agentId,@Param("status") String status,@Param("type") Integer type); + + @Select(" select " + + " a.id," + + " a.noUsedNum, " + + " (a.noUsedNum * a.price) noUsedPrice," + + " b.usedNum," + + " (b.usedNum * b.price) usedPrice" + + " from (" + + " select " + + " b.id," + + " count(1) noUsedNum," + + " b.sales_price price" + + " from high_coupon_agent_code a " + + " LEFT JOIN high_coupon_agent_rel b on b.id = a.coupon_agent_id" + + " where b.id = 22 and a.`status` = 2) a," + + " (select " + + " b.id," + + " count(1) usedNum," + + " b.sales_price price" + + " from high_coupon_agent_code a" + + " LEFT JOIN high_coupon_agent_rel b on b.id = a.coupon_agent_id" + + " where b.id = 22 and a.`status` = 3) b" + + " where a.id = b.id ") + Map getUseNum(@Param("couponAgentRelId") Long couponAgentRelId); } diff --git a/hai-service/src/main/java/com/hai/model/HighCouponAgentRelModel.java b/hai-service/src/main/java/com/hai/model/HighCouponAgentRelModel.java index 8c9cd0ac..0eca04ca 100644 --- a/hai-service/src/main/java/com/hai/model/HighCouponAgentRelModel.java +++ b/hai-service/src/main/java/com/hai/model/HighCouponAgentRelModel.java @@ -3,6 +3,8 @@ package com.hai.model; import com.hai.entity.HighAgent; import com.hai.entity.HighCoupon; +import java.math.BigDecimal; + /** * @Auther: 胡锐 * @Description: @@ -18,6 +20,18 @@ public class HighCouponAgentRelModel { //代理商信息 private HighAgent highAgent; + // 未使用数量 + private Integer noUsedNum; + + // 未使用金额 + private BigDecimal noUsedPrice; + + // 使用数量 + private Integer usedNum; + + // 使用金额 + private BigDecimal usedPrice; + public String getMerchantLogo() { return merchantLogo; } @@ -41,4 +55,36 @@ public class HighCouponAgentRelModel { public void setHighAgent(HighAgent highAgent) { this.highAgent = highAgent; } + + public Integer getNoUsedNum() { + return noUsedNum; + } + + public void setNoUsedNum(Integer noUsedNum) { + this.noUsedNum = noUsedNum; + } + + public BigDecimal getNoUsedPrice() { + return noUsedPrice; + } + + public void setNoUsedPrice(BigDecimal noUsedPrice) { + this.noUsedPrice = noUsedPrice; + } + + public Integer getUsedNum() { + return usedNum; + } + + public void setUsedNum(Integer usedNum) { + this.usedNum = usedNum; + } + + public BigDecimal getUsedPrice() { + return usedPrice; + } + + public void setUsedPrice(BigDecimal usedPrice) { + this.usedPrice = usedPrice; + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java index c34d57ac..c30be274 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java @@ -317,6 +317,14 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { listMap.put("agentId", agentId); List list = getCouponAgentList(listMap).stream().sorted(Comparator.comparing(HighCouponAgentRel::getSalesPrice)).collect(Collectors.toList()); + for (HighCouponAgentRel couponAgentRel : list) { + Map map = highCouponAgentRelMapper.getUseNum(couponAgentRel.getId()); + couponAgentRel.setUsedNum(MapUtils.getInteger(map, "usedNum")); + couponAgentRel.setUsedPrice(new BigDecimal(MapUtils.getString(map, "usedPrice"))); + couponAgentRel.setNoUsedNum(MapUtils.getInteger(map, "noUsedNum")); + couponAgentRel.setNoUsedPrice(new BigDecimal(MapUtils.getString(map, "noUsedPrice"))); + } + Map returnMap = new HashMap<>(); returnMap.put("list", list);