提交代码

new-dev
胡锐 2 years ago
parent 83a6d1561f
commit 25916061ec
  1. 100
      hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentBatchController.java
  2. 46
      hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java
  3. 15
      hai-bweb/src/main/java/com/bweb/controller/HighDiscountController.java
  4. 155
      hai-service/src/main/java/com/hai/dao/HighDiscountAgentBatchMapper.java
  5. 53
      hai-service/src/main/java/com/hai/dao/HighDiscountAgentBatchMapperExt.java
  6. 430
      hai-service/src/main/java/com/hai/dao/HighDiscountAgentBatchSqlProvider.java
  7. 20
      hai-service/src/main/java/com/hai/dao/HighDiscountAgentCodeMapper.java
  8. 14
      hai-service/src/main/java/com/hai/dao/HighDiscountAgentCodeSqlProvider.java
  9. 345
      hai-service/src/main/java/com/hai/entity/HighDiscountAgentBatch.java
  10. 1444
      hai-service/src/main/java/com/hai/entity/HighDiscountAgentBatchExample.java
  11. 20
      hai-service/src/main/java/com/hai/entity/HighDiscountAgentCode.java
  12. 60
      hai-service/src/main/java/com/hai/entity/HighDiscountAgentCodeExample.java
  13. 40
      hai-service/src/main/java/com/hai/service/HighDiscountAgentBatchService.java
  14. 7
      hai-service/src/main/java/com/hai/service/HighDiscountAgentRelService.java
  15. 3
      hai-service/src/main/java/com/hai/service/HighDiscountService.java
  16. 55
      hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentBatchServiceImpl.java
  17. 39
      hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentRelServiceImpl.java
  18. 15
      hai-service/src/main/java/com/hai/service/impl/HighDiscountServiceImpl.java

