提交代碼

dev-discount
胡锐 3 years ago
parent 84c860b06d
commit 870ff68323
  1. 25
      hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapperExt.java
  2. 46
      hai-service/src/main/java/com/hai/model/HighCouponAgentRelModel.java
  3. 8
      hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java

@ -9,6 +9,7 @@ import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType; import org.apache.ibatis.type.JdbcType;
import java.util.List; 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 " + " 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} ") " 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); 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<String, Object> getUseNum(@Param("couponAgentRelId") Long couponAgentRelId);
} }

@ -3,6 +3,8 @@ package com.hai.model;
import com.hai.entity.HighAgent; import com.hai.entity.HighAgent;
import com.hai.entity.HighCoupon; import com.hai.entity.HighCoupon;
import java.math.BigDecimal;
/** /**
* @Auther: 胡锐 * @Auther: 胡锐
* @Description: * @Description:
@ -18,6 +20,18 @@ public class HighCouponAgentRelModel {
//代理商信息 //代理商信息
private HighAgent highAgent; private HighAgent highAgent;
// 未使用数量
private Integer noUsedNum;
// 未使用金额
private BigDecimal noUsedPrice;
// 使用数量
private Integer usedNum;
// 使用金额
private BigDecimal usedPrice;
public String getMerchantLogo() { public String getMerchantLogo() {
return merchantLogo; return merchantLogo;
} }
@ -41,4 +55,36 @@ public class HighCouponAgentRelModel {
public void setHighAgent(HighAgent highAgent) { public void setHighAgent(HighAgent highAgent) {
this.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;
}
} }

@ -317,6 +317,14 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
listMap.put("agentId", agentId); listMap.put("agentId", agentId);
List<HighCouponAgentRel> list = getCouponAgentList(listMap).stream().sorted(Comparator.comparing(HighCouponAgentRel::getSalesPrice)).collect(Collectors.toList()); List<HighCouponAgentRel> list = getCouponAgentList(listMap).stream().sorted(Comparator.comparing(HighCouponAgentRel::getSalesPrice)).collect(Collectors.toList());
for (HighCouponAgentRel couponAgentRel : list) {
Map<String, Object> 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<String, Object> returnMap = new HashMap<>(); Map<String, Object> returnMap = new HashMap<>();
returnMap.put("list", list); returnMap.put("list", list);

Loading…
Cancel
Save