完成兑换码

dev-discount
胡锐 3 years ago
parent 62b5edea60
commit bcde92c9e2
  1. 8
      hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java
  2. 4
      hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java
  3. 1
      hai-cweb/src/main/java/com/cweb/config/AuthConfig.java
  4. 77
      hai-cweb/src/main/java/com/cweb/controller/HighCouponAgentController.java
  5. 25
      hai-service/src/main/java/com/hai/common/GenerateCode.java
  6. 34
      hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeMapper.java
  7. 56
      hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeSqlProvider.java
  8. 33
      hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapper.java
  9. 4
      hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapperExt.java
  10. 14
      hai-service/src/main/java/com/hai/dao/HighCouponAgentRelSqlProvider.java
  11. 62
      hai-service/src/main/java/com/hai/entity/HighCouponAgentCode.java
  12. 226
      hai-service/src/main/java/com/hai/entity/HighCouponAgentCodeExample.java
  13. 16
      hai-service/src/main/java/com/hai/entity/HighCouponAgentRel.java
  14. 60
      hai-service/src/main/java/com/hai/entity/HighCouponAgentRelExample.java
  15. 25
      hai-service/src/main/java/com/hai/service/HighCouponAgentService.java
  16. 151
      hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java

@ -61,7 +61,8 @@ public class HighCouponAgentController {
@RequestMapping(value = "/getAgentCount", method = RequestMethod.GET) @RequestMapping(value = "/getAgentCount", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "代理商统计") @ApiOperation(value = "代理商统计")
public ResponseData getAgentCount(HttpServletRequest request) { public ResponseData getAgentCount(HttpServletRequest request,
@RequestParam(name = "type", required = true) Integer type) {
try { try {
SessionObject sessionObject = userCenter.getSessionObject(request); SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
@ -71,7 +72,7 @@ public class HighCouponAgentController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, "");
} }
return ResponseMsgUtil.success(highCouponAgentService.getSalesCountByAgent(userInfoModel.getHighAgent().getId())); return ResponseMsgUtil.success(highCouponAgentService.getSalesCountByAgent(userInfoModel.getHighAgent().getId(), type));
} catch (Exception e) { } catch (Exception e) {
log.error("HighCouponAgentController --> getCodeById() error!", e); log.error("HighCouponAgentController --> getCodeById() error!", e);
@ -187,6 +188,7 @@ public class HighCouponAgentController {
if(highCouponAgentRel.getCouponId() == null if(highCouponAgentRel.getCouponId() == null
|| highCouponAgentRel.getAgentId() == null || highCouponAgentRel.getAgentId() == null
|| highCouponAgentRel.getType() == null
|| highCouponAgentRel.getStockCount() == null) { || highCouponAgentRel.getStockCount() == null) {
log.error("HighCouponAgentController -> assignCouponAgent() error!","参数错误"); log.error("HighCouponAgentController -> assignCouponAgent() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
@ -207,7 +209,7 @@ public class HighCouponAgentController {
} }
// 校验是否分配过 // 校验是否分配过
HighCouponAgentRel couponAgent = highCouponAgentService.getRelByCouponAgent(highCouponAgentRel.getCouponId(), highCouponAgentRel.getAgentId()); HighCouponAgentRel couponAgent = highCouponAgentService.getRelByCouponAgent(highCouponAgentRel.getCouponId(), highCouponAgentRel.getAgentId(), highCouponAgentRel.getType());
if (couponAgent != null) { if (couponAgent != null) {
couponAgent.setStockCount(couponAgent.getStockCount() + highCouponAgentRel.getStockCount()); couponAgent.setStockCount(couponAgent.getStockCount() + highCouponAgentRel.getStockCount());
couponAgent.setOperatorId(userInfoModel.getSecUser().getId()); couponAgent.setOperatorId(userInfoModel.getSecUser().getId());

@ -12,7 +12,7 @@ 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.generateCode; import com.hai.common.GenerateCode;
import com.hai.common.security.SessionObject; import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter; import com.hai.common.security.UserCenter;
import com.hai.common.utils.DateUtil; import com.hai.common.utils.DateUtil;
@ -620,7 +620,7 @@ public class HighCouponController {
highCouponCode = new HighCouponCode(); highCouponCode = new HighCouponCode();
highCouponCode.setCouponId(couponId); highCouponCode.setCouponId(couponId);
highCouponCode.setMerchantId(coupon.getMerchantId()); highCouponCode.setMerchantId(coupon.getMerchantId());
highCouponCode.setSalesCode(generateCode.couponSalesCode(coupon.getMerchantId(), couponId)); highCouponCode.setSalesCode(GenerateCode.couponSalesCode(coupon.getMerchantId(), couponId));
highCouponCode.setSalesEndTime(salesEndTimeC.getTime()); highCouponCode.setSalesEndTime(salesEndTimeC.getTime());
highCouponCode.setUseEndTime(useEndTimeC.getTime()); highCouponCode.setUseEndTime(useEndTimeC.getTime());
highCouponCode.setStatus(1); // 状态:1.待销售 2.未使用 3.已使用 99.预支付 highCouponCode.setStatus(1); // 状态:1.待销售 2.未使用 3.已使用 99.预支付

@ -93,6 +93,7 @@ public class AuthConfig implements WebMvcConfigurer {
.excludePathPatterns("/order/*") .excludePathPatterns("/order/*")
.excludePathPatterns("/coupon/getCouponList") .excludePathPatterns("/coupon/getCouponList")
.excludePathPatterns("/wechatpay/*") .excludePathPatterns("/wechatpay/*")
.excludePathPatterns("/couponAgent/useConvertCode")
.excludePathPatterns("/coupon/getCouponById") .excludePathPatterns("/coupon/getCouponById")
.excludePathPatterns("/discount/getDiscountByQrCode") .excludePathPatterns("/discount/getDiscountByQrCode")
.excludePathPatterns("/discount/getDiscountById") .excludePathPatterns("/discount/getDiscountById")

@ -0,0 +1,77 @@
package com.cweb.controller;
import com.alibaba.fastjson.JSONObject;
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.SessionObject;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.*;
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.math.BigDecimal;
import java.util.*;
/**
* @Auther: 胡锐
* @Description:
* @Date: 2021/4/20 23:47
*/
@Controller
@RequestMapping(value = "/couponAgent")
@Api(value = "代理商接口")
public class HighCouponAgentController {
private static Logger log = LoggerFactory.getLogger(HighCouponAgentController.class);
@Resource
private HighCouponAgentService highCouponAgentService;
@RequestMapping(value = "/useConvertCode", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "兑换码使用")
public ResponseData useConvertCode(@RequestBody JSONObject body) {
try {
if (body == null || StringUtils.isBlank(body.getString("code"))) {
log.error("HighCouponAgentController -> queryConvertCode() error!","");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 查询兑换码
HighCouponAgentCode convertCode = highCouponAgentService.getConvertCode(body.getString("code"));
if (convertCode == null) {
log.error("HighCouponAgentController -> queryConvertCode() error!","无效的兑换码");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无效的兑换码");
}
if (convertCode.getStatus() != 1) {
log.error("HighCouponAgentController -> queryConvertCode() error!","兑换码已被使用");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "兑换码已被使用");
}
return ResponseMsgUtil.success(highCouponAgentService.useConvertCode(body.getString("code")));
} catch (Exception e) {
log.error("HighCouponAgentController --> useConvertCode() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -1,5 +1,6 @@
package com.hai.common; package com.hai.common;
import java.security.SecureRandom;
import java.util.Calendar; import java.util.Calendar;
import java.util.Random; import java.util.Random;
@ -8,8 +9,11 @@ import java.util.Random;
* @Description: * @Description:
* @Date: 2021/3/18 21:07 * @Date: 2021/3/18 21:07
*/ */
public class generateCode { public class GenerateCode {
private static final Random RANDOM = new SecureRandom();
private static final String SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
/** /**
* @Author 胡锐 * @Author 胡锐
@ -33,4 +37,23 @@ public class generateCode {
} }
return val; return val;
} }
/**
* 生成兑换码
* @param couponAgentRelId
* @return
*/
public static String convertCode(Long couponAgentRelId) {
// 兑换码总长度
int countLength = 20;
// 需要生成的长度
int generateLength = countLength - couponAgentRelId.toString().length();
char[] nonceChars = new char[generateLength];
for (int index = 0; index < nonceChars.length; ++index) {
nonceChars[index] = SYMBOLS.charAt(RANDOM.nextInt(SYMBOLS.length()));
}
return new String(nonceChars) + couponAgentRelId;
}
} }

@ -39,16 +39,18 @@ public interface HighCouponAgentCodeMapper extends HighCouponAgentCodeMapperExt
int deleteByPrimaryKey(Long id); int deleteByPrimaryKey(Long id);
@Insert({ @Insert({
"insert into high_coupon_agent_code (coupon_agent_id, coupon_id, ", "insert into high_coupon_agent_code (`type`, coupon_agent_id, ",
"agent_id, coupon_code_id, ", "coupon_id, agent_id, ",
"coupon_agent_record_id, coupon_code, ", "coupon_agent_record_id, convert_code, ",
"coupon_code_id, coupon_code, ",
"qr_code, `status`, ", "qr_code, `status`, ",
"remark, create_time, ", "remark, create_time, ",
"operator_id, operator_name, ", "operator_id, operator_name, ",
"ext_1, ext_2, ext_3)", "ext_1, ext_2, ext_3)",
"values (#{couponAgentId,jdbcType=BIGINT}, #{couponId,jdbcType=BIGINT}, ", "values (#{type,jdbcType=INTEGER}, #{couponAgentId,jdbcType=BIGINT}, ",
"#{agentId,jdbcType=BIGINT}, #{couponCodeId,jdbcType=BIGINT}, ", "#{couponId,jdbcType=BIGINT}, #{agentId,jdbcType=BIGINT}, ",
"#{couponAgentRecordId,jdbcType=BIGINT}, #{couponCode,jdbcType=VARCHAR}, ", "#{couponAgentRecordId,jdbcType=BIGINT}, #{convertCode,jdbcType=VARCHAR}, ",
"#{couponCodeId,jdbcType=BIGINT}, #{couponCode,jdbcType=VARCHAR}, ",
"#{qrCode,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ", "#{qrCode,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ",
"#{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ", "#{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ",
"#{operatorId,jdbcType=BIGINT}, #{operatorName,jdbcType=VARCHAR}, ", "#{operatorId,jdbcType=BIGINT}, #{operatorName,jdbcType=VARCHAR}, ",
@ -64,11 +66,13 @@ public interface HighCouponAgentCodeMapper extends HighCouponAgentCodeMapperExt
@SelectProvider(type=HighCouponAgentCodeSqlProvider.class, method="selectByExample") @SelectProvider(type=HighCouponAgentCodeSqlProvider.class, method="selectByExample")
@Results({ @Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
@Result(column="coupon_agent_id", property="couponAgentId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_agent_id", property="couponAgentId", jdbcType=JdbcType.BIGINT),
@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="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT),
@Result(column="coupon_agent_record_id", property="couponAgentRecordId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_agent_record_id", property="couponAgentRecordId", jdbcType=JdbcType.BIGINT),
@Result(column="convert_code", property="convertCode", jdbcType=JdbcType.VARCHAR),
@Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT),
@Result(column="coupon_code", property="couponCode", jdbcType=JdbcType.VARCHAR), @Result(column="coupon_code", property="couponCode", jdbcType=JdbcType.VARCHAR),
@Result(column="qr_code", property="qrCode", jdbcType=JdbcType.VARCHAR), @Result(column="qr_code", property="qrCode", jdbcType=JdbcType.VARCHAR),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@ -84,19 +88,21 @@ public interface HighCouponAgentCodeMapper extends HighCouponAgentCodeMapperExt
@Select({ @Select({
"select", "select",
"id, coupon_agent_id, coupon_id, agent_id, coupon_code_id, coupon_agent_record_id, ", "id, `type`, coupon_agent_id, coupon_id, agent_id, coupon_agent_record_id, convert_code, ",
"coupon_code, qr_code, `status`, remark, create_time, operator_id, operator_name, ", "coupon_code_id, coupon_code, qr_code, `status`, remark, create_time, operator_id, ",
"ext_1, ext_2, ext_3", "operator_name, ext_1, ext_2, ext_3",
"from high_coupon_agent_code", "from high_coupon_agent_code",
"where id = #{id,jdbcType=BIGINT}" "where id = #{id,jdbcType=BIGINT}"
}) })
@Results({ @Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
@Result(column="coupon_agent_id", property="couponAgentId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_agent_id", property="couponAgentId", jdbcType=JdbcType.BIGINT),
@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="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT),
@Result(column="coupon_agent_record_id", property="couponAgentRecordId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_agent_record_id", property="couponAgentRecordId", jdbcType=JdbcType.BIGINT),
@Result(column="convert_code", property="convertCode", jdbcType=JdbcType.VARCHAR),
@Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT),
@Result(column="coupon_code", property="couponCode", jdbcType=JdbcType.VARCHAR), @Result(column="coupon_code", property="couponCode", jdbcType=JdbcType.VARCHAR),
@Result(column="qr_code", property="qrCode", jdbcType=JdbcType.VARCHAR), @Result(column="qr_code", property="qrCode", jdbcType=JdbcType.VARCHAR),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@ -121,11 +127,13 @@ public interface HighCouponAgentCodeMapper extends HighCouponAgentCodeMapperExt
@Update({ @Update({
"update high_coupon_agent_code", "update high_coupon_agent_code",
"set coupon_agent_id = #{couponAgentId,jdbcType=BIGINT},", "set `type` = #{type,jdbcType=INTEGER},",
"coupon_agent_id = #{couponAgentId,jdbcType=BIGINT},",
"coupon_id = #{couponId,jdbcType=BIGINT},", "coupon_id = #{couponId,jdbcType=BIGINT},",
"agent_id = #{agentId,jdbcType=BIGINT},", "agent_id = #{agentId,jdbcType=BIGINT},",
"coupon_code_id = #{couponCodeId,jdbcType=BIGINT},",
"coupon_agent_record_id = #{couponAgentRecordId,jdbcType=BIGINT},", "coupon_agent_record_id = #{couponAgentRecordId,jdbcType=BIGINT},",
"convert_code = #{convertCode,jdbcType=VARCHAR},",
"coupon_code_id = #{couponCodeId,jdbcType=BIGINT},",
"coupon_code = #{couponCode,jdbcType=VARCHAR},", "coupon_code = #{couponCode,jdbcType=VARCHAR},",
"qr_code = #{qrCode,jdbcType=VARCHAR},", "qr_code = #{qrCode,jdbcType=VARCHAR},",
"`status` = #{status,jdbcType=INTEGER},", "`status` = #{status,jdbcType=INTEGER},",

@ -28,6 +28,10 @@ public class HighCouponAgentCodeSqlProvider {
SQL sql = new SQL(); SQL sql = new SQL();
sql.INSERT_INTO("high_coupon_agent_code"); sql.INSERT_INTO("high_coupon_agent_code");
if (record.getType() != null) {
sql.VALUES("`type`", "#{type,jdbcType=INTEGER}");
}
if (record.getCouponAgentId() != null) { if (record.getCouponAgentId() != null) {
sql.VALUES("coupon_agent_id", "#{couponAgentId,jdbcType=BIGINT}"); sql.VALUES("coupon_agent_id", "#{couponAgentId,jdbcType=BIGINT}");
} }
@ -40,14 +44,18 @@ public class HighCouponAgentCodeSqlProvider {
sql.VALUES("agent_id", "#{agentId,jdbcType=BIGINT}"); sql.VALUES("agent_id", "#{agentId,jdbcType=BIGINT}");
} }
if (record.getCouponCodeId() != null) {
sql.VALUES("coupon_code_id", "#{couponCodeId,jdbcType=BIGINT}");
}
if (record.getCouponAgentRecordId() != null) { if (record.getCouponAgentRecordId() != null) {
sql.VALUES("coupon_agent_record_id", "#{couponAgentRecordId,jdbcType=BIGINT}"); sql.VALUES("coupon_agent_record_id", "#{couponAgentRecordId,jdbcType=BIGINT}");
} }
if (record.getConvertCode() != null) {
sql.VALUES("convert_code", "#{convertCode,jdbcType=VARCHAR}");
}
if (record.getCouponCodeId() != null) {
sql.VALUES("coupon_code_id", "#{couponCodeId,jdbcType=BIGINT}");
}
if (record.getCouponCode() != null) { if (record.getCouponCode() != null) {
sql.VALUES("coupon_code", "#{couponCode,jdbcType=VARCHAR}"); sql.VALUES("coupon_code", "#{couponCode,jdbcType=VARCHAR}");
} }
@ -98,11 +106,13 @@ public class HighCouponAgentCodeSqlProvider {
} else { } else {
sql.SELECT("id"); sql.SELECT("id");
} }
sql.SELECT("`type`");
sql.SELECT("coupon_agent_id"); sql.SELECT("coupon_agent_id");
sql.SELECT("coupon_id"); sql.SELECT("coupon_id");
sql.SELECT("agent_id"); sql.SELECT("agent_id");
sql.SELECT("coupon_code_id");
sql.SELECT("coupon_agent_record_id"); sql.SELECT("coupon_agent_record_id");
sql.SELECT("convert_code");
sql.SELECT("coupon_code_id");
sql.SELECT("coupon_code"); sql.SELECT("coupon_code");
sql.SELECT("qr_code"); sql.SELECT("qr_code");
sql.SELECT("`status`"); sql.SELECT("`status`");
@ -134,6 +144,10 @@ public class HighCouponAgentCodeSqlProvider {
sql.SET("id = #{record.id,jdbcType=BIGINT}"); sql.SET("id = #{record.id,jdbcType=BIGINT}");
} }
if (record.getType() != null) {
sql.SET("`type` = #{record.type,jdbcType=INTEGER}");
}
if (record.getCouponAgentId() != null) { if (record.getCouponAgentId() != null) {
sql.SET("coupon_agent_id = #{record.couponAgentId,jdbcType=BIGINT}"); sql.SET("coupon_agent_id = #{record.couponAgentId,jdbcType=BIGINT}");
} }
@ -146,14 +160,18 @@ public class HighCouponAgentCodeSqlProvider {
sql.SET("agent_id = #{record.agentId,jdbcType=BIGINT}"); sql.SET("agent_id = #{record.agentId,jdbcType=BIGINT}");
} }
if (record.getCouponCodeId() != null) {
sql.SET("coupon_code_id = #{record.couponCodeId,jdbcType=BIGINT}");
}
if (record.getCouponAgentRecordId() != null) { if (record.getCouponAgentRecordId() != null) {
sql.SET("coupon_agent_record_id = #{record.couponAgentRecordId,jdbcType=BIGINT}"); sql.SET("coupon_agent_record_id = #{record.couponAgentRecordId,jdbcType=BIGINT}");
} }
if (record.getConvertCode() != null) {
sql.SET("convert_code = #{record.convertCode,jdbcType=VARCHAR}");
}
if (record.getCouponCodeId() != null) {
sql.SET("coupon_code_id = #{record.couponCodeId,jdbcType=BIGINT}");
}
if (record.getCouponCode() != null) { if (record.getCouponCode() != null) {
sql.SET("coupon_code = #{record.couponCode,jdbcType=VARCHAR}"); sql.SET("coupon_code = #{record.couponCode,jdbcType=VARCHAR}");
} }
@ -203,11 +221,13 @@ public class HighCouponAgentCodeSqlProvider {
sql.UPDATE("high_coupon_agent_code"); sql.UPDATE("high_coupon_agent_code");
sql.SET("id = #{record.id,jdbcType=BIGINT}"); sql.SET("id = #{record.id,jdbcType=BIGINT}");
sql.SET("`type` = #{record.type,jdbcType=INTEGER}");
sql.SET("coupon_agent_id = #{record.couponAgentId,jdbcType=BIGINT}"); sql.SET("coupon_agent_id = #{record.couponAgentId,jdbcType=BIGINT}");
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("coupon_code_id = #{record.couponCodeId,jdbcType=BIGINT}");
sql.SET("coupon_agent_record_id = #{record.couponAgentRecordId,jdbcType=BIGINT}"); sql.SET("coupon_agent_record_id = #{record.couponAgentRecordId,jdbcType=BIGINT}");
sql.SET("convert_code = #{record.convertCode,jdbcType=VARCHAR}");
sql.SET("coupon_code_id = #{record.couponCodeId,jdbcType=BIGINT}");
sql.SET("coupon_code = #{record.couponCode,jdbcType=VARCHAR}"); sql.SET("coupon_code = #{record.couponCode,jdbcType=VARCHAR}");
sql.SET("qr_code = #{record.qrCode,jdbcType=VARCHAR}"); sql.SET("qr_code = #{record.qrCode,jdbcType=VARCHAR}");
sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
@ -228,6 +248,10 @@ public class HighCouponAgentCodeSqlProvider {
SQL sql = new SQL(); SQL sql = new SQL();
sql.UPDATE("high_coupon_agent_code"); sql.UPDATE("high_coupon_agent_code");
if (record.getType() != null) {
sql.SET("`type` = #{type,jdbcType=INTEGER}");
}
if (record.getCouponAgentId() != null) { if (record.getCouponAgentId() != null) {
sql.SET("coupon_agent_id = #{couponAgentId,jdbcType=BIGINT}"); sql.SET("coupon_agent_id = #{couponAgentId,jdbcType=BIGINT}");
} }
@ -240,14 +264,18 @@ public class HighCouponAgentCodeSqlProvider {
sql.SET("agent_id = #{agentId,jdbcType=BIGINT}"); sql.SET("agent_id = #{agentId,jdbcType=BIGINT}");
} }
if (record.getCouponCodeId() != null) {
sql.SET("coupon_code_id = #{couponCodeId,jdbcType=BIGINT}");
}
if (record.getCouponAgentRecordId() != null) { if (record.getCouponAgentRecordId() != null) {
sql.SET("coupon_agent_record_id = #{couponAgentRecordId,jdbcType=BIGINT}"); sql.SET("coupon_agent_record_id = #{couponAgentRecordId,jdbcType=BIGINT}");
} }
if (record.getConvertCode() != null) {
sql.SET("convert_code = #{convertCode,jdbcType=VARCHAR}");
}
if (record.getCouponCodeId() != null) {
sql.SET("coupon_code_id = #{couponCodeId,jdbcType=BIGINT}");
}
if (record.getCouponCode() != null) { if (record.getCouponCode() != null) {
sql.SET("coupon_code = #{couponCode,jdbcType=VARCHAR}"); sql.SET("coupon_code = #{couponCode,jdbcType=VARCHAR}");
} }

@ -39,18 +39,20 @@ public interface HighCouponAgentRelMapper extends HighCouponAgentRelMapperExt {
int deleteByPrimaryKey(Long id); int deleteByPrimaryKey(Long id);
@Insert({ @Insert({
"insert into high_coupon_agent_rel (coupon_name, sales_price, ", "insert into high_coupon_agent_rel (`type`, coupon_name, ",
"coupon_id, agent_id, ", "sales_price, coupon_id, ",
"stock_count, sales_count, ", "agent_id, stock_count, ",
"create_time, `status`, ", "sales_count, create_time, ",
"operator_id, operator_name, ", "`status`, operator_id, ",
"ext_1, ext_2, ext_3)", "operator_name, ext_1, ",
"values (#{couponName,jdbcType=VARCHAR}, #{salesPrice,jdbcType=DECIMAL}, ", "ext_2, ext_3)",
"#{couponId,jdbcType=BIGINT}, #{agentId,jdbcType=BIGINT}, ", "values (#{type,jdbcType=INTEGER}, #{couponName,jdbcType=VARCHAR}, ",
"#{stockCount,jdbcType=INTEGER}, #{salesCount,jdbcType=INTEGER}, ", "#{salesPrice,jdbcType=DECIMAL}, #{couponId,jdbcType=BIGINT}, ",
"#{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, ", "#{agentId,jdbcType=BIGINT}, #{stockCount,jdbcType=INTEGER}, ",
"#{operatorId,jdbcType=BIGINT}, #{operatorName,jdbcType=VARCHAR}, ", "#{salesCount,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ",
"#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" "#{status,jdbcType=INTEGER}, #{operatorId,jdbcType=BIGINT}, ",
"#{operatorName,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);
@ -62,6 +64,7 @@ public interface HighCouponAgentRelMapper extends HighCouponAgentRelMapperExt {
@SelectProvider(type=HighCouponAgentRelSqlProvider.class, method="selectByExample") @SelectProvider(type=HighCouponAgentRelSqlProvider.class, method="selectByExample")
@Results({ @Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
@Result(column="coupon_name", property="couponName", jdbcType=JdbcType.VARCHAR), @Result(column="coupon_name", property="couponName", jdbcType=JdbcType.VARCHAR),
@Result(column="sales_price", property="salesPrice", jdbcType=JdbcType.DECIMAL), @Result(column="sales_price", property="salesPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT),
@ -80,13 +83,14 @@ public interface HighCouponAgentRelMapper extends HighCouponAgentRelMapperExt {
@Select({ @Select({
"select", "select",
"id, coupon_name, sales_price, coupon_id, agent_id, stock_count, sales_count, ", "id, `type`, 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", "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}"
}) })
@Results({ @Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
@Result(column="coupon_name", property="couponName", jdbcType=JdbcType.VARCHAR), @Result(column="coupon_name", property="couponName", jdbcType=JdbcType.VARCHAR),
@Result(column="sales_price", property="salesPrice", jdbcType=JdbcType.DECIMAL), @Result(column="sales_price", property="salesPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT),
@ -114,7 +118,8 @@ public interface HighCouponAgentRelMapper extends HighCouponAgentRelMapperExt {
@Update({ @Update({
"update high_coupon_agent_rel", "update high_coupon_agent_rel",
"set coupon_name = #{couponName,jdbcType=VARCHAR},", "set `type` = #{type,jdbcType=INTEGER},",
"coupon_name = #{couponName,jdbcType=VARCHAR},",
"sales_price = #{salesPrice,jdbcType=DECIMAL},", "sales_price = #{salesPrice,jdbcType=DECIMAL},",
"coupon_id = #{couponId,jdbcType=BIGINT},", "coupon_id = #{couponId,jdbcType=BIGINT},",
"agent_id = #{agentId,jdbcType=BIGINT},", "agent_id = #{agentId,jdbcType=BIGINT},",

@ -47,6 +47,6 @@ public interface HighCouponAgentRelMapperExt {
}) })
List<HighCouponAgentCode> getAgentSalesCodeList(@Param("agentId") Long agentId, @Param("consumeTimeS")String consumeTimeS, @Param("consumeTimeE")String consumeTimeE); List<HighCouponAgentCode> getAgentSalesCodeList(@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}) ") @Select(" select count(1) from high_coupon_agent_code a where a.agent_id = #{agentId} and a.`status` in (#{status}) and a.type = #{type} ")
Integer getAgentCodeCount(@Param("agentId") Long agentId,@Param("status") String status); Integer getAgentCodeCount(@Param("agentId") Long agentId,@Param("status") String status,@Param("type") Integer type);
} }

@ -28,6 +28,10 @@ public class HighCouponAgentRelSqlProvider {
SQL sql = new SQL(); SQL sql = new SQL();
sql.INSERT_INTO("high_coupon_agent_rel"); sql.INSERT_INTO("high_coupon_agent_rel");
if (record.getType() != null) {
sql.VALUES("`type`", "#{type,jdbcType=INTEGER}");
}
if (record.getCouponName() != null) { if (record.getCouponName() != null) {
sql.VALUES("coupon_name", "#{couponName,jdbcType=VARCHAR}"); sql.VALUES("coupon_name", "#{couponName,jdbcType=VARCHAR}");
} }
@ -90,6 +94,7 @@ public class HighCouponAgentRelSqlProvider {
} else { } else {
sql.SELECT("id"); sql.SELECT("id");
} }
sql.SELECT("`type`");
sql.SELECT("coupon_name"); sql.SELECT("coupon_name");
sql.SELECT("sales_price"); sql.SELECT("sales_price");
sql.SELECT("coupon_id"); sql.SELECT("coupon_id");
@ -124,6 +129,10 @@ public class HighCouponAgentRelSqlProvider {
sql.SET("id = #{record.id,jdbcType=BIGINT}"); sql.SET("id = #{record.id,jdbcType=BIGINT}");
} }
if (record.getType() != null) {
sql.SET("`type` = #{record.type,jdbcType=INTEGER}");
}
if (record.getCouponName() != null) { if (record.getCouponName() != null) {
sql.SET("coupon_name = #{record.couponName,jdbcType=VARCHAR}"); sql.SET("coupon_name = #{record.couponName,jdbcType=VARCHAR}");
} }
@ -185,6 +194,7 @@ public class HighCouponAgentRelSqlProvider {
sql.UPDATE("high_coupon_agent_rel"); sql.UPDATE("high_coupon_agent_rel");
sql.SET("id = #{record.id,jdbcType=BIGINT}"); sql.SET("id = #{record.id,jdbcType=BIGINT}");
sql.SET("`type` = #{record.type,jdbcType=INTEGER}");
sql.SET("coupon_name = #{record.couponName,jdbcType=VARCHAR}"); sql.SET("coupon_name = #{record.couponName,jdbcType=VARCHAR}");
sql.SET("sales_price = #{record.salesPrice,jdbcType=DECIMAL}"); sql.SET("sales_price = #{record.salesPrice,jdbcType=DECIMAL}");
sql.SET("coupon_id = #{record.couponId,jdbcType=BIGINT}"); sql.SET("coupon_id = #{record.couponId,jdbcType=BIGINT}");
@ -208,6 +218,10 @@ public class HighCouponAgentRelSqlProvider {
SQL sql = new SQL(); SQL sql = new SQL();
sql.UPDATE("high_coupon_agent_rel"); sql.UPDATE("high_coupon_agent_rel");
if (record.getType() != null) {
sql.SET("`type` = #{type,jdbcType=INTEGER}");
}
if (record.getCouponName() != null) { if (record.getCouponName() != null) {
sql.SET("coupon_name = #{couponName,jdbcType=VARCHAR}"); sql.SET("coupon_name = #{couponName,jdbcType=VARCHAR}");
} }

@ -20,6 +20,11 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser
*/ */
private Long id; private Long id;
/**
* 类型 1销售码 2兑换码
*/
private Integer type;
/** /**
* 卡券和代理商的id * 卡券和代理商的id
*/ */
@ -36,14 +41,19 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser
private Long agentId; private Long agentId;
/** /**
* 销售码id * 卡券分配给代理商库存记录id
*/ */
private Long couponCodeId; private Long couponAgentRecordId;
/** /**
* 卡券分配给代理商库存记录id * 兑换码
*/ */
private Long couponAgentRecordId; private String convertCode;
/**
* 销售码id
*/
private Long couponCodeId;
/** /**
* 销售码 * 销售码
@ -96,6 +106,14 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser
this.id = id; this.id = id;
} }
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Long getCouponAgentId() { public Long getCouponAgentId() {
return couponAgentId; return couponAgentId;
} }
@ -120,14 +138,6 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser
this.agentId = agentId; this.agentId = agentId;
} }
public Long getCouponCodeId() {
return couponCodeId;
}
public void setCouponCodeId(Long couponCodeId) {
this.couponCodeId = couponCodeId;
}
public Long getCouponAgentRecordId() { public Long getCouponAgentRecordId() {
return couponAgentRecordId; return couponAgentRecordId;
} }
@ -136,6 +146,22 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser
this.couponAgentRecordId = couponAgentRecordId; this.couponAgentRecordId = couponAgentRecordId;
} }
public String getConvertCode() {
return convertCode;
}
public void setConvertCode(String convertCode) {
this.convertCode = convertCode;
}
public Long getCouponCodeId() {
return couponCodeId;
}
public void setCouponCodeId(Long couponCodeId) {
this.couponCodeId = couponCodeId;
}
public String getCouponCode() { public String getCouponCode() {
return couponCode; return couponCode;
} }
@ -229,11 +255,13 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser
} }
HighCouponAgentCode other = (HighCouponAgentCode) that; HighCouponAgentCode other = (HighCouponAgentCode) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
&& (this.getCouponAgentId() == null ? other.getCouponAgentId() == null : this.getCouponAgentId().equals(other.getCouponAgentId())) && (this.getCouponAgentId() == null ? other.getCouponAgentId() == null : this.getCouponAgentId().equals(other.getCouponAgentId()))
&& (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.getCouponCodeId() == null ? other.getCouponCodeId() == null : this.getCouponCodeId().equals(other.getCouponCodeId()))
&& (this.getCouponAgentRecordId() == null ? other.getCouponAgentRecordId() == null : this.getCouponAgentRecordId().equals(other.getCouponAgentRecordId())) && (this.getCouponAgentRecordId() == null ? other.getCouponAgentRecordId() == null : this.getCouponAgentRecordId().equals(other.getCouponAgentRecordId()))
&& (this.getConvertCode() == null ? other.getConvertCode() == null : this.getConvertCode().equals(other.getConvertCode()))
&& (this.getCouponCodeId() == null ? other.getCouponCodeId() == null : this.getCouponCodeId().equals(other.getCouponCodeId()))
&& (this.getCouponCode() == null ? other.getCouponCode() == null : this.getCouponCode().equals(other.getCouponCode())) && (this.getCouponCode() == null ? other.getCouponCode() == null : this.getCouponCode().equals(other.getCouponCode()))
&& (this.getQrCode() == null ? other.getQrCode() == null : this.getQrCode().equals(other.getQrCode())) && (this.getQrCode() == null ? other.getQrCode() == null : this.getQrCode().equals(other.getQrCode()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
@ -251,11 +279,13 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
result = prime * result + ((getCouponAgentId() == null) ? 0 : getCouponAgentId().hashCode()); result = prime * result + ((getCouponAgentId() == null) ? 0 : getCouponAgentId().hashCode());
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 + ((getCouponCodeId() == null) ? 0 : getCouponCodeId().hashCode());
result = prime * result + ((getCouponAgentRecordId() == null) ? 0 : getCouponAgentRecordId().hashCode()); result = prime * result + ((getCouponAgentRecordId() == null) ? 0 : getCouponAgentRecordId().hashCode());
result = prime * result + ((getConvertCode() == null) ? 0 : getConvertCode().hashCode());
result = prime * result + ((getCouponCodeId() == null) ? 0 : getCouponCodeId().hashCode());
result = prime * result + ((getCouponCode() == null) ? 0 : getCouponCode().hashCode()); result = prime * result + ((getCouponCode() == null) ? 0 : getCouponCode().hashCode());
result = prime * result + ((getQrCode() == null) ? 0 : getQrCode().hashCode()); result = prime * result + ((getQrCode() == null) ? 0 : getQrCode().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
@ -276,11 +306,13 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser
sb.append(" ["); sb.append(" [");
sb.append("Hash = ").append(hashCode()); sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id); sb.append(", id=").append(id);
sb.append(", type=").append(type);
sb.append(", couponAgentId=").append(couponAgentId); sb.append(", couponAgentId=").append(couponAgentId);
sb.append(", couponId=").append(couponId); sb.append(", couponId=").append(couponId);
sb.append(", agentId=").append(agentId); sb.append(", agentId=").append(agentId);
sb.append(", couponCodeId=").append(couponCodeId);
sb.append(", couponAgentRecordId=").append(couponAgentRecordId); sb.append(", couponAgentRecordId=").append(couponAgentRecordId);
sb.append(", convertCode=").append(convertCode);
sb.append(", couponCodeId=").append(couponCodeId);
sb.append(", couponCode=").append(couponCode); sb.append(", couponCode=").append(couponCode);
sb.append(", qrCode=").append(qrCode); sb.append(", qrCode=").append(qrCode);
sb.append(", status=").append(status); sb.append(", status=").append(status);

@ -185,6 +185,66 @@ public class HighCouponAgentCodeExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTypeIsNull() {
addCriterion("`type` is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("`type` is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(Integer value) {
addCriterion("`type` =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(Integer value) {
addCriterion("`type` <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(Integer value) {
addCriterion("`type` >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(Integer value) {
addCriterion("`type` >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(Integer value) {
addCriterion("`type` <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(Integer value) {
addCriterion("`type` <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<Integer> values) {
addCriterion("`type` in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<Integer> values) {
addCriterion("`type` not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(Integer value1, Integer value2) {
addCriterion("`type` between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(Integer value1, Integer value2) {
addCriterion("`type` not between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andCouponAgentIdIsNull() { public Criteria andCouponAgentIdIsNull() {
addCriterion("coupon_agent_id is null"); addCriterion("coupon_agent_id is null");
return (Criteria) this; return (Criteria) this;
@ -365,123 +425,193 @@ public class HighCouponAgentCodeExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponCodeIdIsNull() { public Criteria andCouponAgentRecordIdIsNull() {
addCriterion("coupon_code_id is null"); addCriterion("coupon_agent_record_id is null");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponCodeIdIsNotNull() { public Criteria andCouponAgentRecordIdIsNotNull() {
addCriterion("coupon_code_id is not null"); addCriterion("coupon_agent_record_id is not null");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponCodeIdEqualTo(Long value) { public Criteria andCouponAgentRecordIdEqualTo(Long value) {
addCriterion("coupon_code_id =", value, "couponCodeId"); addCriterion("coupon_agent_record_id =", value, "couponAgentRecordId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponCodeIdNotEqualTo(Long value) { public Criteria andCouponAgentRecordIdNotEqualTo(Long value) {
addCriterion("coupon_code_id <>", value, "couponCodeId"); addCriterion("coupon_agent_record_id <>", value, "couponAgentRecordId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponCodeIdGreaterThan(Long value) { public Criteria andCouponAgentRecordIdGreaterThan(Long value) {
addCriterion("coupon_code_id >", value, "couponCodeId"); addCriterion("coupon_agent_record_id >", value, "couponAgentRecordId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponCodeIdGreaterThanOrEqualTo(Long value) { public Criteria andCouponAgentRecordIdGreaterThanOrEqualTo(Long value) {
addCriterion("coupon_code_id >=", value, "couponCodeId"); addCriterion("coupon_agent_record_id >=", value, "couponAgentRecordId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponCodeIdLessThan(Long value) { public Criteria andCouponAgentRecordIdLessThan(Long value) {
addCriterion("coupon_code_id <", value, "couponCodeId"); addCriterion("coupon_agent_record_id <", value, "couponAgentRecordId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponCodeIdLessThanOrEqualTo(Long value) { public Criteria andCouponAgentRecordIdLessThanOrEqualTo(Long value) {
addCriterion("coupon_code_id <=", value, "couponCodeId"); addCriterion("coupon_agent_record_id <=", value, "couponAgentRecordId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponCodeIdIn(List<Long> values) { public Criteria andCouponAgentRecordIdIn(List<Long> values) {
addCriterion("coupon_code_id in", values, "couponCodeId"); addCriterion("coupon_agent_record_id in", values, "couponAgentRecordId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponCodeIdNotIn(List<Long> values) { public Criteria andCouponAgentRecordIdNotIn(List<Long> values) {
addCriterion("coupon_code_id not in", values, "couponCodeId"); addCriterion("coupon_agent_record_id not in", values, "couponAgentRecordId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponCodeIdBetween(Long value1, Long value2) { public Criteria andCouponAgentRecordIdBetween(Long value1, Long value2) {
addCriterion("coupon_code_id between", value1, value2, "couponCodeId"); addCriterion("coupon_agent_record_id between", value1, value2, "couponAgentRecordId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponCodeIdNotBetween(Long value1, Long value2) { public Criteria andCouponAgentRecordIdNotBetween(Long value1, Long value2) {
addCriterion("coupon_code_id not between", value1, value2, "couponCodeId"); addCriterion("coupon_agent_record_id not between", value1, value2, "couponAgentRecordId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponAgentRecordIdIsNull() { public Criteria andConvertCodeIsNull() {
addCriterion("coupon_agent_record_id is null"); addCriterion("convert_code is null");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponAgentRecordIdIsNotNull() { public Criteria andConvertCodeIsNotNull() {
addCriterion("coupon_agent_record_id is not null"); addCriterion("convert_code is not null");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponAgentRecordIdEqualTo(Long value) { public Criteria andConvertCodeEqualTo(String value) {
addCriterion("coupon_agent_record_id =", value, "couponAgentRecordId"); addCriterion("convert_code =", value, "convertCode");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponAgentRecordIdNotEqualTo(Long value) { public Criteria andConvertCodeNotEqualTo(String value) {
addCriterion("coupon_agent_record_id <>", value, "couponAgentRecordId"); addCriterion("convert_code <>", value, "convertCode");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponAgentRecordIdGreaterThan(Long value) { public Criteria andConvertCodeGreaterThan(String value) {
addCriterion("coupon_agent_record_id >", value, "couponAgentRecordId"); addCriterion("convert_code >", value, "convertCode");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponAgentRecordIdGreaterThanOrEqualTo(Long value) { public Criteria andConvertCodeGreaterThanOrEqualTo(String value) {
addCriterion("coupon_agent_record_id >=", value, "couponAgentRecordId"); addCriterion("convert_code >=", value, "convertCode");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponAgentRecordIdLessThan(Long value) { public Criteria andConvertCodeLessThan(String value) {
addCriterion("coupon_agent_record_id <", value, "couponAgentRecordId"); addCriterion("convert_code <", value, "convertCode");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponAgentRecordIdLessThanOrEqualTo(Long value) { public Criteria andConvertCodeLessThanOrEqualTo(String value) {
addCriterion("coupon_agent_record_id <=", value, "couponAgentRecordId"); addCriterion("convert_code <=", value, "convertCode");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponAgentRecordIdIn(List<Long> values) { public Criteria andConvertCodeLike(String value) {
addCriterion("coupon_agent_record_id in", values, "couponAgentRecordId"); addCriterion("convert_code like", value, "convertCode");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponAgentRecordIdNotIn(List<Long> values) { public Criteria andConvertCodeNotLike(String value) {
addCriterion("coupon_agent_record_id not in", values, "couponAgentRecordId"); addCriterion("convert_code not like", value, "convertCode");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponAgentRecordIdBetween(Long value1, Long value2) { public Criteria andConvertCodeIn(List<String> values) {
addCriterion("coupon_agent_record_id between", value1, value2, "couponAgentRecordId"); addCriterion("convert_code in", values, "convertCode");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCouponAgentRecordIdNotBetween(Long value1, Long value2) { public Criteria andConvertCodeNotIn(List<String> values) {
addCriterion("coupon_agent_record_id not between", value1, value2, "couponAgentRecordId"); addCriterion("convert_code not in", values, "convertCode");
return (Criteria) this;
}
public Criteria andConvertCodeBetween(String value1, String value2) {
addCriterion("convert_code between", value1, value2, "convertCode");
return (Criteria) this;
}
public Criteria andConvertCodeNotBetween(String value1, String value2) {
addCriterion("convert_code not between", value1, value2, "convertCode");
return (Criteria) this;
}
public Criteria andCouponCodeIdIsNull() {
addCriterion("coupon_code_id is null");
return (Criteria) this;
}
public Criteria andCouponCodeIdIsNotNull() {
addCriterion("coupon_code_id is not null");
return (Criteria) this;
}
public Criteria andCouponCodeIdEqualTo(Long value) {
addCriterion("coupon_code_id =", value, "couponCodeId");
return (Criteria) this;
}
public Criteria andCouponCodeIdNotEqualTo(Long value) {
addCriterion("coupon_code_id <>", value, "couponCodeId");
return (Criteria) this;
}
public Criteria andCouponCodeIdGreaterThan(Long value) {
addCriterion("coupon_code_id >", value, "couponCodeId");
return (Criteria) this;
}
public Criteria andCouponCodeIdGreaterThanOrEqualTo(Long value) {
addCriterion("coupon_code_id >=", value, "couponCodeId");
return (Criteria) this;
}
public Criteria andCouponCodeIdLessThan(Long value) {
addCriterion("coupon_code_id <", value, "couponCodeId");
return (Criteria) this;
}
public Criteria andCouponCodeIdLessThanOrEqualTo(Long value) {
addCriterion("coupon_code_id <=", value, "couponCodeId");
return (Criteria) this;
}
public Criteria andCouponCodeIdIn(List<Long> values) {
addCriterion("coupon_code_id in", values, "couponCodeId");
return (Criteria) this;
}
public Criteria andCouponCodeIdNotIn(List<Long> values) {
addCriterion("coupon_code_id not in", values, "couponCodeId");
return (Criteria) this;
}
public Criteria andCouponCodeIdBetween(Long value1, Long value2) {
addCriterion("coupon_code_id between", value1, value2, "couponCodeId");
return (Criteria) this;
}
public Criteria andCouponCodeIdNotBetween(Long value1, Long value2) {
addCriterion("coupon_code_id not between", value1, value2, "couponCodeId");
return (Criteria) this; return (Criteria) this;
} }

@ -21,6 +21,11 @@ public class HighCouponAgentRel extends HighCouponAgentRelModel implements Seria
*/ */
private Long id; private Long id;
/**
* 类型 1销售码 2兑换码
*/
private Integer type;
/** /**
* 卡券名称 * 卡券名称
*/ */
@ -87,6 +92,14 @@ public class HighCouponAgentRel extends HighCouponAgentRelModel implements Seria
this.id = id; this.id = id;
} }
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getCouponName() { public String getCouponName() {
return couponName; return couponName;
} }
@ -204,6 +217,7 @@ public class HighCouponAgentRel extends HighCouponAgentRelModel implements Seria
} }
HighCouponAgentRel other = (HighCouponAgentRel) that; HighCouponAgentRel other = (HighCouponAgentRel) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
&& (this.getCouponName() == null ? other.getCouponName() == null : this.getCouponName().equals(other.getCouponName())) && (this.getCouponName() == null ? other.getCouponName() == null : this.getCouponName().equals(other.getCouponName()))
&& (this.getSalesPrice() == null ? other.getSalesPrice() == null : this.getSalesPrice().equals(other.getSalesPrice())) && (this.getSalesPrice() == null ? other.getSalesPrice() == null : this.getSalesPrice().equals(other.getSalesPrice()))
&& (this.getCouponId() == null ? other.getCouponId() == null : this.getCouponId().equals(other.getCouponId())) && (this.getCouponId() == null ? other.getCouponId() == null : this.getCouponId().equals(other.getCouponId()))
@ -224,6 +238,7 @@ public class HighCouponAgentRel extends HighCouponAgentRelModel implements Seria
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
result = prime * result + ((getCouponName() == null) ? 0 : getCouponName().hashCode()); result = prime * result + ((getCouponName() == null) ? 0 : getCouponName().hashCode());
result = prime * result + ((getSalesPrice() == null) ? 0 : getSalesPrice().hashCode()); result = prime * result + ((getSalesPrice() == null) ? 0 : getSalesPrice().hashCode());
result = prime * result + ((getCouponId() == null) ? 0 : getCouponId().hashCode()); result = prime * result + ((getCouponId() == null) ? 0 : getCouponId().hashCode());
@ -247,6 +262,7 @@ public class HighCouponAgentRel extends HighCouponAgentRelModel implements Seria
sb.append(" ["); sb.append(" [");
sb.append("Hash = ").append(hashCode()); sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id); sb.append(", id=").append(id);
sb.append(", type=").append(type);
sb.append(", couponName=").append(couponName); sb.append(", couponName=").append(couponName);
sb.append(", salesPrice=").append(salesPrice); sb.append(", salesPrice=").append(salesPrice);
sb.append(", couponId=").append(couponId); sb.append(", couponId=").append(couponId);

@ -186,6 +186,66 @@ public class HighCouponAgentRelExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTypeIsNull() {
addCriterion("`type` is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("`type` is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(Integer value) {
addCriterion("`type` =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(Integer value) {
addCriterion("`type` <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(Integer value) {
addCriterion("`type` >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(Integer value) {
addCriterion("`type` >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(Integer value) {
addCriterion("`type` <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(Integer value) {
addCriterion("`type` <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<Integer> values) {
addCriterion("`type` in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<Integer> values) {
addCriterion("`type` not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(Integer value1, Integer value2) {
addCriterion("`type` between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(Integer value1, Integer value2) {
addCriterion("`type` not between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andCouponNameIsNull() { public Criteria andCouponNameIsNull() {
addCriterion("coupon_name is null"); addCriterion("coupon_name is null");
return (Criteria) this; return (Criteria) this;

@ -35,7 +35,7 @@ public interface HighCouponAgentService {
* @Description 根据卡券id和代理商id 查询 * @Description 根据卡券id和代理商id 查询
* @Date 2021/4/20 23:52 * @Date 2021/4/20 23:52
**/ **/
HighCouponAgentRel getRelByCouponAgent(Long couponId,Long agentId); HighCouponAgentRel getRelByCouponAgent(Long couponId,Long agentId, Integer type);
/** /**
* @Author 胡锐 * @Author 胡锐
@ -78,7 +78,7 @@ public interface HighCouponAgentService {
* @Description 根据代理商 查询销售统计 * @Description 根据代理商 查询销售统计
* @Date 2021/4/22 22:26 * @Date 2021/4/22 22:26
**/ **/
Map<String, Object> getSalesCountByAgent(Long agentId) throws Exception; Map<String, Object> getSalesCountByAgent(Long agentId, Integer type) throws Exception;
/** /**
* *
@ -104,4 +104,25 @@ public interface HighCouponAgentService {
*/ */
List<HighCouponAgentCode> getAgentSalesCodeList(Long agentId,String consumeTimeS,String consumeTimeE); List<HighCouponAgentCode> getAgentSalesCodeList(Long agentId,String consumeTimeS,String consumeTimeE);
/**
* 生成兑换码
* @param couponAgentRelId
* @return
*/
String generateConvertCode(Long couponAgentRelId);
/**
* 查询兑换码
* @param convertCode
* @return
*/
HighCouponAgentCode getConvertCode(String convertCode);
/**
* 使用兑换码
* @param code
* @return
*/
String useConvertCode(String code);
} }

@ -1,6 +1,7 @@
package com.hai.service.impl; package com.hai.service.impl;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.hai.common.GenerateCode;
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;
@ -15,6 +16,7 @@ import com.hai.service.*;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -54,13 +56,9 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
private HighAgentService highAgentService; private HighAgentService highAgentService;
@Override @Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void assignCouponAgent(HighCouponAgentRel highCouponAgentRel,Integer stockCount) { public void assignCouponAgent(HighCouponAgentRel highCouponAgentRel,Integer stockCount) {
// 查询未销售的卡券
List<HighCouponCode> codeList = highCouponCodeService.getNoSaleCode(highCouponAgentRel.getCouponId());
if (stockCount > codeList.size()) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法分配,分配数量超过库存数量");
}
if (highCouponAgentRel.getId() != null) { if (highCouponAgentRel.getId() != null) {
highCouponAgentRelMapper.updateByPrimaryKey(highCouponAgentRel); highCouponAgentRelMapper.updateByPrimaryKey(highCouponAgentRel);
} else { } else {
@ -87,26 +85,50 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
record.setCreateTime(new Date()); record.setCreateTime(new Date());
highCouponAgentRecordMapper.insert(record); highCouponAgentRecordMapper.insert(record);
List<HighCouponCode> assignCouponCodeList = codeList.stream().limit(stockCount).collect(Collectors.toList()); if (highCouponAgentRel.getType() == 1) {
HighCouponAgentCode highCouponAgentCode; // 查询未销售的卡券
for (HighCouponCode code : assignCouponCodeList) { List<HighCouponCode> codeList = highCouponCodeService.getNoSaleCode(highCouponAgentRel.getCouponId());
code.setAgentId(highCouponAgentRel.getAgentId()); if (stockCount > codeList.size()) {
code.setIsAssignAgent(true); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法分配,分配数量超过库存数量");
highCouponCodeService.updateCouponCode(code); }
List<HighCouponCode> assignCouponCodeList = codeList.stream().limit(stockCount).collect(Collectors.toList());
highCouponAgentCode = new HighCouponAgentCode(); HighCouponAgentCode highCouponAgentCode;
highCouponAgentCode.setCouponAgentId(highCouponAgentRel.getId()); for (HighCouponCode code : assignCouponCodeList) {
highCouponAgentCode.setCouponAgentRecordId(record.getId()); code.setAgentId(highCouponAgentRel.getAgentId());
highCouponAgentCode.setCouponId(code.getCouponId()); code.setIsAssignAgent(true);
highCouponAgentCode.setAgentId(highCouponAgentRel.getAgentId()); highCouponCodeService.updateCouponCode(code);
highCouponAgentCode.setCouponCodeId(code.getId());
highCouponAgentCode.setCouponCode(code.getSalesCode()); highCouponAgentCode = new HighCouponAgentCode();
highCouponAgentCode.setQrCode(code.getExt1()); highCouponAgentCode.setCouponAgentId(highCouponAgentRel.getId());
highCouponAgentCode.setStatus(1); highCouponAgentCode.setCouponAgentRecordId(record.getId());
highCouponAgentCode.setCreateTime(new Date()); highCouponAgentCode.setCouponId(code.getCouponId());
highCouponAgentCode.setOperatorId(highCouponAgentRel.getOperatorId()); highCouponAgentCode.setAgentId(highCouponAgentRel.getAgentId());
highCouponAgentCode.setOperatorName(highCouponAgentRel.getOperatorName()); highCouponAgentCode.setCouponCodeId(code.getId());
highCouponAgentCodeMapper.insert(highCouponAgentCode); highCouponAgentCode.setCouponCode(code.getSalesCode());
highCouponAgentCode.setQrCode(code.getExt1());
highCouponAgentCode.setStatus(1);
highCouponAgentCode.setCreateTime(new Date());
highCouponAgentCode.setOperatorId(highCouponAgentRel.getOperatorId());
highCouponAgentCode.setOperatorName(highCouponAgentRel.getOperatorName());
highCouponAgentCodeMapper.insert(highCouponAgentCode);
}
}
if (highCouponAgentRel.getType() == 2) {
HighCouponAgentCode highCouponAgentCode;
for (int i = 0; i < stockCount; i++) {
highCouponAgentCode = new HighCouponAgentCode();
highCouponAgentCode.setCouponAgentId(highCouponAgentRel.getId());
highCouponAgentCode.setCouponAgentRecordId(record.getId());
highCouponAgentCode.setCouponId(highCoupon.getId());
highCouponAgentCode.setAgentId(highCouponAgentRel.getAgentId());
highCouponAgentCode.setConvertCode(generateConvertCode(highCouponAgentRel.getId()));
highCouponAgentCode.setStatus(1);
highCouponAgentCode.setCreateTime(new Date());
highCouponAgentCode.setOperatorId(highCouponAgentRel.getOperatorId());
highCouponAgentCode.setOperatorName(highCouponAgentRel.getOperatorName());
highCouponAgentCodeMapper.insert(highCouponAgentCode);
}
} }
} }
@ -116,9 +138,9 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
} }
@Override @Override
public HighCouponAgentRel getRelByCouponAgent(Long couponId, Long agentId) { public HighCouponAgentRel getRelByCouponAgent(Long couponId, Long agentId,Integer type) {
HighCouponAgentRelExample example = new HighCouponAgentRelExample(); HighCouponAgentRelExample example = new HighCouponAgentRelExample();
example.createCriteria().andCouponIdEqualTo(couponId).andAgentIdEqualTo(agentId); example.createCriteria().andCouponIdEqualTo(couponId).andAgentIdEqualTo(agentId).andTypeEqualTo(type);
List<HighCouponAgentRel> list = highCouponAgentRelMapper.selectByExample(example); List<HighCouponAgentRel> list = highCouponAgentRelMapper.selectByExample(example);
if (list != null && list.size() > 0) { if (list != null && list.size() > 0) {
return list.get(0); return list.get(0);
@ -131,6 +153,10 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
HighCouponAgentRelExample example = new HighCouponAgentRelExample(); HighCouponAgentRelExample example = new HighCouponAgentRelExample();
HighCouponAgentRelExample.Criteria criteria = example.createCriteria(); HighCouponAgentRelExample.Criteria criteria = example.createCriteria();
if (MapUtils.getInteger(map, "type") != null) {
criteria.andTypeEqualTo(MapUtils.getInteger(map, "type"));
}
if (MapUtils.getLong(map, "couponId") != null) { if (MapUtils.getLong(map, "couponId") != null) {
criteria.andCouponIdEqualTo(MapUtils.getLong(map, "couponId")); criteria.andCouponIdEqualTo(MapUtils.getLong(map, "couponId"));
} }
@ -213,15 +239,19 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
couponAgentCode.setRemark(remark); couponAgentCode.setRemark(remark);
highCouponAgentCodeMapper.updateByPrimaryKey(couponAgentCode); highCouponAgentCodeMapper.updateByPrimaryKey(couponAgentCode);
HighCouponAgentRel couponAgent = getRelByCouponAgent(couponAgentCode.getCouponId(), couponAgentCode.getAgentId()); HighCouponAgentRel couponAgent = getRelByCouponAgent(couponAgentCode.getCouponId(), couponAgentCode.getAgentId(), couponAgentCode.getType());
couponAgent.setStockCount(couponAgent.getStockCount() - 1); couponAgent.setStockCount(couponAgent.getStockCount() - 1);
couponAgent.setSalesCount(couponAgent.getSalesCount() + 1); couponAgent.setSalesCount(couponAgent.getSalesCount() + 1);
highCouponAgentRelMapper.updateByPrimaryKey(couponAgent); highCouponAgentRelMapper.updateByPrimaryKey(couponAgent);
HighCouponCode couponCode = highCouponCodeService.getCouponCodeById(couponAgentCode.getCouponCodeId());
couponCode.setStatus(2); HighCouponCode couponCode = null;
couponCode.setReceiveTime(new Date()); if (couponAgentCode.getType() == 1) {
highCouponCodeService.updateCouponCode(couponCode); couponCode = highCouponCodeService.getCouponCodeById(couponAgentCode.getCouponCodeId());
couponCode.setStatus(2);
couponCode.setReceiveTime(new Date());
highCouponCodeService.updateCouponCode(couponCode);
}
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("couponInfo", highCouponService.getCouponById(couponAgentCode.getCouponId())); map.put("couponInfo", highCouponService.getCouponById(couponAgentCode.getCouponId()));
@ -231,12 +261,13 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
} }
@Override @Override
public Map<String, Object> getSalesCountByAgent(Long agentId) throws Exception { public Map<String, Object> getSalesCountByAgent(Long agentId, Integer type) throws Exception {
BigDecimal surplusCountPrice = new BigDecimal("0"); BigDecimal surplusCountPrice = new BigDecimal("0");
BigDecimal salesCountPrice = new BigDecimal("0"); BigDecimal salesCountPrice = new BigDecimal("0");
Map<String,Object> listMap = new HashMap<>(); Map<String,Object> listMap = new HashMap<>();
listMap.put("agentId", agentId); listMap.put("agentId", agentId);
listMap.put("type", type);
List<HighCouponAgentRel> list = getCouponAgentList(listMap).stream().sorted(Comparator.comparing(HighCouponAgentRel::getSalesPrice)).collect(Collectors.toList()); List<HighCouponAgentRel> list = getCouponAgentList(listMap).stream().sorted(Comparator.comparing(HighCouponAgentRel::getSalesPrice)).collect(Collectors.toList());
for (HighCouponAgentRel highCouponAgentRel : list) { for (HighCouponAgentRel highCouponAgentRel : list) {
BigDecimal surplusPrice = new BigDecimal(highCouponAgentRel.getStockCount()).multiply((highCouponAgentRel.getSalesPrice())); BigDecimal surplusPrice = new BigDecimal(highCouponAgentRel.getStockCount()).multiply((highCouponAgentRel.getSalesPrice()));
@ -246,7 +277,7 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
salesCountPrice = salesCountPrice.add(salesPrice); salesCountPrice = salesCountPrice.add(salesPrice);
} }
// 计算使用有效期 // 当前日时间
Calendar consumeTimeS = Calendar.getInstance(); Calendar consumeTimeS = Calendar.getInstance();
consumeTimeS.setTime(new Date()); consumeTimeS.setTime(new Date());
consumeTimeS.set(Calendar.HOUR_OF_DAY, 00); consumeTimeS.set(Calendar.HOUR_OF_DAY, 00);
@ -265,8 +296,8 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
returnMap.put("orderCount", agentSales.getCount()); returnMap.put("orderCount", agentSales.getCount());
returnMap.put("turnoverPrice", agentSales.getSalesCountPrice()); returnMap.put("turnoverPrice", agentSales.getSalesCountPrice());
returnMap.put("laveStockCount", highCouponAgentRelMapper.getAgentCodeCount(agentId, "1")); // 库存数量 returnMap.put("laveStockCount", highCouponAgentRelMapper.getAgentCodeCount(agentId, "1", type)); // 库存数量
returnMap.put("soldCount", highCouponAgentRelMapper.getAgentCodeCount(agentId, "2,3")); // 销售数量 returnMap.put("soldCount", highCouponAgentRelMapper.getAgentCodeCount(agentId, "2,3", type)); // 销售数量
returnMap.put("surplusCountPrice", surplusCountPrice); // 剩余总额 returnMap.put("surplusCountPrice", surplusCountPrice); // 剩余总额
returnMap.put("salesCountPrice", salesCountPrice); // 销售总额 returnMap.put("salesCountPrice", salesCountPrice); // 销售总额
@ -312,4 +343,52 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
} }
return new ArrayList<>(); return new ArrayList<>();
} }
@Override
public String generateConvertCode(Long couponAgentRelId) {
// 生成兑换码
String code = GenerateCode.convertCode(couponAgentRelId);
if (getConvertCode(code) != null){
return generateConvertCode(couponAgentRelId);
}
return code;
}
@Override
public HighCouponAgentCode getConvertCode(String convertCode) {
HighCouponAgentCodeExample example = new HighCouponAgentCodeExample();
example.createCriteria().andConvertCodeEqualTo(convertCode);
List<HighCouponAgentCode> list = highCouponAgentCodeMapper.selectByExample(example);
if (list.size() > 0) {
return list.get(0);
}
return null;
}
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW,isolation= Isolation.SERIALIZABLE)
public String useConvertCode(String code) {
// 查询兑换码
HighCouponAgentCode convertCode = getConvertCode(code);
if (convertCode == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无效的兑换码");
}
if (convertCode.getStatus() != 1) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "兑换码已被使用");
}
// 查询未销售的卡券
List<HighCouponCode> codeList = highCouponCodeService.getNoSaleCode(convertCode.getCouponId());
if (codeList.size() == 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法使用兑换码");
}
HighCouponCode couponCode = codeList.get(0);
convertCode.setCouponCodeId(couponCode.getId());
convertCode.setCouponCode(couponCode.getSalesCode());
convertCode.setQrCode(couponCode.getExt1());
convertCode.setStatus(2);
highCouponAgentCodeMapper.updateByPrimaryKey(convertCode);
return "/couponCode/"+couponCode.getExt1();
}
} }

Loading…
Cancel
Save