'提交diam'

dev-discount
199901012 4 years ago
parent 82e27c0062
commit fb9de099ac
  1. 8
      hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java
  2. 23
      hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapper.java
  3. 16
      hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapperExt.java
  4. 14
      hai-service/src/main/java/com/hai/dao/HighCouponAgentRelSqlProvider.java
  5. 16
      hai-service/src/main/java/com/hai/entity/HighCouponAgentRel.java
  6. 60
      hai-service/src/main/java/com/hai/entity/HighCouponAgentRelExample.java
  7. 31
      hai-service/src/main/java/com/hai/model/AgentSalesModel.java
  8. 7
      hai-service/src/main/java/com/hai/service/HighCouponAgentService.java
  9. 48
      hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java

@ -69,10 +69,12 @@ public class HighCouponAgentController {
SessionObject sessionObject = userCenter.getSessionObject(request); SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
Map<String,Object> map = new HashMap<>(); if (userInfoModel.getHighAgent() == null) {
map.put("", ""); log.error("HighCouponAgentController -> assignCouponAgent() error!","该主角色没有权限");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, "");
}
return ResponseMsgUtil.success(map); return ResponseMsgUtil.success(highCouponAgentService.getSalesCountByAgent(userInfoModel.getHighAgent().getId()));
} catch (Exception e) { } catch (Exception e) {
log.error("HighCouponAgentController --> getCodeById() error!", e); log.error("HighCouponAgentController --> getCodeById() error!", e);

@ -41,16 +41,16 @@ public interface HighCouponAgentRelMapper extends HighCouponAgentRelMapperExt {
@Insert({ @Insert({
"insert into high_coupon_agent_rel (coupon_name, sales_price, ", "insert into high_coupon_agent_rel (coupon_name, sales_price, ",
"coupon_id, agent_id, ", "coupon_id, agent_id, ",
"stock_count, create_time, ", "stock_count, sales_count, ",
"`status`, operator_id, ", "create_time, `status`, ",
"operator_name, ext_1, ", "operator_id, operator_name, ",
"ext_2, ext_3)", "ext_1, ext_2, ext_3)",
"values (#{couponName,jdbcType=VARCHAR}, #{salesPrice,jdbcType=DECIMAL}, ", "values (#{couponName,jdbcType=VARCHAR}, #{salesPrice,jdbcType=DECIMAL}, ",
"#{couponId,jdbcType=BIGINT}, #{agentId,jdbcType=BIGINT}, ", "#{couponId,jdbcType=BIGINT}, #{agentId,jdbcType=BIGINT}, ",
"#{stockCount,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ", "#{stockCount,jdbcType=INTEGER}, #{salesCount,jdbcType=INTEGER}, ",
"#{status,jdbcType=INTEGER}, #{operatorId,jdbcType=BIGINT}, ", "#{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, ",
"#{operatorName,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR}, ", "#{operatorId,jdbcType=BIGINT}, #{operatorName,jdbcType=VARCHAR}, ",
"#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
}) })
@Options(useGeneratedKeys=true,keyProperty="id") @Options(useGeneratedKeys=true,keyProperty="id")
int insert(HighCouponAgentRel record); int insert(HighCouponAgentRel record);
@ -67,6 +67,7 @@ public interface HighCouponAgentRelMapper extends HighCouponAgentRelMapperExt {
@Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT),
@Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT), @Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT),
@Result(column="stock_count", property="stockCount", jdbcType=JdbcType.INTEGER), @Result(column="stock_count", property="stockCount", jdbcType=JdbcType.INTEGER),
@Result(column="sales_count", property="salesCount", jdbcType=JdbcType.INTEGER),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="operator_id", property="operatorId", jdbcType=JdbcType.BIGINT), @Result(column="operator_id", property="operatorId", jdbcType=JdbcType.BIGINT),
@ -79,8 +80,8 @@ public interface HighCouponAgentRelMapper extends HighCouponAgentRelMapperExt {
@Select({ @Select({
"select", "select",
"id, coupon_name, sales_price, coupon_id, agent_id, stock_count, create_time, ", "id, coupon_name, sales_price, coupon_id, agent_id, stock_count, sales_count, ",
"`status`, operator_id, operator_name, ext_1, ext_2, ext_3", "create_time, `status`, operator_id, operator_name, ext_1, ext_2, ext_3",
"from high_coupon_agent_rel", "from high_coupon_agent_rel",
"where id = #{id,jdbcType=BIGINT}" "where id = #{id,jdbcType=BIGINT}"
}) })
@ -91,6 +92,7 @@ public interface HighCouponAgentRelMapper extends HighCouponAgentRelMapperExt {
@Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT),
@Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT), @Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT),
@Result(column="stock_count", property="stockCount", jdbcType=JdbcType.INTEGER), @Result(column="stock_count", property="stockCount", jdbcType=JdbcType.INTEGER),
@Result(column="sales_count", property="salesCount", jdbcType=JdbcType.INTEGER),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="operator_id", property="operatorId", jdbcType=JdbcType.BIGINT), @Result(column="operator_id", property="operatorId", jdbcType=JdbcType.BIGINT),
@ -117,6 +119,7 @@ public interface HighCouponAgentRelMapper extends HighCouponAgentRelMapperExt {
"coupon_id = #{couponId,jdbcType=BIGINT},", "coupon_id = #{couponId,jdbcType=BIGINT},",
"agent_id = #{agentId,jdbcType=BIGINT},", "agent_id = #{agentId,jdbcType=BIGINT},",
"stock_count = #{stockCount,jdbcType=INTEGER},", "stock_count = #{stockCount,jdbcType=INTEGER},",
"sales_count = #{salesCount,jdbcType=INTEGER},",
"create_time = #{createTime,jdbcType=TIMESTAMP},", "create_time = #{createTime,jdbcType=TIMESTAMP},",
"`status` = #{status,jdbcType=INTEGER},", "`status` = #{status,jdbcType=INTEGER},",
"operator_id = #{operatorId,jdbcType=BIGINT},", "operator_id = #{operatorId,jdbcType=BIGINT},",

@ -1,7 +1,21 @@
package com.hai.dao; package com.hai.dao;
import com.hai.model.AgentSalesModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.Map;
/** /**
* mapper扩展类 * mapper扩展类
*/ */
public interface HighCouponAgentRelMapperExt { public interface HighCouponAgentRelMapperExt {
}
@Select(" select case when sum(1) is not null then sum(1) else 0 end count," +
" case when sum(c.sales_price) is not null then sum(c.sales_price) else 0 end salesCountPrice " +
" from high_coupon_agent_code a,high_coupon_code b,high_coupon_agent_rel c" +
" where c.id = a.coupon_agent_id and c.agent_id = #{agentId}" +
" and a.status = 2 and a.coupon_code_id = b.id and b.consume_time >= #{consumeTimeS} and b.consume_time <= #{consumeTimeE}")
AgentSalesModel getAgentSales(@Param("agentId") Long agentId, @Param("consumeTimeS")String consumeTimeS, @Param("consumeTimeE")String consumeTimeE);
}

@ -48,6 +48,10 @@ public class HighCouponAgentRelSqlProvider {
sql.VALUES("stock_count", "#{stockCount,jdbcType=INTEGER}"); sql.VALUES("stock_count", "#{stockCount,jdbcType=INTEGER}");
} }
if (record.getSalesCount() != null) {
sql.VALUES("sales_count", "#{salesCount,jdbcType=INTEGER}");
}
if (record.getCreateTime() != null) { if (record.getCreateTime() != null) {
sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}"); sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
} }
@ -91,6 +95,7 @@ public class HighCouponAgentRelSqlProvider {
sql.SELECT("coupon_id"); sql.SELECT("coupon_id");
sql.SELECT("agent_id"); sql.SELECT("agent_id");
sql.SELECT("stock_count"); sql.SELECT("stock_count");
sql.SELECT("sales_count");
sql.SELECT("create_time"); sql.SELECT("create_time");
sql.SELECT("`status`"); sql.SELECT("`status`");
sql.SELECT("operator_id"); sql.SELECT("operator_id");
@ -139,6 +144,10 @@ public class HighCouponAgentRelSqlProvider {
sql.SET("stock_count = #{record.stockCount,jdbcType=INTEGER}"); sql.SET("stock_count = #{record.stockCount,jdbcType=INTEGER}");
} }
if (record.getSalesCount() != null) {
sql.SET("sales_count = #{record.salesCount,jdbcType=INTEGER}");
}
if (record.getCreateTime() != null) { if (record.getCreateTime() != null) {
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
} }
@ -181,6 +190,7 @@ public class HighCouponAgentRelSqlProvider {
sql.SET("coupon_id = #{record.couponId,jdbcType=BIGINT}"); sql.SET("coupon_id = #{record.couponId,jdbcType=BIGINT}");
sql.SET("agent_id = #{record.agentId,jdbcType=BIGINT}"); sql.SET("agent_id = #{record.agentId,jdbcType=BIGINT}");
sql.SET("stock_count = #{record.stockCount,jdbcType=INTEGER}"); sql.SET("stock_count = #{record.stockCount,jdbcType=INTEGER}");
sql.SET("sales_count = #{record.salesCount,jdbcType=INTEGER}");
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
sql.SET("operator_id = #{record.operatorId,jdbcType=BIGINT}"); sql.SET("operator_id = #{record.operatorId,jdbcType=BIGINT}");
@ -218,6 +228,10 @@ public class HighCouponAgentRelSqlProvider {
sql.SET("stock_count = #{stockCount,jdbcType=INTEGER}"); sql.SET("stock_count = #{stockCount,jdbcType=INTEGER}");
} }
if (record.getSalesCount() != null) {
sql.SET("sales_count = #{salesCount,jdbcType=INTEGER}");
}
if (record.getCreateTime() != null) { if (record.getCreateTime() != null) {
sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}"); sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
} }