@ -0,0 +1,100 @@
package com.bweb.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSONObject;
import com.bweb.config.SysConst;
import com.github.pagehelper.PageHelper;
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.security.AESEncodeUtil;
import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.CommonSysConst;
import com.hai.entity.*;
import com.hai.model.DiscountUseConditionModel;
import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel;
import com.hai.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @Auther: 胡锐
* @Description:
* @Date: 2021/4/4 00:19
*/
@Controller
@RequestMapping(value = "/discountAgentBatch")
@Api(value = "优惠券和代理商接口")
public class HighDiscountAgentBatchController {
private static Logger log = LoggerFactory.getLogger(HighDiscountAgentBatchController.class);
@Resource
private HighDiscountAgentBatchService highDiscountAgentBatchService;
@RequestMapping(value="/replenish",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "批次补充")
public ResponseData replenish(@RequestBody JSONObject jsonObject) {
try {
String batchIdentifier = jsonObject.getString("batchIdentifier");
Long mailTime = jsonObject.getLong("mailTime");
Integer batchNum = jsonObject.getInteger("batchNum");
if (StringUtils.isBlank(batchIdentifier)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 查询数据
HighDiscountAgentBatch batch = highDiscountAgentBatchService.getBatchByIdentifier(batchIdentifier);
if (batch == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "批次不存在");
}
if (mailTime != null) {
batch.setMailTime(new Date(mailTime));
}
if (batchNum != null) {
batch.setBatchNum(batch.getBatchNum().intValue() + batchNum);
}
highDiscountAgentBatchService.editData(batch);
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("HighDiscountAgentBatchController -> replenish() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getBatchDetail",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询批次详情")
public ResponseData getBatchDetail(@RequestParam(name = "batchIdentifier", required = true) String batchIdentifier) {
try {
return ResponseMsgUtil.success(highDiscountAgentBatchService.getBatchByIdentifier(batchIdentifier));
} catch (Exception e) {
log.error("HighDiscountController -> getBatchDetail() error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -39,6 +39,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.Date;
import java.util.HashMap;
@ -75,6 +76,9 @@ public class HighDiscountAgentRelController {
@Resource
private HighOrderService highOrderService;
@Resource
private HighDiscountAgentBatchService highDiscountAgentBatchService;
@RequestMapping(value="/insertDiscountAgent",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "分配优惠券给代理商")
@ -110,9 +114,11 @@ public class HighDiscountAgentRelController {
HighDiscountAgentRel discountAgent = highDiscountAgentRelService.getRelByDiscountAgent(highDiscountAgentRel.getDiscountId(), highDiscountAgentRel.getAgentId());
// 是否已分配
if (discountAgent != null) {
discountAgent.setHighDiscount(discount);
discountAgent.setStockCount(discountAgent.getStockCount() + highDiscountAgentRel.getStockCount());
highDiscountAgentRelService.insertDiscountAgentRel(discountAgent,highDiscountAgentRel.getStockCount());
} else {
highDiscountAgentRel.setHighDiscount(discount);
highDiscountAgentRel.setCreateTime(new Date());
highDiscountAgentRel.setStatus(1);
highDiscountAgentRelService.insertDiscountAgentRel(highDiscountAgentRel,highDiscountAgentRel.getStockCount());
@ -380,4 +386,44 @@ public class HighDiscountAgentRelController {
}
}
@RequestMapping(value="/getBatchUseCount",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询优惠券使用统计")
public ResponseData getBatchUseCount(@RequestParam(name = "usingRange", required = false) Integer usingRange,
@RequestParam(name = "price", required = false) BigDecimal price,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize) {
try {
Map<String,Object> param = new HashMap<>();
param.put("usingRange", usingRange);
param.put("price", price);
PageHelper.startPage(pageNum, pageSize);
return ResponseMsgUtil.success(new PageInfo<>(highDiscountAgentBatchService.getUsageCount(param)));
} catch (Exception e) {
log.error("HighDiscountController -> getBatchUseCount() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getCount",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询统计")
public ResponseData getCount(@RequestParam(name = "usingRange", required = false) Integer usingRange,
@RequestParam(name = "price", required = false) BigDecimal price) {
try {
Map<String,Object> param = new HashMap<>();
param.put("usingRange", usingRange);
param.put("price", price);
return ResponseMsgUtil.success(highDiscountAgentBatchService.getCount(param));
} catch (Exception e) {
log.error("HighDiscountController -> getCount() error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -190,7 +190,6 @@ public class HighDiscountController {
@RequestMapping(value="/getDiscountList",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询优惠券列表")
public ResponseData getDiscountList(@RequestParam(name = "discountKey", required = false) String discountKey,
@RequestParam(name = "discountName", required = false) String discountName,
@ -221,4 +220,18 @@ public class HighDiscountController {
}
}
@RequestMapping(value="/getDiscountPrice",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询优惠券金额")
public ResponseData getDiscountPrice(@RequestParam(name = "usingRange", required = true) Integer usingRange) {
try {
return ResponseMsgUtil.success(highDiscountService.getDiscountPrice(usingRange));
} catch (Exception e) {
log.error("HighDiscountController -> getDiscountPrice() error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -0,0 +1,155 @@
package com.hai.dao;
import com.hai.entity.HighDiscountAgentBatch;
import com.hai.entity.HighDiscountAgentBatchExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;
/**
*
* 代码由工具生成,请勿修改!!!
* 如果需要扩展请在其父类进行扩展
*
**/
@Repository
public interface HighDiscountAgentBatchMapper extends HighDiscountAgentBatchMapperExt {
@SelectProvider(type=HighDiscountAgentBatchSqlProvider.class, method="countByExample")
long countByExample(HighDiscountAgentBatchExample example);
@DeleteProvider(type=HighDiscountAgentBatchSqlProvider.class, method="deleteByExample")
int deleteByExample(HighDiscountAgentBatchExample example);
@Delete({
"delete from high_discount_agent_batch",
"where id = #{id,jdbcType=BIGINT}"
})
int deleteByPrimaryKey(Long id);
@Insert({
"insert into high_discount_agent_batch (discount_agent_id, discount_id, ",
"discount_name, discount_price, ",
"using_range, use_scope, ",
"agent_id, batch_identifier, ",
"batch_num, code_start, ",
"code_end, mail_time, ",
"create_time, `status`, ",
"qr_code, ext_1, ext_2, ",
"ext_3)",
"values (#{discountAgentId,jdbcType=BIGINT}, #{discountId,jdbcType=BIGINT}, ",
"#{discountName,jdbcType=VARCHAR}, #{discountPrice,jdbcType=DECIMAL}, ",
"#{usingRange,jdbcType=INTEGER}, #{useScope,jdbcType=INTEGER}, ",
"#{agentId,jdbcType=BIGINT}, #{batchIdentifier,jdbcType=VARCHAR}, ",
"#{batchNum,jdbcType=INTEGER}, #{codeStart,jdbcType=VARCHAR}, ",
"#{codeEnd,jdbcType=VARCHAR}, #{mailTime,jdbcType=TIMESTAMP}, ",
"#{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, ",
"#{qrCode,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, ",
"#{ext3,jdbcType=VARCHAR})"
})
@Options(useGeneratedKeys=true,keyProperty="id")
int insert(HighDiscountAgentBatch record);
@InsertProvider(type=HighDiscountAgentBatchSqlProvider.class, method="insertSelective")
@Options(useGeneratedKeys=true,keyProperty="id")
int insertSelective(HighDiscountAgentBatch record);
@SelectProvider(type=HighDiscountAgentBatchSqlProvider.class, method="selectByExample")
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="discount_agent_id", property="discountAgentId", jdbcType=JdbcType.BIGINT),
@Result(column="discount_id", property="discountId", jdbcType=JdbcType.BIGINT),
@Result(column="discount_name", property="discountName", jdbcType=JdbcType.VARCHAR),
@Result(column="discount_price", property="discountPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="using_range", property="usingRange", jdbcType=JdbcType.INTEGER),
@Result(column="use_scope", property="useScope", jdbcType=JdbcType.INTEGER),
@Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT),
@Result(column="batch_identifier", property="batchIdentifier", jdbcType=JdbcType.VARCHAR),
@Result(column="batch_num", property="batchNum", jdbcType=JdbcType.INTEGER),
@Result(column="code_start", property="codeStart", jdbcType=JdbcType.VARCHAR),
@Result(column="code_end", property="codeEnd", jdbcType=JdbcType.VARCHAR),
@Result(column="mail_time", property="mailTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="qr_code", property="qrCode", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR)
})
List<HighDiscountAgentBatch> selectByExample(HighDiscountAgentBatchExample example);
@Select({
"select",
"id, discount_agent_id, discount_id, discount_name, discount_price, using_range, ",
"use_scope, agent_id, batch_identifier, batch_num, code_start, code_end, mail_time, ",
"create_time, `status`, qr_code, ext_1, ext_2, ext_3",
"from high_discount_agent_batch",
"where id = #{id,jdbcType=BIGINT}"
})
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="discount_agent_id", property="discountAgentId", jdbcType=JdbcType.BIGINT),
@Result(column="discount_id", property="discountId", jdbcType=JdbcType.BIGINT),
@Result(column="discount_name", property="discountName", jdbcType=JdbcType.VARCHAR),
@Result(column="discount_price", property="discountPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="using_range", property="usingRange", jdbcType=JdbcType.INTEGER),
@Result(column="use_scope", property="useScope", jdbcType=JdbcType.INTEGER),
@Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT),
@Result(column="batch_identifier", property="batchIdentifier", jdbcType=JdbcType.VARCHAR),
@Result(column="batch_num", property="batchNum", jdbcType=JdbcType.INTEGER),
@Result(column="code_start", property="codeStart", jdbcType=JdbcType.VARCHAR),
@Result(column="code_end", property="codeEnd", jdbcType=JdbcType.VARCHAR),
@Result(column="mail_time", property="mailTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="qr_code", property="qrCode", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR)
})
HighDiscountAgentBatch selectByPrimaryKey(Long id);
@UpdateProvider(type=HighDiscountAgentBatchSqlProvider.class, method="updateByExampleSelective")
int updateByExampleSelective(@Param("record") HighDiscountAgentBatch record, @Param("example") HighDiscountAgentBatchExample example);
@UpdateProvider(type=HighDiscountAgentBatchSqlProvider.class, method="updateByExample")
int updateByExample(@Param("record") HighDiscountAgentBatch record, @Param("example") HighDiscountAgentBatchExample example);
@UpdateProvider(type=HighDiscountAgentBatchSqlProvider.class, method="updateByPrimaryKeySelective")
int updateByPrimaryKeySelective(HighDiscountAgentBatch record);
@Update({
"update high_discount_agent_batch",
"set discount_agent_id = #{discountAgentId,jdbcType=BIGINT},",
"discount_id = #{discountId,jdbcType=BIGINT},",
"discount_name = #{discountName,jdbcType=VARCHAR},",
"discount_price = #{discountPrice,jdbcType=DECIMAL},",
"using_range = #{usingRange,jdbcType=INTEGER},",
"use_scope = #{useScope,jdbcType=INTEGER},",
"agent_id = #{agentId,jdbcType=BIGINT},",
"batch_identifier = #{batchIdentifier,jdbcType=VARCHAR},",
"batch_num = #{batchNum,jdbcType=INTEGER},",
"code_start = #{codeStart,jdbcType=VARCHAR},",
"code_end = #{codeEnd,jdbcType=VARCHAR},",
"mail_time = #{mailTime,jdbcType=TIMESTAMP},",
"create_time = #{createTime,jdbcType=TIMESTAMP},",
"`status` = #{status,jdbcType=INTEGER},",
"qr_code = #{qrCode,jdbcType=VARCHAR},",
"ext_1 = #{ext1,jdbcType=VARCHAR},",
"ext_2 = #{ext2,jdbcType=VARCHAR},",
"ext_3 = #{ext3,jdbcType=VARCHAR}",
"where id = #{id,jdbcType=BIGINT}"
})
int updateByPrimaryKey(HighDiscountAgentBatch record);
}

@ -0,0 +1,53 @@
package com.hai.dao;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
/**
* mapper扩展类
*/
public interface HighDiscountAgentBatchMapperExt {
@Select("<script>" +
" select a.*," +
" ROUND((a.useNum / a.batchNum) * 100, 2) useRate" +
" from (select " +
" a.batch_identifier batchIdentifier," +
" a.discount_name discountName," +
" a.discount_price discountPrice," +
" a.using_range discountUsingRange," +
" a.code_start codeStart," +
" a.code_end codeEnd," +
" a.create_time createTime," +
" a.mail_time mailTime," +
" a.batch_num batchNum," +
" (select count(1) from high_discount_agent_code where discount_agent_batch_id = a.id and `status` in (2,3)) useNum" +
" from high_discount_agent_batch a where 1 = 1" +
" <if test='param.usingRange != null'> and a.using_range = #{param.usingRange} </if>" +
" <if test='param.price != null'> and a.discount_price = #{param.price} </if>" +
") a" +
"</script>")
List<Map<String,Object>> queryUsageCount(@Param("param") Map<String,Object> param);
@Select("<script>" +
" select" +
" sum(a.batchNum) batchNum," +
" sum(a.useNum) useNum," +
" sum((a.useNum * a.discountPrice)) usePrice," +
" ROUND(sum(a.useNum) / sum(a.batchNum) * 100, 2) useRate" +
" from (select " +
" a.discount_price discountPrice," +
" a.using_range discountUsingRange," +
" a.batch_num batchNum," +
" (select count(1) from high_discount_agent_code where discount_agent_batch_id = a.id and `status` in (2,3)) useNum" +
" from high_discount_agent_batch a where 1 = 1" +
" <if test='param.usingRange != null'> and a.using_range = #{param.usingRange} </if>" +
" <if test='param.price != null'> and a.discount_price = #{param.price} </if>" +
" ) a " +
"</script>")
Map<String,Object> queryCount(@Param("param") Map<String,Object> param);
}

@ -0,0 +1,430 @@
package com.hai.dao;
import com.hai.entity.HighDiscountAgentBatch;
import com.hai.entity.HighDiscountAgentBatchExample.Criteria;
import com.hai.entity.HighDiscountAgentBatchExample.Criterion;
import com.hai.entity.HighDiscountAgentBatchExample;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.jdbc.SQL;
public class HighDiscountAgentBatchSqlProvider {
public String countByExample(HighDiscountAgentBatchExample example) {
SQL sql = new SQL();
sql.SELECT("count(*)").FROM("high_discount_agent_batch");
applyWhere(sql, example, false);
return sql.toString();
}
public String deleteByExample(HighDiscountAgentBatchExample example) {
SQL sql = new SQL();
sql.DELETE_FROM("high_discount_agent_batch");
applyWhere(sql, example, false);
return sql.toString();
}
public String insertSelective(HighDiscountAgentBatch record) {
SQL sql = new SQL();
sql.INSERT_INTO("high_discount_agent_batch");
if (record.getDiscountAgentId() != null) {
sql.VALUES("discount_agent_id", "#{discountAgentId,jdbcType=BIGINT}");
}
if (record.getDiscountId() != null) {
sql.VALUES("discount_id", "#{discountId,jdbcType=BIGINT}");
}
if (record.getDiscountName() != null) {
sql.VALUES("discount_name", "#{discountName,jdbcType=VARCHAR}");
}
if (record.getDiscountPrice() != null) {
sql.VALUES("discount_price", "#{discountPrice,jdbcType=DECIMAL}");
}
if (record.getUsingRange() != null) {
sql.VALUES("using_range", "#{usingRange,jdbcType=INTEGER}");
}
if (record.getUseScope() != null) {
sql.VALUES("use_scope", "#{useScope,jdbcType=INTEGER}");
}
if (record.getAgentId() != null) {
sql.VALUES("agent_id", "#{agentId,jdbcType=BIGINT}");
}
if (record.getBatchIdentifier() != null) {
sql.VALUES("batch_identifier", "#{batchIdentifier,jdbcType=VARCHAR}");
}
if (record.getBatchNum() != null) {
sql.VALUES("batch_num", "#{batchNum,jdbcType=INTEGER}");
}
if (record.getCodeStart() != null) {
sql.VALUES("code_start", "#{codeStart,jdbcType=VARCHAR}");
}
if (record.getCodeEnd() != null) {
sql.VALUES("code_end", "#{codeEnd,jdbcType=VARCHAR}");
}
if (record.getMailTime() != null) {
sql.VALUES("mail_time", "#{mailTime,jdbcType=TIMESTAMP}");
}
if (record.getCreateTime() != null) {
sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
}
if (record.getStatus() != null) {
sql.VALUES("`status`", "#{status,jdbcType=INTEGER}");
}
if (record.getQrCode() != null) {
sql.VALUES("qr_code", "#{qrCode,jdbcType=VARCHAR}");
}
if (record.getExt1() != null) {
sql.VALUES("ext_1", "#{ext1,jdbcType=VARCHAR}");
}
if (record.getExt2() != null) {
sql.VALUES("ext_2", "#{ext2,jdbcType=VARCHAR}");
}
if (record.getExt3() != null) {
sql.VALUES("ext_3", "#{ext3,jdbcType=VARCHAR}");
}
return sql.toString();
}
public String selectByExample(HighDiscountAgentBatchExample example) {
SQL sql = new SQL();
if (example != null && example.isDistinct()) {
sql.SELECT_DISTINCT("id");
} else {
sql.SELECT("id");
}
sql.SELECT("discount_agent_id");
sql.SELECT("discount_id");
sql.SELECT("discount_name");
sql.SELECT("discount_price");
sql.SELECT("using_range");
sql.SELECT("use_scope");
sql.SELECT("agent_id");
sql.SELECT("batch_identifier");
sql.SELECT("batch_num");
sql.SELECT("code_start");
sql.SELECT("code_end");
sql.SELECT("mail_time");
sql.SELECT("create_time");
sql.SELECT("`status`");
sql.SELECT("qr_code");
sql.SELECT("ext_1");
sql.SELECT("ext_2");
sql.SELECT("ext_3");
sql.FROM("high_discount_agent_batch");
applyWhere(sql, example, false);
if (example != null && example.getOrderByClause() != null) {
sql.ORDER_BY(example.getOrderByClause());
}
return sql.toString();
}
public String updateByExampleSelective(Map<String, Object> parameter) {
HighDiscountAgentBatch record = (HighDiscountAgentBatch) parameter.get("record");
HighDiscountAgentBatchExample example = (HighDiscountAgentBatchExample) parameter.get("example");
SQL sql = new SQL();
sql.UPDATE("high_discount_agent_batch");
if (record.getId() != null) {
sql.SET("id = #{record.id,jdbcType=BIGINT}");
}
if (record.getDiscountAgentId() != null) {
sql.SET("discount_agent_id = #{record.discountAgentId,jdbcType=BIGINT}");
}
if (record.getDiscountId() != null) {
sql.SET("discount_id = #{record.discountId,jdbcType=BIGINT}");
}
if (record.getDiscountName() != null) {
sql.SET("discount_name = #{record.discountName,jdbcType=VARCHAR}");
}
if (record.getDiscountPrice() != null) {
sql.SET("discount_price = #{record.discountPrice,jdbcType=DECIMAL}");
}
if (record.getUsingRange() != null) {
sql.SET("using_range = #{record.usingRange,jdbcType=INTEGER}");
}
if (record.getUseScope() != null) {
sql.SET("use_scope = #{record.useScope,jdbcType=INTEGER}");
}
if (record.getAgentId() != null) {
sql.SET("agent_id = #{record.agentId,jdbcType=BIGINT}");
}
if (record.getBatchIdentifier() != null) {
sql.SET("batch_identifier = #{record.batchIdentifier,jdbcType=VARCHAR}");
}
if (record.getBatchNum() != null) {
sql.SET("batch_num = #{record.batchNum,jdbcType=INTEGER}");
}
if (record.getCodeStart() != null) {
sql.SET("code_start = #{record.codeStart,jdbcType=VARCHAR}");
}
if (record.getCodeEnd() != null) {
sql.SET("code_end = #{record.codeEnd,jdbcType=VARCHAR}");
}
if (record.getMailTime() != null) {
sql.SET("mail_time = #{record.mailTime,jdbcType=TIMESTAMP}");
}
if (record.getCreateTime() != null) {
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
}
if (record.getStatus() != null) {
sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
}
if (record.getQrCode() != null) {
sql.SET("qr_code = #{record.qrCode,jdbcType=VARCHAR}");
}
if (record.getExt1() != null) {
sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}");
}
if (record.getExt2() != null) {
sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}");
}
if (record.getExt3() != null) {
sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}");
}
applyWhere(sql, example, true);
return sql.toString();
}
public String updateByExample(Map<String, Object> parameter) {
SQL sql = new SQL();
sql.UPDATE("high_discount_agent_batch");
sql.SET("id = #{record.id,jdbcType=BIGINT}");
sql.SET("discount_agent_id = #{record.discountAgentId,jdbcType=BIGINT}");
sql.SET("discount_id = #{record.discountId,jdbcType=BIGINT}");
sql.SET("discount_name = #{record.discountName,jdbcType=VARCHAR}");
sql.SET("discount_price = #{record.discountPrice,jdbcType=DECIMAL}");
sql.SET("using_range = #{record.usingRange,jdbcType=INTEGER}");
sql.SET("use_scope = #{record.useScope,jdbcType=INTEGER}");
sql.SET("agent_id = #{record.agentId,jdbcType=BIGINT}");
sql.SET("batch_identifier = #{record.batchIdentifier,jdbcType=VARCHAR}");
sql.SET("batch_num = #{record.batchNum,jdbcType=INTEGER}");
sql.SET("code_start = #{record.codeStart,jdbcType=VARCHAR}");
sql.SET("code_end = #{record.codeEnd,jdbcType=VARCHAR}");
sql.SET("mail_time = #{record.mailTime,jdbcType=TIMESTAMP}");
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
sql.SET("qr_code = #{record.qrCode,jdbcType=VARCHAR}");
sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}");
sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}");
sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}");
HighDiscountAgentBatchExample example = (HighDiscountAgentBatchExample) parameter.get("example");
applyWhere(sql, example, true);
return sql.toString();
}
public String updateByPrimaryKeySelective(HighDiscountAgentBatch record) {
SQL sql = new SQL();
sql.UPDATE("high_discount_agent_batch");
if (record.getDiscountAgentId() != null) {
sql.SET("discount_agent_id = #{discountAgentId,jdbcType=BIGINT}");
}
if (record.getDiscountId() != null) {
sql.SET("discount_id = #{discountId,jdbcType=BIGINT}");
}
if (record.getDiscountName() != null) {
sql.SET("discount_name = #{discountName,jdbcType=VARCHAR}");
}
if (record.getDiscountPrice() != null) {
sql.SET("discount_price = #{discountPrice,jdbcType=DECIMAL}");
}
if (record.getUsingRange() != null) {
sql.SET("using_range = #{usingRange,jdbcType=INTEGER}");
}
if (record.getUseScope() != null) {
sql.SET("use_scope = #{useScope,jdbcType=INTEGER}");
}
if (record.getAgentId() != null) {
sql.SET("agent_id = #{agentId,jdbcType=BIGINT}");
}
if (record.getBatchIdentifier() != null) {
sql.SET("batch_identifier = #{batchIdentifier,jdbcType=VARCHAR}");
}
if (record.getBatchNum() != null) {
sql.SET("batch_num = #{batchNum,jdbcType=INTEGER}");
}
if (record.getCodeStart() != null) {
sql.SET("code_start = #{codeStart,jdbcType=VARCHAR}");
}
if (record.getCodeEnd() != null) {
sql.SET("code_end = #{codeEnd,jdbcType=VARCHAR}");
}
if (record.getMailTime() != null) {
sql.SET("mail_time = #{mailTime,jdbcType=TIMESTAMP}");
}
if (record.getCreateTime() != null) {
sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
}
if (record.getStatus() != null) {
sql.SET("`status` = #{status,jdbcType=INTEGER}");
}
if (record.getQrCode() != null) {
sql.SET("qr_code = #{qrCode,jdbcType=VARCHAR}");
}
if (record.getExt1() != null) {
sql.SET("ext_1 = #{ext1,jdbcType=VARCHAR}");
}
if (record.getExt2() != null) {
sql.SET("ext_2 = #{ext2,jdbcType=VARCHAR}");
}
if (record.getExt3() != null) {
sql.SET("ext_3 = #{ext3,jdbcType=VARCHAR}");
}
sql.WHERE("id = #{id,jdbcType=BIGINT}");
return sql.toString();
}
protected void applyWhere(SQL sql, HighDiscountAgentBatchExample example, boolean includeExamplePhrase) {
if (example == null) {
return;
}
String parmPhrase1;
String parmPhrase1_th;
String parmPhrase2;
String parmPhrase2_th;
String parmPhrase3;
String parmPhrase3_th;
if (includeExamplePhrase) {
parmPhrase1 = "%s #{example.oredCriteria[%d].allCriteria[%d].value}";
parmPhrase1_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}";
parmPhrase2 = "%s #{example.oredCriteria[%d].allCriteria[%d].value} and #{example.oredCriteria[%d].criteria[%d].secondValue}";
parmPhrase2_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{example.oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}";
parmPhrase3 = "#{example.oredCriteria[%d].allCriteria[%d].value[%d]}";
parmPhrase3_th = "#{example.oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}";
} else {
parmPhrase1 = "%s #{oredCriteria[%d].allCriteria[%d].value}";
parmPhrase1_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}";
parmPhrase2 = "%s #{oredCriteria[%d].allCriteria[%d].value} and #{oredCriteria[%d].criteria[%d].secondValue}";
parmPhrase2_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}";
parmPhrase3 = "#{oredCriteria[%d].allCriteria[%d].value[%d]}";
parmPhrase3_th = "#{oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}";
}
StringBuilder sb = new StringBuilder();
List<Criteria> oredCriteria = example.getOredCriteria();
boolean firstCriteria = true;
for (int i = 0; i < oredCriteria.size(); i++) {
Criteria criteria = oredCriteria.get(i);
if (criteria.isValid()) {
if (firstCriteria) {
firstCriteria = false;
} else {
sb.append(" or ");
}
sb.append('(');
List<Criterion> criterions = criteria.getAllCriteria();
boolean firstCriterion = true;
for (int j = 0; j < criterions.size(); j++) {
Criterion criterion = criterions.get(j);
if (firstCriterion) {
firstCriterion = false;
} else {
sb.append(" and ");
}
if (criterion.isNoValue()) {
sb.append(criterion.getCondition());
} else if (criterion.isSingleValue()) {
if (criterion.getTypeHandler() == null) {
sb.append(String.format(parmPhrase1, criterion.getCondition(), i, j));
} else {
sb.append(String.format(parmPhrase1_th, criterion.getCondition(), i, j,criterion.getTypeHandler()));
}
} else if (criterion.isBetweenValue()) {
if (criterion.getTypeHandler() == null) {
sb.append(String.format(parmPhrase2, criterion.getCondition(), i, j, i, j));
} else {
sb.append(String.format(parmPhrase2_th, criterion.getCondition(), i, j, criterion.getTypeHandler(), i, j, criterion.getTypeHandler()));
}
} else if (criterion.isListValue()) {
sb.append(criterion.getCondition());
sb.append(" (");
List<?> listItems = (List<?>) criterion.getValue();
boolean comma = false;
for (int k = 0; k < listItems.size(); k++) {
if (comma) {
sb.append(", ");
} else {
comma = true;
}
if (criterion.getTypeHandler() == null) {
sb.append(String.format(parmPhrase3, i, j, k));
} else {
sb.append(String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler()));
}
}
sb.append(')');
}
}
sb.append(')');
}
}
if (sb.length() > 0) {
sql.WHERE(sb.toString());
}
}
}

@ -39,12 +39,14 @@ public interface HighDiscountAgentCodeMapper extends HighDiscountAgentCodeMapper
int deleteByPrimaryKey(Long id);
@Insert({
"insert into high_discount_agent_code (discount_agent_id, qr_code, ",
"create_time, `status`, ",
"ext_1, ext_2, ext_3)",
"values (#{discountAgentId,jdbcType=BIGINT}, #{qrCode,jdbcType=VARCHAR}, ",
"#{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, ",
"#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
"insert into high_discount_agent_code (discount_agent_id, discount_agent_batch_id, ",
"qr_code, create_time, ",
"`status`, ext_1, ext_2, ",
"ext_3)",
"values (#{discountAgentId,jdbcType=BIGINT}, #{discountAgentBatchId,jdbcType=BIGINT}, ",
"#{qrCode,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ",
"#{status,jdbcType=INTEGER}, #{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, ",
"#{ext3,jdbcType=VARCHAR})"
})
@Options(useGeneratedKeys=true,keyProperty="id")
int insert(HighDiscountAgentCode record);
@ -57,6 +59,7 @@ public interface HighDiscountAgentCodeMapper extends HighDiscountAgentCodeMapper
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="discount_agent_id", property="discountAgentId", jdbcType=JdbcType.BIGINT),
@Result(column="discount_agent_batch_id", property="discountAgentBatchId", jdbcType=JdbcType.BIGINT),
@Result(column="qr_code", property="qrCode", jdbcType=JdbcType.VARCHAR),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@ -68,13 +71,15 @@ public interface HighDiscountAgentCodeMapper extends HighDiscountAgentCodeMapper
@Select({
"select",
"id, discount_agent_id, qr_code, create_time, `status`, ext_1, ext_2, ext_3",
"id, discount_agent_id, discount_agent_batch_id, qr_code, create_time, `status`, ",
"ext_1, ext_2, ext_3",
"from high_discount_agent_code",
"where id = #{id,jdbcType=BIGINT}"
})
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="discount_agent_id", property="discountAgentId", jdbcType=JdbcType.BIGINT),
@Result(column="discount_agent_batch_id", property="discountAgentBatchId", jdbcType=JdbcType.BIGINT),
@Result(column="qr_code", property="qrCode", jdbcType=JdbcType.VARCHAR),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@ -96,6 +101,7 @@ public interface HighDiscountAgentCodeMapper extends HighDiscountAgentCodeMapper
@Update({
"update high_discount_agent_code",
"set discount_agent_id = #{discountAgentId,jdbcType=BIGINT},",
"discount_agent_batch_id = #{discountAgentBatchId,jdbcType=BIGINT},",
"qr_code = #{qrCode,jdbcType=VARCHAR},",
"create_time = #{createTime,jdbcType=TIMESTAMP},",
"`status` = #{status,jdbcType=INTEGER},",

@ -32,6 +32,10 @@ public class HighDiscountAgentCodeSqlProvider {
sql.VALUES("discount_agent_id", "#{discountAgentId,jdbcType=BIGINT}");
}
if (record.getDiscountAgentBatchId() != null) {
sql.VALUES("discount_agent_batch_id", "#{discountAgentBatchId,jdbcType=BIGINT}");
}
if (record.getQrCode() != null) {
sql.VALUES("qr_code", "#{qrCode,jdbcType=VARCHAR}");
}
@ -67,6 +71,7 @@ public class HighDiscountAgentCodeSqlProvider {
sql.SELECT("id");
}
sql.SELECT("discount_agent_id");
sql.SELECT("discount_agent_batch_id");
sql.SELECT("qr_code");
sql.SELECT("create_time");
sql.SELECT("`status`");
@ -98,6 +103,10 @@ public class HighDiscountAgentCodeSqlProvider {
sql.SET("discount_agent_id = #{record.discountAgentId,jdbcType=BIGINT}");
}
if (record.getDiscountAgentBatchId() != null) {
sql.SET("discount_agent_batch_id = #{record.discountAgentBatchId,jdbcType=BIGINT}");
}
if (record.getQrCode() != null) {
sql.SET("qr_code = #{record.qrCode,jdbcType=VARCHAR}");
}
@ -132,6 +141,7 @@ public class HighDiscountAgentCodeSqlProvider {
sql.SET("id = #{record.id,jdbcType=BIGINT}");
sql.SET("discount_agent_id = #{record.discountAgentId,jdbcType=BIGINT}");
sql.SET("discount_agent_batch_id = #{record.discountAgentBatchId,jdbcType=BIGINT}");
sql.SET("qr_code = #{record.qrCode,jdbcType=VARCHAR}");
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
@ -152,6 +162,10 @@ public class HighDiscountAgentCodeSqlProvider {
sql.SET("discount_agent_id = #{discountAgentId,jdbcType=BIGINT}");
}
if (record.getDiscountAgentBatchId() != null) {
sql.SET("discount_agent_batch_id = #{discountAgentBatchId,jdbcType=BIGINT}");
}
if (record.getQrCode() != null) {
sql.SET("qr_code = #{qrCode,jdbcType=VARCHAR}");
}

@ -0,0 +1,345 @@
package com.hai.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* high_discount_agent_batch
* @author
*/
/**
*
* 代码由工具生成
*
**/
public class HighDiscountAgentBatch implements Serializable {
/**
* 主键
*/
private Long id;
/**
* 优惠券与代理商关系
*/
private Long discountAgentId;
/**
* 优惠券id
*/
private Long discountId;
/**
* 优惠券名称
*/
private String discountName;
/**
* 优惠券金额
*/
private BigDecimal discountPrice;
/**
* 使用归属
*/
private Integer usingRange;
/**
* 使用范围 1. 全场 2.卡券 3.话费
*/
private Integer useScope;
/**
* 代理商id
*/
private Long agentId;
/**
* 批次标识
*/
private String batchIdentifier;
/**
* 批次数量
*/
private Integer batchNum;
/**
* 编码区间
*/
private String codeStart;
/**
* 编码区间
*/
private String codeEnd;
/**
* 邮寄时间
*/
private Date mailTime;
/**
* 创建时间
*/
private Date createTime;
/**
* 状态 0删除 1正常
*/
private Integer status;
/**
* 二维码
*/
private String qrCode;
private String ext1;
private String ext2;
private String ext3;
private static final long serialVersionUID = 1L;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getDiscountAgentId() {
return discountAgentId;
}
public void setDiscountAgentId(Long discountAgentId) {
this.discountAgentId = discountAgentId;
}
public Long getDiscountId() {
return discountId;
}
public void setDiscountId(Long discountId) {
this.discountId = discountId;
}
public String getDiscountName() {
return discountName;
}
public void setDiscountName(String discountName) {
this.discountName = discountName;
}
public BigDecimal getDiscountPrice() {
return discountPrice;
}
public void setDiscountPrice(BigDecimal discountPrice) {
this.discountPrice = discountPrice;
}
public Integer getUsingRange() {
return usingRange;
}
public void setUsingRange(Integer usingRange) {
this.usingRange = usingRange;
}
public Integer getUseScope() {
return useScope;
}
public void setUseScope(Integer useScope) {
this.useScope = useScope;
}
public Long getAgentId() {
return agentId;
}
public void setAgentId(Long agentId) {
this.agentId = agentId;
}
public String getBatchIdentifier() {
return batchIdentifier;
}
public void setBatchIdentifier(String batchIdentifier) {
this.batchIdentifier = batchIdentifier;
}
public Integer getBatchNum() {
return batchNum;
}
public void setBatchNum(Integer batchNum) {
this.batchNum = batchNum;
}
public String getCodeStart() {
return codeStart;
}
public void setCodeStart(String codeStart) {
this.codeStart = codeStart;
}
public String getCodeEnd() {
return codeEnd;
}
public void setCodeEnd(String codeEnd) {
this.codeEnd = codeEnd;
}
public Date getMailTime() {
return mailTime;
}
public void setMailTime(Date mailTime) {
this.mailTime = mailTime;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getQrCode() {
return qrCode;
}
public void setQrCode(String qrCode) {
this.qrCode = qrCode;
}
public String getExt1() {
return ext1;
}
public void setExt1(String ext1) {
this.ext1 = ext1;
}
public String getExt2() {
return ext2;
}
public void setExt2(String ext2) {
this.ext2 = ext2;
}
public String getExt3() {
return ext3;
}
public void setExt3(String ext3) {
this.ext3 = ext3;
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
HighDiscountAgentBatch other = (HighDiscountAgentBatch) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getDiscountAgentId() == null ? other.getDiscountAgentId() == null : this.getDiscountAgentId().equals(other.getDiscountAgentId()))
&& (this.getDiscountId() == null ? other.getDiscountId() == null : this.getDiscountId().equals(other.getDiscountId()))
&& (this.getDiscountName() == null ? other.getDiscountName() == null : this.getDiscountName().equals(other.getDiscountName()))
&& (this.getDiscountPrice() == null ? other.getDiscountPrice() == null : this.getDiscountPrice().equals(other.getDiscountPrice()))
&& (this.getUsingRange() == null ? other.getUsingRange() == null : this.getUsingRange().equals(other.getUsingRange()))
&& (this.getUseScope() == null ? other.getUseScope() == null : this.getUseScope().equals(other.getUseScope()))
&& (this.getAgentId() == null ? other.getAgentId() == null : this.getAgentId().equals(other.getAgentId()))
&& (this.getBatchIdentifier() == null ? other.getBatchIdentifier() == null : this.getBatchIdentifier().equals(other.getBatchIdentifier()))
&& (this.getBatchNum() == null ? other.getBatchNum() == null : this.getBatchNum().equals(other.getBatchNum()))
&& (this.getCodeStart() == null ? other.getCodeStart() == null : this.getCodeStart().equals(other.getCodeStart()))
&& (this.getCodeEnd() == null ? other.getCodeEnd() == null : this.getCodeEnd().equals(other.getCodeEnd()))
&& (this.getMailTime() == null ? other.getMailTime() == null : this.getMailTime().equals(other.getMailTime()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getQrCode() == null ? other.getQrCode() == null : this.getQrCode().equals(other.getQrCode()))
&& (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1()))
&& (this.getExt2() == null ? other.getExt2() == null : this.getExt2().equals(other.getExt2()))
&& (this.getExt3() == null ? other.getExt3() == null : this.getExt3().equals(other.getExt3()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getDiscountAgentId() == null) ? 0 : getDiscountAgentId().hashCode());
result = prime * result + ((getDiscountId() == null) ? 0 : getDiscountId().hashCode());
result = prime * result + ((getDiscountName() == null) ? 0 : getDiscountName().hashCode());
result = prime * result + ((getDiscountPrice() == null) ? 0 : getDiscountPrice().hashCode());
result = prime * result + ((getUsingRange() == null) ? 0 : getUsingRange().hashCode());
result = prime * result + ((getUseScope() == null) ? 0 : getUseScope().hashCode());
result = prime * result + ((getAgentId() == null) ? 0 : getAgentId().hashCode());
result = prime * result + ((getBatchIdentifier() == null) ? 0 : getBatchIdentifier().hashCode());
result = prime * result + ((getBatchNum() == null) ? 0 : getBatchNum().hashCode());
result = prime * result + ((getCodeStart() == null) ? 0 : getCodeStart().hashCode());
result = prime * result + ((getCodeEnd() == null) ? 0 : getCodeEnd().hashCode());
result = prime * result + ((getMailTime() == null) ? 0 : getMailTime().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getQrCode() == null) ? 0 : getQrCode().hashCode());
result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode());
result = prime * result + ((getExt2() == null) ? 0 : getExt2().hashCode());
result = prime * result + ((getExt3() == null) ? 0 : getExt3().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", discountAgentId=").append(discountAgentId);
sb.append(", discountId=").append(discountId);
sb.append(", discountName=").append(discountName);
sb.append(", discountPrice=").append(discountPrice);
sb.append(", usingRange=").append(usingRange);
sb.append(", useScope=").append(useScope);
sb.append(", agentId=").append(agentId);
sb.append(", batchIdentifier=").append(batchIdentifier);
sb.append(", batchNum=").append(batchNum);
sb.append(", codeStart=").append(codeStart);
sb.append(", codeEnd=").append(codeEnd);
sb.append(", mailTime=").append(mailTime);
sb.append(", createTime=").append(createTime);
sb.append(", status=").append(status);
sb.append(", qrCode=").append(qrCode);
sb.append(", ext1=").append(ext1);
sb.append(", ext2=").append(ext2);
sb.append(", ext3=").append(ext3);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

@ -25,6 +25,11 @@ public class HighDiscountAgentCode extends HighDiscountAgentCodeModel implements
*/
private Long discountAgentId;
/**
* 批次id
*/
private Long discountAgentBatchId;
/**
* 二维码
*/
@ -36,7 +41,7 @@ public class HighDiscountAgentCode extends HighDiscountAgentCodeModel implements
private Date createTime;
/**
* 状态 0删除 1待领取 2待使用 3已使用 4已过期
* 状态 0删除 1待领取 2待使用 3已使用 4已过期 5已分配
*/
private Integer status;
@ -64,6 +69,14 @@ public class HighDiscountAgentCode extends HighDiscountAgentCodeModel implements
this.discountAgentId = discountAgentId;
}
public Long getDiscountAgentBatchId() {
return discountAgentBatchId;
}
public void setDiscountAgentBatchId(Long discountAgentBatchId) {
this.discountAgentBatchId = discountAgentBatchId;
}
public String getQrCode() {
return qrCode;
}
@ -126,6 +139,7 @@ public class HighDiscountAgentCode extends HighDiscountAgentCodeModel implements
HighDiscountAgentCode other = (HighDiscountAgentCode) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getDiscountAgentId() == null ? other.getDiscountAgentId() == null : this.getDiscountAgentId().equals(other.getDiscountAgentId()))
&& (this.getDiscountAgentBatchId() == null ? other.getDiscountAgentBatchId() == null : this.getDiscountAgentBatchId().equals(other.getDiscountAgentBatchId()))
&& (this.getQrCode() == null ? other.getQrCode() == null : this.getQrCode().equals(other.getQrCode()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
@ -140,6 +154,7 @@ public class HighDiscountAgentCode extends HighDiscountAgentCodeModel implements
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getDiscountAgentId() == null) ? 0 : getDiscountAgentId().hashCode());
result = prime * result + ((getDiscountAgentBatchId() == null) ? 0 : getDiscountAgentBatchId().hashCode());
result = prime * result + ((getQrCode() == null) ? 0 : getQrCode().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
@ -157,6 +172,7 @@ public class HighDiscountAgentCode extends HighDiscountAgentCodeModel implements
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", discountAgentId=").append(discountAgentId);
sb.append(", discountAgentBatchId=").append(discountAgentBatchId);
sb.append(", qrCode=").append(qrCode);
sb.append(", createTime=").append(createTime);
sb.append(", status=").append(status);
@ -167,4 +183,4 @@ public class HighDiscountAgentCode extends HighDiscountAgentCodeModel implements
sb.append("]");
return sb.toString();
}
}
}

@ -245,6 +245,66 @@ public class HighDiscountAgentCodeExample {
return (Criteria) this;
}
public Criteria andDiscountAgentBatchIdIsNull() {
addCriterion("discount_agent_batch_id is null");
return (Criteria) this;
}
public Criteria andDiscountAgentBatchIdIsNotNull() {
addCriterion("discount_agent_batch_id is not null");
return (Criteria) this;
}
public Criteria andDiscountAgentBatchIdEqualTo(Long value) {
addCriterion("discount_agent_batch_id =", value, "discountAgentBatchId");
return (Criteria) this;
}
public Criteria andDiscountAgentBatchIdNotEqualTo(Long value) {
addCriterion("discount_agent_batch_id <>", value, "discountAgentBatchId");
return (Criteria) this;
}
public Criteria andDiscountAgentBatchIdGreaterThan(Long value) {
addCriterion("discount_agent_batch_id >", value, "discountAgentBatchId");
return (Criteria) this;
}
public Criteria andDiscountAgentBatchIdGreaterThanOrEqualTo(Long value) {
addCriterion("discount_agent_batch_id >=", value, "discountAgentBatchId");
return (Criteria) this;
}
public Criteria andDiscountAgentBatchIdLessThan(Long value) {
addCriterion("discount_agent_batch_id <", value, "discountAgentBatchId");
return (Criteria) this;
}
public Criteria andDiscountAgentBatchIdLessThanOrEqualTo(Long value) {
addCriterion("discount_agent_batch_id <=", value, "discountAgentBatchId");
return (Criteria) this;
}
public Criteria andDiscountAgentBatchIdIn(List<Long> values) {
addCriterion("discount_agent_batch_id in", values, "discountAgentBatchId");
return (Criteria) this;
}
public Criteria andDiscountAgentBatchIdNotIn(List<Long> values) {
addCriterion("discount_agent_batch_id not in", values, "discountAgentBatchId");
return (Criteria) this;
}
public Criteria andDiscountAgentBatchIdBetween(Long value1, Long value2) {
addCriterion("discount_agent_batch_id between", value1, value2, "discountAgentBatchId");
return (Criteria) this;
}
public Criteria andDiscountAgentBatchIdNotBetween(Long value1, Long value2) {
addCriterion("discount_agent_batch_id not between", value1, value2, "discountAgentBatchId");
return (Criteria) this;
}
public Criteria andQrCodeIsNull() {
addCriterion("qr_code is null");
return (Criteria) this;

@ -0,0 +1,40 @@
package com.hai.service;
import com.hai.entity.HighDiscountAgentBatch;
import java.util.List;
import java.util.Map;
/**
* @className: HighDiscountAgentBatchService
* @author: HuRui
* @date: 2023/8/16
**/
public interface HighDiscountAgentBatchService {
/**
* 编辑数据
* @param discountAgentBatch
*/
void editData(HighDiscountAgentBatch discountAgentBatch);
/**
* 根据标识查询数据
* @param identifier
* @return
*/
HighDiscountAgentBatch getBatchByIdentifier(String identifier);
/**
* 获取使用统计
* @param param
* @return
*/List<Map<String,Object>> getUsageCount(Map<String, Object> param);
/**
* 获取统计
* @param param
* @return
*/
Map<String,Object> getCount(Map<String, Object> param);
}

@ -60,4 +60,11 @@ public interface HighDiscountAgentRelService {
* @Date 2021/4/4 0:32
**/
List<HighDiscountAgentRel> getRelList(Map<String,Object> map);
/**
* 查询列表
* @param map
* @return
*/
List<HighDiscountAgentRel> getDiscountUseCount(Map<String,Object> map);
}

@ -2,6 +2,7 @@ package com.hai.service;
import com.hai.entity.HighDiscount;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
@ -47,5 +48,5 @@ public interface HighDiscountService {
**/
List<HighDiscount> getDiscount(Map<String,Object> map);
List<BigDecimal> getDiscountPrice(Integer usingRange);
}

@ -0,0 +1,55 @@
package com.hai.service.impl;
import com.hai.dao.HighDiscountAgentBatchMapper;
import com.hai.entity.HighDiscountAgentBatch;
import com.hai.entity.HighDiscountAgentBatchExample;
import com.hai.service.HighDiscountAgentBatchService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @className: HighDiscountAgentBatchServiceImpl
* @author: HuRui
* @date: 2023/8/16
**/
@Service("discountAgentBatchService")
public class HighDiscountAgentBatchServiceImpl implements HighDiscountAgentBatchService {
@Resource
private HighDiscountAgentBatchMapper discountAgentBatchMapper;
@Override
public void editData(HighDiscountAgentBatch discountAgentBatch) {
if (discountAgentBatch.getId() == null) {
discountAgentBatch.setCreateTime(new Date());
discountAgentBatch.setStatus(1);
discountAgentBatchMapper.insert(discountAgentBatch);
} else {
discountAgentBatchMapper.updateByPrimaryKey(discountAgentBatch);
}
}
@Override
public HighDiscountAgentBatch getBatchByIdentifier(String identifier) {
HighDiscountAgentBatchExample example = new HighDiscountAgentBatchExample();
example.createCriteria().andBatchIdentifierEqualTo(identifier).andStatusNotEqualTo(0);
List<HighDiscountAgentBatch> list = discountAgentBatchMapper.selectByExample(example);
if (list.size() > 0) {
return list.get(0);
}
return null;
}
@Override
public List<Map<String, Object>> getUsageCount(Map<String, Object> param) {
return discountAgentBatchMapper.queryUsageCount(param);
}
@Override
public Map<String, Object> getCount(Map<String, Object> param) {
return discountAgentBatchMapper.queryCount(param);
}
}

@ -11,10 +11,7 @@ import com.hai.config.WeChatQrcodeUtils;
import com.hai.dao.HighDiscountAgentRelMapper;
import com.hai.entity.*;
import com.hai.enum_type.WxQrCodeTypeEnum;
import com.hai.service.HighAgentService;
import com.hai.service.HighDiscountAgentCodeService;
import com.hai.service.HighDiscountAgentRelService;
import com.hai.service.HighDiscountService;
import com.hai.service.*;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -45,6 +42,9 @@ public class HighDiscountAgentRelServiceImpl implements HighDiscountAgentRelServ
@Resource
private HighDiscountAgentCodeService highDiscountAgentCodeService;
@Resource
private HighDiscountAgentBatchService discountAgentBatchService;
@Autowired
private WeChatQrcodeUtils weChatQrcodeUtils;
@ -56,6 +56,19 @@ public class HighDiscountAgentRelServiceImpl implements HighDiscountAgentRelServ
} else {
highDiscountAgentRelMapper.insert(highDiscountAgentRel);
}
HighDiscountAgentBatch discountAgentBatch = new HighDiscountAgentBatch();
discountAgentBatch.setDiscountAgentId(highDiscountAgentRel.getId());
discountAgentBatch.setDiscountId(highDiscountAgentRel.getDiscountId());
discountAgentBatch.setDiscountName(highDiscountAgentRel.getHighDiscount().getDiscountName());
discountAgentBatch.setDiscountPrice(highDiscountAgentRel.getHighDiscount().getDiscountPrice());
discountAgentBatch.setUseScope(highDiscountAgentRel.getHighDiscount().getUseScope());
discountAgentBatch.setUsingRange(highDiscountAgentRel.getHighDiscount().getUsingRange());
discountAgentBatch.setAgentId(highDiscountAgentRel.getAgentId());
discountAgentBatch.setBatchNum(stockCount);
discountAgentBatchService.editData(discountAgentBatch);
discountAgentBatch.setBatchIdentifier((10000 + discountAgentBatch.getId())+"");
discountAgentBatchService.editData(discountAgentBatch);
HighDiscountAgentCode code;
Map<String,Object> map = new HashMap<>();
@ -63,6 +76,7 @@ public class HighDiscountAgentRelServiceImpl implements HighDiscountAgentRelServ
for (int i = 0;i < stockCount;i++) {
code = new HighDiscountAgentCode();
code.setDiscountAgentId(highDiscountAgentRel.getId());
code.setDiscountAgentBatchId(discountAgentBatch.getId());
code.setStatus(1);
code.setCreateTime(new Date());
highDiscountAgentCodeService.insertCode(code);
@ -74,7 +88,14 @@ public class HighDiscountAgentRelServiceImpl implements HighDiscountAgentRelServ
code.setExt1(qrCodeUrl);
// 生成二维码地址
highDiscountAgentCodeService.updateCode(code);
if (i == 0) {
discountAgentBatch.setCodeStart(code.getId().toString());
} else if ((i + 1) == stockCount) {
discountAgentBatch.setCodeEnd(code.getId().toString());
}
}
discountAgentBatchService.editData(discountAgentBatch);
}
@Override
@ -140,4 +161,14 @@ public class HighDiscountAgentRelServiceImpl implements HighDiscountAgentRelServ
}
return list;
}
@Override
public List<HighDiscountAgentRel> getDiscountUseCount(Map<String, Object> map) {
HighDiscountAgentRelExample example = new HighDiscountAgentRelExample();
HighDiscountAgentRelExample.Criteria criteria = example.createCriteria().andStatusEqualTo(1);
example.setOrderByClause("create_time desc");
return highDiscountAgentRelMapper.selectByExample(example);
}
}

@ -10,8 +10,11 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Auther: 胡锐
@ -75,4 +78,16 @@ public class HighDiscountServiceImpl implements HighDiscountService {
example.setOrderByClause("update_time desc");
return highDiscountMapper.selectByExample(example);
}
@Override
public List<BigDecimal> getDiscountPrice(Integer usingRange) {
HighDiscountExample discountExample = new HighDiscountExample();
discountExample.createCriteria().andUsingRangeEqualTo(usingRange);
List<HighDiscount> list = highDiscountMapper.selectByExample(discountExample);
List<BigDecimal> priceList = new ArrayList<>();
for (HighDiscount discount : list) {
priceList.add(discount.getDiscountPrice());
}
return priceList.stream().distinct().sorted().collect(Collectors.toList());
}
}

Loading…
Cancel
Save