From 82e27c00626cda2ecb78485a3086436e4f0d1ee9 Mon Sep 17 00:00:00 2001 From: 199901012 Date: Thu, 22 Apr 2021 00:30:07 +0800 Subject: [PATCH 1/4] =?UTF-8?q?'=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hai/service/impl/HighCouponAgentServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 2ed2bb97..9a93f744 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 @@ -62,7 +62,7 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { highCouponAgentRelMapper.insert(highCouponAgentRel); - List assignCouponCodeList = codeList.stream().limit(highCouponAgentRel.getStatus()).collect(Collectors.toList()); + List assignCouponCodeList = codeList.stream().limit(highCouponAgentRel.getStockCount()).collect(Collectors.toList()); HighCouponAgentCode highCouponAgentCode; for (HighCouponCode code : assignCouponCodeList) { code.setAgentId(highCouponAgentRel.getAgentId()); From fb9de099ac1343d0e4627481e3c2598b8a3565ab Mon Sep 17 00:00:00 2001 From: 199901012 Date: Thu, 22 Apr 2021 23:52:42 +0800 Subject: [PATCH 2/4] =?UTF-8?q?'=E6=8F=90=E4=BA=A4diam'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HighCouponAgentController.java | 8 ++- .../com/hai/dao/HighCouponAgentRelMapper.java | 23 +++---- .../hai/dao/HighCouponAgentRelMapperExt.java | 16 ++++- .../dao/HighCouponAgentRelSqlProvider.java | 14 +++++ .../com/hai/entity/HighCouponAgentRel.java | 16 +++++ .../hai/entity/HighCouponAgentRelExample.java | 60 +++++++++++++++++++ .../java/com/hai/model/AgentSalesModel.java | 31 ++++++++++ .../hai/service/HighCouponAgentService.java | 7 +++ .../impl/HighCouponAgentServiceImpl.java | 48 +++++++++++++-- 9 files changed, 205 insertions(+), 18 deletions(-) create mode 100644 hai-service/src/main/java/com/hai/model/AgentSalesModel.java diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java index 34462404..ce3cd643 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java @@ -69,10 +69,12 @@ public class HighCouponAgentController { SessionObject sessionObject = userCenter.getSessionObject(request); UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); - Map map = new HashMap<>(); - map.put("", ""); + if (userInfoModel.getHighAgent() == null) { + 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) { log.error("HighCouponAgentController --> getCodeById() error!", e); diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapper.java b/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapper.java index 9afd9bf1..a166f0ee 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapper.java @@ -41,16 +41,16 @@ public interface HighCouponAgentRelMapper extends HighCouponAgentRelMapperExt { @Insert({ "insert into high_coupon_agent_rel (coupon_name, sales_price, ", "coupon_id, agent_id, ", - "stock_count, create_time, ", - "`status`, operator_id, ", - "operator_name, ext_1, ", - "ext_2, ext_3)", + "stock_count, sales_count, ", + "create_time, `status`, ", + "operator_id, operator_name, ", + "ext_1, ext_2, ext_3)", "values (#{couponName,jdbcType=VARCHAR}, #{salesPrice,jdbcType=DECIMAL}, ", "#{couponId,jdbcType=BIGINT}, #{agentId,jdbcType=BIGINT}, ", - "#{stockCount,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ", - "#{status,jdbcType=INTEGER}, #{operatorId,jdbcType=BIGINT}, ", - "#{operatorName,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR}, ", - "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" + "#{stockCount,jdbcType=INTEGER}, #{salesCount,jdbcType=INTEGER}, ", + "#{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, ", + "#{operatorId,jdbcType=BIGINT}, #{operatorName,jdbcType=VARCHAR}, ", + "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(HighCouponAgentRel record); @@ -67,6 +67,7 @@ public interface HighCouponAgentRelMapper extends HighCouponAgentRelMapperExt { @Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT), @Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT), @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="status", property="status", jdbcType=JdbcType.INTEGER), @Result(column="operator_id", property="operatorId", jdbcType=JdbcType.BIGINT), @@ -79,8 +80,8 @@ public interface HighCouponAgentRelMapper extends HighCouponAgentRelMapperExt { @Select({ "select", - "id, coupon_name, sales_price, coupon_id, agent_id, stock_count, create_time, ", - "`status`, operator_id, operator_name, ext_1, ext_2, ext_3", + "id, coupon_name, sales_price, coupon_id, agent_id, stock_count, sales_count, ", + "create_time, `status`, operator_id, operator_name, ext_1, ext_2, ext_3", "from high_coupon_agent_rel", "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="agent_id", property="agentId", jdbcType=JdbcType.BIGINT), @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="status", property="status", jdbcType=JdbcType.INTEGER), @Result(column="operator_id", property="operatorId", jdbcType=JdbcType.BIGINT), @@ -117,6 +119,7 @@ public interface HighCouponAgentRelMapper extends HighCouponAgentRelMapperExt { "coupon_id = #{couponId,jdbcType=BIGINT},", "agent_id = #{agentId,jdbcType=BIGINT},", "stock_count = #{stockCount,jdbcType=INTEGER},", + "sales_count = #{salesCount,jdbcType=INTEGER},", "create_time = #{createTime,jdbcType=TIMESTAMP},", "`status` = #{status,jdbcType=INTEGER},", "operator_id = #{operatorId,jdbcType=BIGINT},", 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 2af8f271..c58dafcd 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapperExt.java @@ -1,7 +1,21 @@ 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扩展类 */ public interface HighCouponAgentRelMapperExt { -} \ No newline at end of file + + + @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); +} diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelSqlProvider.java index 6ee52b00..7783432a 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelSqlProvider.java @@ -48,6 +48,10 @@ public class HighCouponAgentRelSqlProvider { sql.VALUES("stock_count", "#{stockCount,jdbcType=INTEGER}"); } + if (record.getSalesCount() != null) { + sql.VALUES("sales_count", "#{salesCount,jdbcType=INTEGER}"); + } + if (record.getCreateTime() != null) { sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}"); } @@ -91,6 +95,7 @@ public class HighCouponAgentRelSqlProvider { sql.SELECT("coupon_id"); sql.SELECT("agent_id"); sql.SELECT("stock_count"); + sql.SELECT("sales_count"); sql.SELECT("create_time"); sql.SELECT("`status`"); sql.SELECT("operator_id"); @@ -139,6 +144,10 @@ public class HighCouponAgentRelSqlProvider { sql.SET("stock_count = #{record.stockCount,jdbcType=INTEGER}"); } + if (record.getSalesCount() != null) { + sql.SET("sales_count = #{record.salesCount,jdbcType=INTEGER}"); + } + if (record.getCreateTime() != null) { 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("agent_id = #{record.agentId,jdbcType=BIGINT}"); 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("`status` = #{record.status,jdbcType=INTEGER}"); sql.SET("operator_id = #{record.operatorId,jdbcType=BIGINT}"); @@ -218,6 +228,10 @@ public class HighCouponAgentRelSqlProvider { sql.SET("stock_count = #{stockCount,jdbcType=INTEGER}"); } + if (record.getSalesCount() != null) { + sql.SET("sales_count = #{salesCount,jdbcType=INTEGER}"); + } + if (record.getCreateTime() != null) { sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}"); } diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponAgentRel.java b/hai-service/src/main/java/com/hai/entity/HighCouponAgentRel.java index d7efdce4..78f33d29 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponAgentRel.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponAgentRel.java @@ -46,6 +46,11 @@ public class HighCouponAgentRel extends HighCouponAgentRelModel implements Seria */ private Integer stockCount; + /** + * 销售数量 + */ + private Integer salesCount; + /** * 创建时间 */ @@ -122,6 +127,14 @@ public class HighCouponAgentRel extends HighCouponAgentRelModel implements Seria this.stockCount = stockCount; } + public Integer getSalesCount() { + return salesCount; + } + + public void setSalesCount(Integer salesCount) { + this.salesCount = salesCount; + } + public Date getCreateTime() { 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.getAgentId() == null ? other.getAgentId() == null : this.getAgentId().equals(other.getAgentId())) && (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.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) && (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 + ((getAgentId() == null) ? 0 : getAgentId().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 + ((getStatus() == null) ? 0 : getStatus().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(", agentId=").append(agentId); sb.append(", stockCount=").append(stockCount); + sb.append(", salesCount=").append(salesCount); sb.append(", createTime=").append(createTime); sb.append(", status=").append(status); sb.append(", operatorId=").append(operatorId); diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponAgentRelExample.java b/hai-service/src/main/java/com/hai/entity/HighCouponAgentRelExample.java index c27d627a..3d82ecff 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponAgentRelExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponAgentRelExample.java @@ -496,6 +496,66 @@ public class HighCouponAgentRelExample { 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 values) { + addCriterion("sales_count in", values, "salesCount"); + return (Criteria) this; + } + + public Criteria andSalesCountNotIn(List 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() { addCriterion("create_time is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/model/AgentSalesModel.java b/hai-service/src/main/java/com/hai/model/AgentSalesModel.java new file mode 100644 index 00000000..0c5ab5a7 --- /dev/null +++ b/hai-service/src/main/java/com/hai/model/AgentSalesModel.java @@ -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; + } +} diff --git a/hai-service/src/main/java/com/hai/service/HighCouponAgentService.java b/hai-service/src/main/java/com/hai/service/HighCouponAgentService.java index 8a4eb7f8..ec058098 100644 --- a/hai-service/src/main/java/com/hai/service/HighCouponAgentService.java +++ b/hai-service/src/main/java/com/hai/service/HighCouponAgentService.java @@ -55,4 +55,11 @@ public interface HighCouponAgentService { * @Date 2021/4/21 22:35 **/ Map generateCode(Long couponAgentCodeId); + + /** + * @Author 胡锐 + * @Description 根据代理商 查询销售统计 + * @Date 2021/4/22 22:26 + **/ + Map getSalesCountByAgent(Long agentId) throws Exception; } 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 9a93f744..5b2432a0 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 @@ -4,10 +4,12 @@ import com.github.pagehelper.PageInfo; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; +import com.hai.common.utils.DateUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.dao.HighCouponAgentCodeMapper; import com.hai.dao.HighCouponAgentRelMapper; import com.hai.entity.*; +import com.hai.model.AgentSalesModel; import com.hai.service.HighCouponAgentService; import com.hai.service.HighCouponCodeService; import com.hai.service.HighCouponService; @@ -17,10 +19,8 @@ import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.math.BigDecimal; +import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -168,4 +168,44 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { map.put("couponAgentCode", couponAgentCode); return map; } + + @Override + public Map getSalesCountByAgent(Long agentId) throws Exception { + BigDecimal surplusCountPrice = new BigDecimal("0"); + BigDecimal salesCountPrice = new BigDecimal("0"); + + Map listMap = new HashMap<>(); + listMap.put("agentId", agentId); + List 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 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; + } } From 378f2579de7473ca6004a6557ebb38407b7f65a2 Mon Sep 17 00:00:00 2001 From: 199901012 Date: Fri, 23 Apr 2021 00:45:16 +0800 Subject: [PATCH 3/4] =?UTF-8?q?'=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HighCouponAgentController.java | 4 +++- .../hai/dao/HighCouponAgentRelMapperExt.java | 4 +++- .../hai/model/HighCouponAgentCodeModel.java | 10 ++++++++ .../hai/model/HighCouponAgentRelModel.java | 10 ++++++++ .../impl/HighCouponAgentServiceImpl.java | 23 +++++++++++++++---- 5 files changed, 45 insertions(+), 6 deletions(-) diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java index ce3cd643..5623dfb8 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java @@ -124,6 +124,7 @@ public class HighCouponAgentController { highCouponAgentRel.setCouponName(coupon.getCouponName()); highCouponAgentRel.setSalesPrice(coupon.getSalesPrice()); highCouponAgentRel.setStatus(1); // 状态 0:删除 1:正常 + highCouponAgentRel.setSalesCount(0); highCouponAgentRel.setCreateTime(new Date()); highCouponAgentRel.setOperatorId(userInfoModel.getSecUser().getId()); highCouponAgentRel.setOperatorName(userInfoModel.getSecUser().getUserName()); @@ -203,7 +204,7 @@ public class HighCouponAgentController { @ResponseBody @ApiOperation(value = "根据代理商和卡券 查询分配的销售码") public ResponseData getCodeListByAgentCoupon(@RequestParam(name = "couponId", required = true) Long couponId, - @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "status", required = false) String status, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { @@ -226,6 +227,7 @@ public class HighCouponAgentController { if (pageInfo.getList().size() > 0) { HighCoupon coupon = highCouponService.getCouponDetail(couponId); for (HighCouponAgentCode code : pageInfo.getList()) { + code.setMerchantLogo(code.getMerchantLogo()); code.setMerchantName(coupon.getMerchantName()); code.setHighCoupon(coupon); code.setHighCouponCode(highCouponCodeService.getCouponCodeById(code.getCouponCodeId())); 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 c58dafcd..c94fb2ad 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapperExt.java @@ -4,7 +4,6 @@ import com.hai.model.AgentSalesModel; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; -import java.util.Map; /** * mapper扩展类 @@ -18,4 +17,7 @@ public interface HighCouponAgentRelMapperExt { " 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); + + @Select(" select count(1) from high_coupon_agent_code a where a.agent_id = #{agentId} and a.`status` in (#{status}) ") + Integer getAgentCodeCount(@Param("agentId") Long agentId,@Param("status") String status); } diff --git a/hai-service/src/main/java/com/hai/model/HighCouponAgentCodeModel.java b/hai-service/src/main/java/com/hai/model/HighCouponAgentCodeModel.java index 5f188282..b9941708 100644 --- a/hai-service/src/main/java/com/hai/model/HighCouponAgentCodeModel.java +++ b/hai-service/src/main/java/com/hai/model/HighCouponAgentCodeModel.java @@ -16,6 +16,8 @@ public class HighCouponAgentCodeModel { // 商户名称 private String merchantName; + private String merchantLogo; + // 卡券 private HighCoupon highCoupon; @@ -30,6 +32,14 @@ public class HighCouponAgentCodeModel { this.merchantName = merchantName; } + public String getMerchantLogo() { + return merchantLogo; + } + + public void setMerchantLogo(String merchantLogo) { + this.merchantLogo = merchantLogo; + } + public HighCoupon getHighCoupon() { return highCoupon; } 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 88bb8261..8c9cd0ac 100644 --- a/hai-service/src/main/java/com/hai/model/HighCouponAgentRelModel.java +++ b/hai-service/src/main/java/com/hai/model/HighCouponAgentRelModel.java @@ -10,12 +10,22 @@ import com.hai.entity.HighCoupon; */ public class HighCouponAgentRelModel { + private String merchantLogo; + // 卡券信息 private HighCoupon highCoupon; //代理商信息 private HighAgent highAgent; + public String getMerchantLogo() { + return merchantLogo; + } + + public void setMerchantLogo(String merchantLogo) { + this.merchantLogo = merchantLogo; + } + public HighCoupon getHighCoupon() { return highCoupon; } 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 5b2432a0..2cfef2e5 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 @@ -14,6 +14,7 @@ import com.hai.service.HighCouponAgentService; import com.hai.service.HighCouponCodeService; import com.hai.service.HighCouponService; import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @@ -130,8 +131,13 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { criteria.andAgentIdEqualTo(MapUtils.getLong(map, "agentId")); } - if (MapUtils.getInteger(map, "status") != null) { - criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); + if (StringUtils.isNotBlank(MapUtils.getString(map, "status"))) { + String[] strings = MapUtils.getString(map, "status").split(","); + List statusList = new ArrayList<>(); + for (String i : strings) { + statusList.add(Integer.parseInt(i)); + } + criteria.andStatusIn(statusList); } example.setOrderByClause("create_time desc"); @@ -157,6 +163,11 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { couponAgentCode.setStatus(2); // 状态:1.待销售 2.未使用 3.已使用 highCouponAgentCodeMapper.updateByPrimaryKey(couponAgentCode); + HighCouponAgentRel couponAgent = getRelByCouponAgent(couponAgentCode.getCouponId(), couponAgentCode.getAgentId()); + couponAgent.setStockCount(couponAgent.getStockCount() - 1); + couponAgent.setSalesCount(couponAgent.getSalesCount() + 1); + highCouponAgentRelMapper.updateByPrimaryKey(couponAgent); + HighCouponCode couponCode = highCouponCodeService.getCouponCodeById(couponAgentCode.getCouponCodeId()); couponCode.setStatus(2); couponCode.setReceiveTime(new Date()); @@ -181,8 +192,8 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { 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); + BigDecimal salesPrice = new BigDecimal(highCouponAgentRel.getSalesCount()).multiply((highCouponAgentRel.getSalesPrice())); + salesCountPrice = salesCountPrice.add(salesPrice); } // 计算使用有效期 @@ -203,6 +214,10 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { Map returnMap = new HashMap<>(); returnMap.put("orderCount", agentSales.getCount()); returnMap.put("turnoverPrice", agentSales.getSalesCountPrice()); + + returnMap.put("laveStockCount", highCouponAgentRelMapper.getAgentCodeCount(agentId, "1")); // 库存数量 + returnMap.put("soldCount", highCouponAgentRelMapper.getAgentCodeCount(agentId, "2,3")); // 销售数量 + returnMap.put("surplusCountPrice", surplusCountPrice); // 剩余总额 returnMap.put("salesCountPrice", salesCountPrice); // 销售总额 returnMap.put("list", list); From 230e0fc0051d6a8fd77b1c2596c9c5e52dabadca Mon Sep 17 00:00:00 2001 From: 199901012 Date: Fri, 23 Apr 2021 00:55:44 +0800 Subject: [PATCH 4/4] =?UTF-8?q?'=E6=8F=90=E4=BA=A4diam'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HighCouponAgentController.java | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java index 5623dfb8..a7d1081a 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java @@ -11,12 +11,10 @@ import com.hai.common.security.UserCenter; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.*; import com.hai.model.HighAgentModel; +import com.hai.model.HighMerchantModel; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; -import com.hai.service.HighAgentService; -import com.hai.service.HighCouponAgentService; -import com.hai.service.HighCouponCodeService; -import com.hai.service.HighCouponService; +import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; @@ -54,6 +52,9 @@ public class HighCouponAgentController { @Resource private HighCouponCodeService highCouponCodeService; + @Resource + private HighMerchantService highMerchantService; + @Autowired private UserCenter userCenter; @@ -142,20 +143,13 @@ public class HighCouponAgentController { @RequestMapping(value = "/getCouponByAgent", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据代理商 查询卡券") - public ResponseData getCouponByAgent(@RequestParam(name = "pageNum", required = true) Integer pageNum, + public ResponseData getCouponByAgent(@RequestParam(name = "agentId", required = true) Long agentId, + @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { - //发布人员 - SessionObject sessionObject = userCenter.getSessionObject(request); - UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); - if (userInfoModel.getHighAgent() == null) { - log.error("HighCouponAgentController -> getCouponByAgent() error!","该角色没有权限"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "该角色没有权限"); - } - Map map = new HashMap<>(); - map.put("agentId", userInfoModel.getHighAgent().getId()); + map.put("agentId", agentId); PageHelper.startPage(pageNum,pageSize); PageInfo pageInfo = new PageInfo<>(highCouponAgentService.getCouponAgentList(map)); @@ -225,11 +219,15 @@ public class HighCouponAgentController { PageHelper.startPage(pageNum,pageSize); PageInfo pageInfo = new PageInfo<>(highCouponAgentService.getCouponCodeList(map)); if (pageInfo.getList().size() > 0) { - HighCoupon coupon = highCouponService.getCouponDetail(couponId); + HighMerchant merchant = new HighMerchant(); + HighCoupon highCoupon = highCouponService.getCouponById(couponId); + if (highCoupon != null) { + merchant = highMerchantService.getMerchantById(highCoupon.getMerchantId()); + } for (HighCouponAgentCode code : pageInfo.getList()) { - code.setMerchantLogo(code.getMerchantLogo()); - code.setMerchantName(coupon.getMerchantName()); - code.setHighCoupon(coupon); + code.setMerchantLogo(merchant.getMerchantLogo()); + code.setMerchantName(merchant.getMerchantName()); + code.setHighCoupon(highCoupon); code.setHighCouponCode(highCouponCodeService.getCouponCodeById(code.getCouponCodeId())); } }