@ -46,6 +46,11 @@ public class HighCouponAgentRel extends HighCouponAgentRelModel implements Seria
*/ */
private Integer stockCount; private Integer stockCount;
/**
* 销售数量
*/
private Integer salesCount;
/** /**
* 创建时间 * 创建时间
*/ */
@ -122,6 +127,14 @@ public class HighCouponAgentRel extends HighCouponAgentRelModel implements Seria
this.stockCount = stockCount; this.stockCount = stockCount;
} }
public Integer getSalesCount() {
return salesCount;
}
public void setSalesCount(Integer salesCount) {
this.salesCount = salesCount;
}
public Date getCreateTime() { public Date getCreateTime() {
return createTime; return createTime;
} }
@ -196,6 +209,7 @@ public class HighCouponAgentRel extends HighCouponAgentRelModel implements Seria
&& (this.getCouponId() == null ? other.getCouponId() == null : this.getCouponId().equals(other.getCouponId())) && (this.getCouponId() == null ? other.getCouponId() == null : this.getCouponId().equals(other.getCouponId()))
&& (this.getAgentId() == null ? other.getAgentId() == null : this.getAgentId().equals(other.getAgentId())) && (this.getAgentId() == null ? other.getAgentId() == null : this.getAgentId().equals(other.getAgentId()))
&& (this.getStockCount() == null ? other.getStockCount() == null : this.getStockCount().equals(other.getStockCount())) && (this.getStockCount() == null ? other.getStockCount() == null : this.getStockCount().equals(other.getStockCount()))
&& (this.getSalesCount() == null ? other.getSalesCount() == null : this.getSalesCount().equals(other.getSalesCount()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getOperatorId() == null ? other.getOperatorId() == null : this.getOperatorId().equals(other.getOperatorId())) && (this.getOperatorId() == null ? other.getOperatorId() == null : this.getOperatorId().equals(other.getOperatorId()))
@ -215,6 +229,7 @@ public class HighCouponAgentRel extends HighCouponAgentRelModel implements Seria
result = prime * result + ((getCouponId() == null) ? 0 : getCouponId().hashCode()); result = prime * result + ((getCouponId() == null) ? 0 : getCouponId().hashCode());
result = prime * result + ((getAgentId() == null) ? 0 : getAgentId().hashCode()); result = prime * result + ((getAgentId() == null) ? 0 : getAgentId().hashCode());
result = prime * result + ((getStockCount() == null) ? 0 : getStockCount().hashCode()); result = prime * result + ((getStockCount() == null) ? 0 : getStockCount().hashCode());
result = prime * result + ((getSalesCount() == null) ? 0 : getSalesCount().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getOperatorId() == null) ? 0 : getOperatorId().hashCode()); result = prime * result + ((getOperatorId() == null) ? 0 : getOperatorId().hashCode());
@ -237,6 +252,7 @@ public class HighCouponAgentRel extends HighCouponAgentRelModel implements Seria
sb.append(", couponId=").append(couponId); sb.append(", couponId=").append(couponId);
sb.append(", agentId=").append(agentId); sb.append(", agentId=").append(agentId);
sb.append(", stockCount=").append(stockCount); sb.append(", stockCount=").append(stockCount);
sb.append(", salesCount=").append(salesCount);
sb.append(", createTime=").append(createTime); sb.append(", createTime=").append(createTime);
sb.append(", status=").append(status); sb.append(", status=").append(status);
sb.append(", operatorId=").append(operatorId); sb.append(", operatorId=").append(operatorId);

@ -496,6 +496,66 @@ public class HighCouponAgentRelExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andSalesCountIsNull() {
addCriterion("sales_count is null");
return (Criteria) this;
}
public Criteria andSalesCountIsNotNull() {
addCriterion("sales_count is not null");
return (Criteria) this;
}
public Criteria andSalesCountEqualTo(Integer value) {
addCriterion("sales_count =", value, "salesCount");
return (Criteria) this;
}
public Criteria andSalesCountNotEqualTo(Integer value) {
addCriterion("sales_count <>", value, "salesCount");
return (Criteria) this;
}
public Criteria andSalesCountGreaterThan(Integer value) {
addCriterion("sales_count >", value, "salesCount");
return (Criteria) this;
}
public Criteria andSalesCountGreaterThanOrEqualTo(Integer value) {
addCriterion("sales_count >=", value, "salesCount");
return (Criteria) this;
}
public Criteria andSalesCountLessThan(Integer value) {
addCriterion("sales_count <", value, "salesCount");
return (Criteria) this;
}
public Criteria andSalesCountLessThanOrEqualTo(Integer value) {
addCriterion("sales_count <=", value, "salesCount");
return (Criteria) this;
}
public Criteria andSalesCountIn(List<Integer> values) {
addCriterion("sales_count in", values, "salesCount");
return (Criteria) this;
}
public Criteria andSalesCountNotIn(List<Integer> values) {
addCriterion("sales_count not in", values, "salesCount");
return (Criteria) this;
}
public Criteria andSalesCountBetween(Integer value1, Integer value2) {
addCriterion("sales_count between", value1, value2, "salesCount");
return (Criteria) this;
}
public Criteria andSalesCountNotBetween(Integer value1, Integer value2) {
addCriterion("sales_count not between", value1, value2, "salesCount");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() { public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null"); addCriterion("create_time is null");
return (Criteria) this; return (Criteria) this;

@ -0,0 +1,31 @@
package com.hai.model;
import java.math.BigDecimal;
/**
* @Auther: 胡锐
* @Description:
* @Date: 2021/4/22 23:44
*/
public class AgentSalesModel {
private Integer count;
private BigDecimal salesCountPrice;
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
public BigDecimal getSalesCountPrice() {
return salesCountPrice;
}
public void setSalesCountPrice(BigDecimal salesCountPrice) {
this.salesCountPrice = salesCountPrice;
}
}

@ -55,4 +55,11 @@ public interface HighCouponAgentService {
* @Date 2021/4/21 22:35 * @Date 2021/4/21 22:35
**/ **/
Map<String, Object> generateCode(Long couponAgentCodeId); Map<String, Object> generateCode(Long couponAgentCodeId);
/**
* @Author 胡锐
* @Description 根据代理商 查询销售统计
* @Date 2021/4/22 22:26
**/
Map<String, Object> getSalesCountByAgent(Long agentId) throws Exception;
} }

@ -4,10 +4,12 @@ import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode; import com.hai.common.exception.SysCode;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.dao.HighCouponAgentCodeMapper; import com.hai.dao.HighCouponAgentCodeMapper;
import com.hai.dao.HighCouponAgentRelMapper; import com.hai.dao.HighCouponAgentRelMapper;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.model.AgentSalesModel;
import com.hai.service.HighCouponAgentService; import com.hai.service.HighCouponAgentService;
import com.hai.service.HighCouponCodeService; import com.hai.service.HighCouponCodeService;
import com.hai.service.HighCouponService; import com.hai.service.HighCouponService;
@ -17,10 +19,8 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date; import java.math.BigDecimal;
import java.util.HashMap; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -168,4 +168,44 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
map.put("couponAgentCode", couponAgentCode); map.put("couponAgentCode", couponAgentCode);
return map; return map;
} }
@Override
public Map<String, Object> getSalesCountByAgent(Long agentId) throws Exception {
BigDecimal surplusCountPrice = new BigDecimal("0");
BigDecimal salesCountPrice = new BigDecimal("0");
Map<String,Object> listMap = new HashMap<>();
listMap.put("agentId", agentId);
List<HighCouponAgentRel> list = getCouponAgentList(listMap);
for (HighCouponAgentRel highCouponAgentRel : list) {
BigDecimal surplusPrice = new BigDecimal(highCouponAgentRel.getStockCount()).multiply((highCouponAgentRel.getSalesPrice()));
surplusCountPrice = surplusCountPrice.add(surplusPrice);
BigDecimal salesPrice = new BigDecimal(highCouponAgentRel.getStockCount()).multiply((highCouponAgentRel.getSalesPrice()));
surplusCountPrice = surplusCountPrice.add(salesPrice);
}
// 计算使用有效期
Calendar consumeTimeS = Calendar.getInstance();
consumeTimeS.setTime(new Date());
consumeTimeS.set(Calendar.HOUR_OF_DAY, 00);
consumeTimeS.set(Calendar.MINUTE, 00);
consumeTimeS.set(Calendar.SECOND, 00);
Calendar consumeTimeE = Calendar.getInstance();
consumeTimeS.setTime(new Date());
consumeTimeS.set(Calendar.HOUR_OF_DAY, 23);
consumeTimeS.set(Calendar.MINUTE, 59);
consumeTimeS.set(Calendar.SECOND, 59);
AgentSalesModel agentSales = highCouponAgentRelMapper.getAgentSales(agentId, DateUtil.date2String(consumeTimeS.getTime(), "yyyy-MM-dd HH:mm:ss"), DateUtil.date2String(consumeTimeE.getTime(), "yyyy-MM-dd HH:mm:ss"));
Map<String, Object> returnMap = new HashMap<>();
returnMap.put("orderCount", agentSales.getCount());
returnMap.put("turnoverPrice", agentSales.getSalesCountPrice());
returnMap.put("surplusCountPrice", surplusCountPrice); // 剩余总额
returnMap.put("salesCountPrice", salesCountPrice); // 销售总额
returnMap.put("list", list);
return returnMap;
}
} }

Loading…
Cancel
Save