'完成限购、归库'

dev-discount
199901012 4 years ago
parent a28cbf77be
commit 16ceac2b98
  1. 45
      hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java
  2. 7
      hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java
  3. 4
      hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java
  4. 2
      hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java
  5. 35
      hai-service/src/main/java/com/hai/dao/HighChildOrderMapper.java
  6. 14
      hai-service/src/main/java/com/hai/dao/HighChildOrderSqlProvider.java
  7. 14
      hai-service/src/main/java/com/hai/dao/HighCouponRecycleMapper.java
  8. 20
      hai-service/src/main/java/com/hai/dao/HighCouponRecycleSqlProvider.java
  9. 17
      hai-service/src/main/java/com/hai/entity/HighChildOrder.java
  10. 60
      hai-service/src/main/java/com/hai/entity/HighChildOrderExample.java
  11. 32
      hai-service/src/main/java/com/hai/entity/HighCouponRecycle.java
  12. 120
      hai-service/src/main/java/com/hai/entity/HighCouponRecycleExample.java
  13. 11
      hai-service/src/main/java/com/hai/model/HighCouponModel.java
  14. 1
      hai-service/src/main/java/com/hai/service/HighCouponCodeService.java
  15. 29
      hai-service/src/main/java/com/hai/service/HighCouponRecycleService.java
  16. 11
      hai-service/src/main/java/com/hai/service/HighCouponService.java
  17. 7
      hai-service/src/main/java/com/hai/service/HighOrderService.java
  18. 8
      hai-service/src/main/java/com/hai/service/HighUserCouponService.java
  19. 7
      hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java
  20. 47
      hai-service/src/main/java/com/hai/service/impl/HighCouponRecycleServiceImpl.java
  21. 25
      hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java
  22. 46
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java
  23. 67
      hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java
  24. 21
      hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java

@ -9,6 +9,7 @@ import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter; import com.hai.common.security.UserCenter;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.BsCompany; import com.hai.entity.BsCompany;
import com.hai.entity.HighCoupon;
import com.hai.entity.HighUserCoupon; import com.hai.entity.HighUserCoupon;
import com.hai.model.HighUserCouponModel; import com.hai.model.HighUserCouponModel;
import com.hai.model.HighUserModel; import com.hai.model.HighUserModel;
@ -51,6 +52,9 @@ public class HighCouponController {
@Resource @Resource
private HighCouponCodeService highCouponCodeService; private HighCouponCodeService highCouponCodeService;
@Resource
private HighOrderService highOrderService;
@Resource @Resource
private HighUserCouponService highUserCouponService; private HighUserCouponService highUserCouponService;
@ -90,10 +94,15 @@ public class HighCouponController {
@RequestMapping(value="/getCouponById",method = RequestMethod.GET) @RequestMapping(value="/getCouponById",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "卡卷信息") @ApiOperation(value = "卡卷信息")
public ResponseData getCouponById(@RequestParam(name = "couponId", required = true) Long couponId) { public ResponseData getCouponById(@RequestParam(name = "userId", required = false) Long userId,
@RequestParam(name = "couponId", required = true) Long couponId) {
try { try {
return ResponseMsgUtil.success(highCouponService.getCouponById(couponId)); HighCoupon coupon = highCouponService.getCouponById(couponId);
if (coupon != null & userId != null) {
coupon.setNumberUpperLimitStatus(highCouponService.userBuyLimitNumber(userId,coupon.getId()));
}
return ResponseMsgUtil.success(coupon);
} catch (Exception e) { } catch (Exception e) {
log.error("HighCouponController -> getCouponById() error!",e); log.error("HighCouponController -> getCouponById() error!",e);
@ -101,8 +110,6 @@ public class HighCouponController {
} }
} }
@RequestMapping(value = "/getUserCouponList", method = RequestMethod.GET) @RequestMapping(value = "/getUserCouponList", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "获取用户卡卷列表") @ApiOperation(value = "获取用户卡卷列表")
@ -129,10 +136,9 @@ public class HighCouponController {
} }
} }
@RequestMapping(value = "/getUserCouponDetail", method = RequestMethod.GET) @RequestMapping(value = "/getUserCouponDetail", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "获取用户卡卷") @ApiOperation(value = "获取用户卡卷详细")
public ResponseData getUserCouponDetail(@RequestParam(name = "couponId", required = true) Long couponId, public ResponseData getUserCouponDetail(@RequestParam(name = "couponId", required = true) Long couponId,
HttpServletRequest request) { HttpServletRequest request) {
try { try {
@ -161,4 +167,31 @@ public class HighCouponController {
} }
@RequestMapping(value = "/againReceiveCoupon", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "卡卷过期,再次领取")
public ResponseData againReceiveCoupon(@RequestParam(name = "couponId", required = true) Long couponId,
HttpServletRequest request) {
try {
// 用户
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
// 重新领取
HighUserCoupon userCoupon = highUserCouponService.againReceiveCoupon(userInfoModel.getHighUser().getId(), couponId);
Map<String, Object> map = new HashMap<>();
map.put("highUserCoupon", "coupon");
map.put("couponInfo", highCouponService.getCouponById(userCoupon.getCouponId()));
map.put("couponCodeInfo", highCouponCodeService.getCouponCodeById(userCoupon.getCouponCodeId()));
return ResponseMsgUtil.success(map);
} catch (Exception e) {
log.error("HighCouponController --> getUserCouponList() error!", e);
return ResponseMsgUtil.exception(e);
}
}
} }

@ -96,12 +96,15 @@ public class HighOrderController {
log.error("HighOrderController --> addOrder() error!", "未找到卡卷信息"); log.error("HighOrderController --> addOrder() error!", "未找到卡卷信息");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, "");
} }
// 是否到底限购数量
if (highCouponService.userBuyLimitNumber(userInfoModel.getHighUser().getId(), coupon.getId()) == true) {
log.error("HighOrderController --> addOrder() error!", "已达到限购数量");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, coupon.getCouponName() + ",已达到限购数量");
}
if (highCouponCodeService.getStockCountByCoupon(coupon.getId()) <= 0) { if (highCouponCodeService.getStockCountByCoupon(coupon.getId()) <= 0) {
log.error("HighOrderController --> addOrder() error!", "卡卷库存数量不足"); log.error("HighOrderController --> addOrder() error!", "卡卷库存数量不足");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COUPON_STOCK_INSUFFICIENT, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.COUPON_STOCK_INSUFFICIENT, "");
} }
childOrder.setGoodsName(coupon.getCouponName()); childOrder.setGoodsName(coupon.getCouponName());
childOrder.setGoodsImg(coupon.getCouponImg()); childOrder.setGoodsImg(coupon.getCouponImg());
childOrder.setGoodsSpecName("默认"); childOrder.setGoodsSpecName("默认");

@ -123,8 +123,8 @@ public class OrderController {
map.put("orderNo", order.getOrderNo()); map.put("orderNo", order.getOrderNo());
map.put("payPrice", order.getPayPrice()); map.put("payPrice", order.getPayPrice());
map.put("orderScene", orderScene); map.put("orderScene", orderScene);
map.put("body","购买卡券"); map.put("body","购买产品");
map.put("subject","购买卡券"); map.put("subject","购买产品");
//微信支付 //微信支付
String nonce_str = MD5Util.MD5Encode(String.valueOf(ThreadLocalRandom.current().nextInt(10000)), "UTF-8"); String nonce_str = MD5Util.MD5Encode(String.valueOf(ThreadLocalRandom.current().nextInt(10000)), "UTF-8");

@ -21,7 +21,7 @@ public class HighCouponSchedule {
// @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 // @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
// @Scheduled(cron = "0 0 0 * * ?") //每天 凌晨0点执行 // @Scheduled(cron = "0 0 0 * * ?") //每天 凌晨0点执行
public void certification() { public void expiredCoupon() {
List<HighUserCoupon> userCoupons = highUserCouponService.getOverdueCoupon(); List<HighUserCoupon> userCoupons = highUserCouponService.getOverdueCoupon();
for (HighUserCoupon highUserCoupon : userCoupons) { for (HighUserCoupon highUserCoupon : userCoupons) {
highUserCoupon.setStatus(0); // 状态 0:已过期 1:未使用 2:已使用 highUserCoupon.setStatus(0); // 状态 0:已过期 1:未使用 2:已使用

@ -39,20 +39,22 @@ public interface HighChildOrderMapper extends HighChildOrderMapperExt {
int deleteByPrimaryKey(Long id); int deleteByPrimaryKey(Long id);
@Insert({ @Insert({
"insert into high_child_order (order_id, goods_type, ", "insert into high_child_order (order_id, mem_id, ",
"goods_id, goods_name, ", "goods_type, goods_id, ",
"goods_img, goods_spec_name, ", "goods_name, goods_img, ",
"goods_price, sale_count, ", "goods_spec_name, goods_price, ",
"total_price, giveaway_type, ", "sale_count, total_price, ",
"child_orde_status, praise_status, ", "giveaway_type, child_orde_status, ",
"ext_1, ext_2, ext_3)", "praise_status, ext_1, ",
"values (#{orderId,jdbcType=BIGINT}, #{goodsType,jdbcType=INTEGER}, ", "ext_2, ext_3)",
"#{goodsId,jdbcType=BIGINT}, #{goodsName,jdbcType=VARCHAR}, ", "values (#{orderId,jdbcType=BIGINT}, #{memId,jdbcType=BIGINT}, ",
"#{goodsImg,jdbcType=VARCHAR}, #{goodsSpecName,jdbcType=VARCHAR}, ", "#{goodsType,jdbcType=INTEGER}, #{goodsId,jdbcType=BIGINT}, ",
"#{goodsPrice,jdbcType=DECIMAL}, #{saleCount,jdbcType=INTEGER}, ", "#{goodsName,jdbcType=VARCHAR}, #{goodsImg,jdbcType=VARCHAR}, ",
"#{totalPrice,jdbcType=DECIMAL}, #{giveawayType,jdbcType=BIT}, ", "#{goodsSpecName,jdbcType=VARCHAR}, #{goodsPrice,jdbcType=DECIMAL}, ",
"#{childOrdeStatus,jdbcType=INTEGER}, #{praiseStatus,jdbcType=INTEGER}, ", "#{saleCount,jdbcType=INTEGER}, #{totalPrice,jdbcType=DECIMAL}, ",
"#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" "#{giveawayType,jdbcType=BIT}, #{childOrdeStatus,jdbcType=INTEGER}, ",
"#{praiseStatus,jdbcType=INTEGER}, #{ext1,jdbcType=VARCHAR}, ",
"#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
}) })
@Options(useGeneratedKeys=true,keyProperty="id") @Options(useGeneratedKeys=true,keyProperty="id")
int insert(HighChildOrder record); int insert(HighChildOrder record);
@ -65,6 +67,7 @@ public interface HighChildOrderMapper extends HighChildOrderMapperExt {
@Results({ @Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="order_id", property="orderId", jdbcType=JdbcType.BIGINT), @Result(column="order_id", property="orderId", jdbcType=JdbcType.BIGINT),
@Result(column="mem_id", property="memId", jdbcType=JdbcType.BIGINT),
@Result(column="goods_type", property="goodsType", jdbcType=JdbcType.INTEGER), @Result(column="goods_type", property="goodsType", jdbcType=JdbcType.INTEGER),
@Result(column="goods_id", property="goodsId", jdbcType=JdbcType.BIGINT), @Result(column="goods_id", property="goodsId", jdbcType=JdbcType.BIGINT),
@Result(column="goods_name", property="goodsName", jdbcType=JdbcType.VARCHAR), @Result(column="goods_name", property="goodsName", jdbcType=JdbcType.VARCHAR),
@ -84,7 +87,7 @@ public interface HighChildOrderMapper extends HighChildOrderMapperExt {
@Select({ @Select({
"select", "select",
"id, order_id, goods_type, goods_id, goods_name, goods_img, goods_spec_name, ", "id, order_id, mem_id, goods_type, goods_id, goods_name, goods_img, goods_spec_name, ",
"goods_price, sale_count, total_price, giveaway_type, child_orde_status, praise_status, ", "goods_price, sale_count, total_price, giveaway_type, child_orde_status, praise_status, ",
"ext_1, ext_2, ext_3", "ext_1, ext_2, ext_3",
"from high_child_order", "from high_child_order",
@ -93,6 +96,7 @@ public interface HighChildOrderMapper extends HighChildOrderMapperExt {
@Results({ @Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="order_id", property="orderId", jdbcType=JdbcType.BIGINT), @Result(column="order_id", property="orderId", jdbcType=JdbcType.BIGINT),
@Result(column="mem_id", property="memId", jdbcType=JdbcType.BIGINT),
@Result(column="goods_type", property="goodsType", jdbcType=JdbcType.INTEGER), @Result(column="goods_type", property="goodsType", jdbcType=JdbcType.INTEGER),
@Result(column="goods_id", property="goodsId", jdbcType=JdbcType.BIGINT), @Result(column="goods_id", property="goodsId", jdbcType=JdbcType.BIGINT),
@Result(column="goods_name", property="goodsName", jdbcType=JdbcType.VARCHAR), @Result(column="goods_name", property="goodsName", jdbcType=JdbcType.VARCHAR),
@ -122,6 +126,7 @@ public interface HighChildOrderMapper extends HighChildOrderMapperExt {
@Update({ @Update({
"update high_child_order", "update high_child_order",
"set order_id = #{orderId,jdbcType=BIGINT},", "set order_id = #{orderId,jdbcType=BIGINT},",
"mem_id = #{memId,jdbcType=BIGINT},",
"goods_type = #{goodsType,jdbcType=INTEGER},", "goods_type = #{goodsType,jdbcType=INTEGER},",
"goods_id = #{goodsId,jdbcType=BIGINT},", "goods_id = #{goodsId,jdbcType=BIGINT},",
"goods_name = #{goodsName,jdbcType=VARCHAR},", "goods_name = #{goodsName,jdbcType=VARCHAR},",

@ -32,6 +32,10 @@ public class HighChildOrderSqlProvider {
sql.VALUES("order_id", "#{orderId,jdbcType=BIGINT}"); sql.VALUES("order_id", "#{orderId,jdbcType=BIGINT}");
} }
if (record.getMemId() != null) {
sql.VALUES("mem_id", "#{memId,jdbcType=BIGINT}");
}
if (record.getGoodsType() != null) { if (record.getGoodsType() != null) {
sql.VALUES("goods_type", "#{goodsType,jdbcType=INTEGER}"); sql.VALUES("goods_type", "#{goodsType,jdbcType=INTEGER}");
} }
@ -99,6 +103,7 @@ public class HighChildOrderSqlProvider {
sql.SELECT("id"); sql.SELECT("id");
} }
sql.SELECT("order_id"); sql.SELECT("order_id");
sql.SELECT("mem_id");
sql.SELECT("goods_type"); sql.SELECT("goods_type");
sql.SELECT("goods_id"); sql.SELECT("goods_id");
sql.SELECT("goods_name"); sql.SELECT("goods_name");
@ -138,6 +143,10 @@ public class HighChildOrderSqlProvider {
sql.SET("order_id = #{record.orderId,jdbcType=BIGINT}"); sql.SET("order_id = #{record.orderId,jdbcType=BIGINT}");
} }
if (record.getMemId() != null) {
sql.SET("mem_id = #{record.memId,jdbcType=BIGINT}");
}
if (record.getGoodsType() != null) { if (record.getGoodsType() != null) {
sql.SET("goods_type = #{record.goodsType,jdbcType=INTEGER}"); sql.SET("goods_type = #{record.goodsType,jdbcType=INTEGER}");
} }
@ -204,6 +213,7 @@ public class HighChildOrderSqlProvider {
sql.SET("id = #{record.id,jdbcType=BIGINT}"); sql.SET("id = #{record.id,jdbcType=BIGINT}");
sql.SET("order_id = #{record.orderId,jdbcType=BIGINT}"); sql.SET("order_id = #{record.orderId,jdbcType=BIGINT}");
sql.SET("mem_id = #{record.memId,jdbcType=BIGINT}");
sql.SET("goods_type = #{record.goodsType,jdbcType=INTEGER}"); sql.SET("goods_type = #{record.goodsType,jdbcType=INTEGER}");
sql.SET("goods_id = #{record.goodsId,jdbcType=BIGINT}"); sql.SET("goods_id = #{record.goodsId,jdbcType=BIGINT}");
sql.SET("goods_name = #{record.goodsName,jdbcType=VARCHAR}"); sql.SET("goods_name = #{record.goodsName,jdbcType=VARCHAR}");
@ -232,6 +242,10 @@ public class HighChildOrderSqlProvider {
sql.SET("order_id = #{orderId,jdbcType=BIGINT}"); sql.SET("order_id = #{orderId,jdbcType=BIGINT}");
} }
if (record.getMemId() != null) {
sql.SET("mem_id = #{memId,jdbcType=BIGINT}");
}
if (record.getGoodsType() != null) { if (record.getGoodsType() != null) {
sql.SET("goods_type = #{goodsType,jdbcType=INTEGER}"); sql.SET("goods_type = #{goodsType,jdbcType=INTEGER}");
} }

@ -34,16 +34,16 @@ public interface HighCouponRecycleMapper extends HighCouponRecycleMapperExt {
"merchant_id, coupon_sales_code, ", "merchant_id, coupon_sales_code, ",
"coupon_code_id, user_id, ", "coupon_code_id, user_id, ",
"user_phone, order_no, ", "user_phone, order_no, ",
"order_id, receive_time, ", "order_id, `type`, receive_time, ",
"create_time, `status`, ", "create_time, ext_1, ",
"ext_1, ext_3, ext_2)", "ext_3, ext_2)",
"values (#{couponId,jdbcType=BIGINT}, #{couponName,jdbcType=VARCHAR}, ", "values (#{couponId,jdbcType=BIGINT}, #{couponName,jdbcType=VARCHAR}, ",
"#{merchantId,jdbcType=BIGINT}, #{couponSalesCode,jdbcType=VARCHAR}, ", "#{merchantId,jdbcType=BIGINT}, #{couponSalesCode,jdbcType=VARCHAR}, ",
"#{couponCodeId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, ", "#{couponCodeId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, ",
"#{userPhone,jdbcType=VARCHAR}, #{orderNo,jdbcType=VARCHAR}, ", "#{userPhone,jdbcType=VARCHAR}, #{orderNo,jdbcType=VARCHAR}, ",
"#{orderId,jdbcType=BIGINT}, #{receiveTime,jdbcType=TIMESTAMP}, ", "#{orderId,jdbcType=BIGINT}, #{type,jdbcType=INTEGER}, #{receiveTime,jdbcType=TIMESTAMP}, ",
"#{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, ", "#{createTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ",
"#{ext1,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR})" "#{ext3,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR})"
}) })
@Options(useGeneratedKeys=true,keyProperty="id") @Options(useGeneratedKeys=true,keyProperty="id")
int insert(HighCouponRecycle record); int insert(HighCouponRecycle record);
@ -64,9 +64,9 @@ public interface HighCouponRecycleMapper extends HighCouponRecycleMapperExt {
@Result(column="user_phone", property="userPhone", jdbcType=JdbcType.VARCHAR), @Result(column="user_phone", property="userPhone", jdbcType=JdbcType.VARCHAR),
@Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR), @Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR),
@Result(column="order_id", property="orderId", jdbcType=JdbcType.BIGINT), @Result(column="order_id", property="orderId", jdbcType=JdbcType.BIGINT),
@Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
@Result(column="receive_time", property="receiveTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="receive_time", property="receiveTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR), @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR) @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR)

@ -64,6 +64,10 @@ public class HighCouponRecycleSqlProvider {
sql.VALUES("order_id", "#{orderId,jdbcType=BIGINT}"); sql.VALUES("order_id", "#{orderId,jdbcType=BIGINT}");
} }
if (record.getType() != null) {
sql.VALUES("`type`", "#{type,jdbcType=INTEGER}");
}
if (record.getReceiveTime() != null) { if (record.getReceiveTime() != null) {
sql.VALUES("receive_time", "#{receiveTime,jdbcType=TIMESTAMP}"); sql.VALUES("receive_time", "#{receiveTime,jdbcType=TIMESTAMP}");
} }
@ -72,10 +76,6 @@ public class HighCouponRecycleSqlProvider {
sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}"); sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
} }
if (record.getStatus() != null) {
sql.VALUES("`status`", "#{status,jdbcType=INTEGER}");
}
if (record.getExt1() != null) { if (record.getExt1() != null) {
sql.VALUES("ext_1", "#{ext1,jdbcType=VARCHAR}"); sql.VALUES("ext_1", "#{ext1,jdbcType=VARCHAR}");
} }
@ -107,9 +107,9 @@ public class HighCouponRecycleSqlProvider {
sql.SELECT("user_phone"); sql.SELECT("user_phone");
sql.SELECT("order_no"); sql.SELECT("order_no");
sql.SELECT("order_id"); sql.SELECT("order_id");
sql.SELECT("`type`");
sql.SELECT("receive_time"); sql.SELECT("receive_time");
sql.SELECT("create_time"); sql.SELECT("create_time");
sql.SELECT("`status`");
sql.SELECT("ext_1"); sql.SELECT("ext_1");
sql.SELECT("ext_3"); sql.SELECT("ext_3");
sql.SELECT("ext_2"); sql.SELECT("ext_2");
@ -170,6 +170,10 @@ public class HighCouponRecycleSqlProvider {
sql.SET("order_id = #{record.orderId,jdbcType=BIGINT}"); sql.SET("order_id = #{record.orderId,jdbcType=BIGINT}");
} }
if (record.getType() != null) {
sql.SET("`type` = #{record.type,jdbcType=INTEGER}");
}
if (record.getReceiveTime() != null) { if (record.getReceiveTime() != null) {
sql.SET("receive_time = #{record.receiveTime,jdbcType=TIMESTAMP}"); sql.SET("receive_time = #{record.receiveTime,jdbcType=TIMESTAMP}");
} }
@ -178,10 +182,6 @@ public class HighCouponRecycleSqlProvider {
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
} }
if (record.getStatus() != null) {
sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
}
if (record.getExt1() != null) { if (record.getExt1() != null) {
sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}");
} }
@ -212,9 +212,9 @@ public class HighCouponRecycleSqlProvider {
sql.SET("user_phone = #{record.userPhone,jdbcType=VARCHAR}"); sql.SET("user_phone = #{record.userPhone,jdbcType=VARCHAR}");
sql.SET("order_no = #{record.orderNo,jdbcType=VARCHAR}"); sql.SET("order_no = #{record.orderNo,jdbcType=VARCHAR}");
sql.SET("order_id = #{record.orderId,jdbcType=BIGINT}"); sql.SET("order_id = #{record.orderId,jdbcType=BIGINT}");
sql.SET("`type` = #{record.type,jdbcType=INTEGER}");
sql.SET("receive_time = #{record.receiveTime,jdbcType=TIMESTAMP}"); sql.SET("receive_time = #{record.receiveTime,jdbcType=TIMESTAMP}");
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}");
sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}");
sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}");

@ -2,7 +2,6 @@ package com.hai.entity;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List;
/** /**
* high_child_order * high_child_order
@ -24,6 +23,11 @@ public class HighChildOrder implements Serializable {
*/ */
private Long orderId; private Long orderId;
/**
* 用户id
*/
private Long memId;
/** /**
* 商品类型 1:卡卷 * 商品类型 1:卡卷
*/ */
@ -103,6 +107,14 @@ public class HighChildOrder implements Serializable {
this.orderId = orderId; this.orderId = orderId;
} }
public Long getMemId() {
return memId;
}
public void setMemId(Long memId) {
this.memId = memId;
}
public Integer getGoodsType() { public Integer getGoodsType() {
return goodsType; return goodsType;
} }
@ -229,6 +241,7 @@ public class HighChildOrder implements Serializable {
HighChildOrder other = (HighChildOrder) that; HighChildOrder other = (HighChildOrder) 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.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId())) && (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId()))
&& (this.getMemId() == null ? other.getMemId() == null : this.getMemId().equals(other.getMemId()))
&& (this.getGoodsType() == null ? other.getGoodsType() == null : this.getGoodsType().equals(other.getGoodsType())) && (this.getGoodsType() == null ? other.getGoodsType() == null : this.getGoodsType().equals(other.getGoodsType()))
&& (this.getGoodsId() == null ? other.getGoodsId() == null : this.getGoodsId().equals(other.getGoodsId())) && (this.getGoodsId() == null ? other.getGoodsId() == null : this.getGoodsId().equals(other.getGoodsId()))
&& (this.getGoodsName() == null ? other.getGoodsName() == null : this.getGoodsName().equals(other.getGoodsName())) && (this.getGoodsName() == null ? other.getGoodsName() == null : this.getGoodsName().equals(other.getGoodsName()))
@ -251,6 +264,7 @@ public class HighChildOrder implements Serializable {
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 + ((getOrderId() == null) ? 0 : getOrderId().hashCode()); result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode());
result = prime * result + ((getMemId() == null) ? 0 : getMemId().hashCode());
result = prime * result + ((getGoodsType() == null) ? 0 : getGoodsType().hashCode()); result = prime * result + ((getGoodsType() == null) ? 0 : getGoodsType().hashCode());
result = prime * result + ((getGoodsId() == null) ? 0 : getGoodsId().hashCode()); result = prime * result + ((getGoodsId() == null) ? 0 : getGoodsId().hashCode());
result = prime * result + ((getGoodsName() == null) ? 0 : getGoodsName().hashCode()); result = prime * result + ((getGoodsName() == null) ? 0 : getGoodsName().hashCode());
@ -276,6 +290,7 @@ public class HighChildOrder implements Serializable {
sb.append("Hash = ").append(hashCode()); sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id); sb.append(", id=").append(id);
sb.append(", orderId=").append(orderId); sb.append(", orderId=").append(orderId);
sb.append(", memId=").append(memId);
sb.append(", goodsType=").append(goodsType); sb.append(", goodsType=").append(goodsType);
sb.append(", goodsId=").append(goodsId); sb.append(", goodsId=").append(goodsId);
sb.append(", goodsName=").append(goodsName); sb.append(", goodsName=").append(goodsName);

@ -245,6 +245,66 @@ public class HighChildOrderExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andMemIdIsNull() {
addCriterion("mem_id is null");
return (Criteria) this;
}
public Criteria andMemIdIsNotNull() {
addCriterion("mem_id is not null");
return (Criteria) this;
}
public Criteria andMemIdEqualTo(Long value) {
addCriterion("mem_id =", value, "memId");
return (Criteria) this;
}
public Criteria andMemIdNotEqualTo(Long value) {
addCriterion("mem_id <>", value, "memId");
return (Criteria) this;
}
public Criteria andMemIdGreaterThan(Long value) {
addCriterion("mem_id >", value, "memId");
return (Criteria) this;
}
public Criteria andMemIdGreaterThanOrEqualTo(Long value) {
addCriterion("mem_id >=", value, "memId");
return (Criteria) this;
}
public Criteria andMemIdLessThan(Long value) {
addCriterion("mem_id <", value, "memId");
return (Criteria) this;
}
public Criteria andMemIdLessThanOrEqualTo(Long value) {
addCriterion("mem_id <=", value, "memId");
return (Criteria) this;
}
public Criteria andMemIdIn(List<Long> values) {
addCriterion("mem_id in", values, "memId");
return (Criteria) this;
}
public Criteria andMemIdNotIn(List<Long> values) {
addCriterion("mem_id not in", values, "memId");
return (Criteria) this;
}
public Criteria andMemIdBetween(Long value1, Long value2) {
addCriterion("mem_id between", value1, value2, "memId");
return (Criteria) this;
}
public Criteria andMemIdNotBetween(Long value1, Long value2) {
addCriterion("mem_id not between", value1, value2, "memId");
return (Criteria) this;
}
public Criteria andGoodsTypeIsNull() { public Criteria andGoodsTypeIsNull() {
addCriterion("goods_type is null"); addCriterion("goods_type is null");
return (Criteria) this; return (Criteria) this;

@ -63,6 +63,11 @@ public class HighCouponRecycle implements Serializable {
*/ */
private Long orderId; private Long orderId;
/**
* 类型1.过期 2.退款
*/
private Integer type;
/** /**
* 领取时间 * 领取时间
*/ */
@ -73,11 +78,6 @@ public class HighCouponRecycle implements Serializable {
*/ */
private Date createTime; private Date createTime;
/**
* 状态1.过期 2.退款
*/
private Integer status;
private String ext1; private String ext1;
private String ext3; private String ext3;
@ -166,6 +166,14 @@ public class HighCouponRecycle implements Serializable {
this.orderId = orderId; this.orderId = orderId;
} }
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Date getReceiveTime() { public Date getReceiveTime() {
return receiveTime; return receiveTime;
} }
@ -182,14 +190,6 @@ public class HighCouponRecycle implements Serializable {
this.createTime = createTime; this.createTime = createTime;
} }
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getExt1() { public String getExt1() {
return ext1; return ext1;
} }
@ -236,9 +236,9 @@ public class HighCouponRecycle implements Serializable {
&& (this.getUserPhone() == null ? other.getUserPhone() == null : this.getUserPhone().equals(other.getUserPhone())) && (this.getUserPhone() == null ? other.getUserPhone() == null : this.getUserPhone().equals(other.getUserPhone()))
&& (this.getOrderNo() == null ? other.getOrderNo() == null : this.getOrderNo().equals(other.getOrderNo())) && (this.getOrderNo() == null ? other.getOrderNo() == null : this.getOrderNo().equals(other.getOrderNo()))
&& (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId())) && (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId()))
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
&& (this.getReceiveTime() == null ? other.getReceiveTime() == null : this.getReceiveTime().equals(other.getReceiveTime())) && (this.getReceiveTime() == null ? other.getReceiveTime() == null : this.getReceiveTime().equals(other.getReceiveTime()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1())) && (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1()))
&& (this.getExt3() == null ? other.getExt3() == null : this.getExt3().equals(other.getExt3())) && (this.getExt3() == null ? other.getExt3() == null : this.getExt3().equals(other.getExt3()))
&& (this.getExt2() == null ? other.getExt2() == null : this.getExt2().equals(other.getExt2())); && (this.getExt2() == null ? other.getExt2() == null : this.getExt2().equals(other.getExt2()));
@ -258,9 +258,9 @@ public class HighCouponRecycle implements Serializable {
result = prime * result + ((getUserPhone() == null) ? 0 : getUserPhone().hashCode()); result = prime * result + ((getUserPhone() == null) ? 0 : getUserPhone().hashCode());
result = prime * result + ((getOrderNo() == null) ? 0 : getOrderNo().hashCode()); result = prime * result + ((getOrderNo() == null) ? 0 : getOrderNo().hashCode());
result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode()); result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode());
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
result = prime * result + ((getReceiveTime() == null) ? 0 : getReceiveTime().hashCode()); result = prime * result + ((getReceiveTime() == null) ? 0 : getReceiveTime().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode()); result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode());
result = prime * result + ((getExt3() == null) ? 0 : getExt3().hashCode()); result = prime * result + ((getExt3() == null) ? 0 : getExt3().hashCode());
result = prime * result + ((getExt2() == null) ? 0 : getExt2().hashCode()); result = prime * result + ((getExt2() == null) ? 0 : getExt2().hashCode());
@ -283,9 +283,9 @@ public class HighCouponRecycle implements Serializable {
sb.append(", userPhone=").append(userPhone); sb.append(", userPhone=").append(userPhone);
sb.append(", orderNo=").append(orderNo); sb.append(", orderNo=").append(orderNo);
sb.append(", orderId=").append(orderId); sb.append(", orderId=").append(orderId);
sb.append(", type=").append(type);
sb.append(", receiveTime=").append(receiveTime); sb.append(", receiveTime=").append(receiveTime);
sb.append(", createTime=").append(createTime); sb.append(", createTime=").append(createTime);
sb.append(", status=").append(status);
sb.append(", ext1=").append(ext1); sb.append(", ext1=").append(ext1);
sb.append(", ext3=").append(ext3); sb.append(", ext3=").append(ext3);
sb.append(", ext2=").append(ext2); sb.append(", ext2=").append(ext2);

@ -765,6 +765,66 @@ public class HighCouponRecycleExample {
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 andReceiveTimeIsNull() { public Criteria andReceiveTimeIsNull() {
addCriterion("receive_time is null"); addCriterion("receive_time is null");
return (Criteria) this; return (Criteria) this;
@ -885,66 +945,6 @@ public class HighCouponRecycleExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andStatusIsNull() {
addCriterion("`status` is null");
return (Criteria) this;
}
public Criteria andStatusIsNotNull() {
addCriterion("`status` is not null");
return (Criteria) this;
}
public Criteria andStatusEqualTo(Integer value) {
addCriterion("`status` =", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotEqualTo(Integer value) {
addCriterion("`status` <>", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThan(Integer value) {
addCriterion("`status` >", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThanOrEqualTo(Integer value) {
addCriterion("`status` >=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThan(Integer value) {
addCriterion("`status` <", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThanOrEqualTo(Integer value) {
addCriterion("`status` <=", value, "status");
return (Criteria) this;
}
public Criteria andStatusIn(List<Integer> values) {
addCriterion("`status` in", values, "status");
return (Criteria) this;
}
public Criteria andStatusNotIn(List<Integer> values) {
addCriterion("`status` not in", values, "status");
return (Criteria) this;
}
public Criteria andStatusBetween(Integer value1, Integer value2) {
addCriterion("`status` between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andStatusNotBetween(Integer value1, Integer value2) {
addCriterion("`status` not between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andExt1IsNull() { public Criteria andExt1IsNull() {
addCriterion("ext_1 is null"); addCriterion("ext_1 is null");
return (Criteria) this; return (Criteria) this;

@ -21,9 +21,20 @@ public class HighCouponModel {
// 赠送卡卷id // 赠送卡卷id
private List<Long> handselCouponId; private List<Long> handselCouponId;
// 购买数量上限
private Boolean numberUpperLimitStatus;
// 赠送卡卷 // 赠送卡卷
private List<HighCouponHandselModel> handselCouponList; private List<HighCouponHandselModel> handselCouponList;
public Boolean getNumberUpperLimitStatus() {
return numberUpperLimitStatus;
}
public void setNumberUpperLimitStatus(Boolean numberUpperLimitStatus) {
this.numberUpperLimitStatus = numberUpperLimitStatus;
}
public String getMerchantName() { public String getMerchantName() {
return merchantName; return merchantName;
} }

@ -89,4 +89,5 @@ public interface HighCouponCodeService {
**/ **/
List<HighCouponCode> getCouponCodeList(Map<String,Object> map); List<HighCouponCode> getCouponCodeList(Map<String,Object> map);
} }

@ -0,0 +1,29 @@
package com.hai.service;
import com.hai.entity.HighCouponRecycle;
import java.util.List;
import java.util.Map;
/**
* @Auther: 胡锐
* @Description: 归库记录
* @Date: 2021/4/2 21:25
*/
public interface HighCouponRecycleService {
/**
* @Author 胡锐
* @Description 增加
* @Date 2021/4/2 21:26
**/
void insertCouponRecycle(HighCouponRecycle highCouponRecycle);
/**
* @Author 胡锐
* @Description 查询
* @Date 2021/4/2 21:26
**/
List<HighCouponRecycle> getRecycleList(Map<String,Object> map);
}

@ -1,8 +1,6 @@
package com.hai.service; package com.hai.service;
import com.hai.entity.HighApprove; import com.hai.entity.*;
import com.hai.entity.HighCoupon;
import com.hai.entity.HighCouponCode;
import com.hai.model.HighCouponModel; import com.hai.model.HighCouponModel;
import java.util.List; import java.util.List;
@ -114,4 +112,11 @@ public interface HighCouponService {
**/ **/
List<HighCoupon> getCouponListByMerchant(Long merchantId); List<HighCoupon> getCouponListByMerchant(Long merchantId);
/**
* @Author 胡锐
* @Description 用户购买卡卷数量上限
* @Date 2021/4/2 22:21
**/
Boolean userBuyLimitNumber(Long userId,Long couponId);
} }

@ -48,6 +48,13 @@ public interface HighOrderService {
*/ */
List<HighChildOrder> getChildOrderByOrder(Long orderId); List<HighChildOrder> getChildOrderByOrder(Long orderId);
/**
* @Author 胡锐
* @Description 查询子商品列表
* @Date 2021/4/2 21:51
**/
List<HighChildOrder> getChildOrderList(Map<String, Object> map);
/** /**
* @Author 胡锐 * @Author 胡锐
* @Description 根据id查询 * @Description 根据id查询

@ -58,4 +58,12 @@ public interface HighUserCouponService {
List<HighUserCoupon> getCouponList(Long userId,Integer status); List<HighUserCoupon> getCouponList(Long userId,Integer status);
/**
* @Author 胡锐
* @Description 重新领取卡卷
* @Date 2021/4/2 23:13
**/
HighUserCoupon againReceiveCoupon(Long userId,Long couponId);
} }

@ -140,10 +140,9 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService {
@Override @Override
public List<HighCouponCode> getNoSaleCode(Long couponId) { public List<HighCouponCode> getNoSaleCode(Long couponId) {
Map<String, Object> map = new HashMap<>(); HighCouponCodeExample example = new HighCouponCodeExample();
map.put("couponId", couponId); example.createCriteria().andCouponIdEqualTo(couponId).andStatusEqualTo(1);
map.put("status", 1); return highCouponCodeMapper.selectByExample(example);
return getCouponCodeList(map);
} }
@Override @Override

@ -0,0 +1,47 @@
package com.hai.service.impl;
import com.hai.dao.HighCouponRecycleMapper;
import com.hai.entity.HighCouponRecycle;
import com.hai.entity.HighCouponRecycleExample;
import com.hai.service.HighCouponRecycleService;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* @Auther: 胡锐
* @Description:
* @Date: 2021/4/2 21:27
*/
@Service("highCouponRecycleService")
public class HighCouponRecycleServiceImpl implements HighCouponRecycleService {
@Resource
private HighCouponRecycleMapper highCouponRecycleMapper;
@Override
public void insertCouponRecycle(HighCouponRecycle highCouponRecycle) {
highCouponRecycleMapper.insert(highCouponRecycle);
}
@Override
public List<HighCouponRecycle> getRecycleList(Map<String, Object> map) {
HighCouponRecycleExample example = new HighCouponRecycleExample();
HighCouponRecycleExample.Criteria criteria = example.createCriteria();
if (StringUtils.isNotBlank(MapUtils.getString(map, "userPhone"))) {
criteria.andUserPhoneEqualTo(MapUtils.getString(map, "userPhone"));
}
if (StringUtils.isNotBlank(MapUtils.getString(map, "orderNo"))) {
criteria.andOrderNoLike("%" + MapUtils.getString(map, "orderNo") + "%");
}
example.setOrderByClause("create_time desc");
return highCouponRecycleMapper.selectByExample(example);
}
}

@ -46,6 +46,9 @@ public class HighCouponServiceImpl implements HighCouponService {
@Resource @Resource
private HighMerchantService highMerchantService; private HighMerchantService highMerchantService;
@Resource
private HighOrderService highOrderService;
@Resource @Resource
private HighApproveService highApproveService; private HighApproveService highApproveService;
@ -377,4 +380,26 @@ public class HighCouponServiceImpl implements HighCouponService {
example.createCriteria().andMerchantIdEqualTo(merchantId).andStatusEqualTo(1).andStatusNotEqualTo(0); example.createCriteria().andMerchantIdEqualTo(merchantId).andStatusEqualTo(1).andStatusNotEqualTo(0);
return highCouponMapper.selectByExample(example); return highCouponMapper.selectByExample(example);
} }
@Override
public Boolean userBuyLimitNumber(Long userId, Long couponId) {
Boolean status = false;
HighCoupon coupon = getCouponById(couponId);
Map<String, Object> map = new HashMap<>();
map.put("memId", userId);
map.put("goodsType", 1);
map.put("goodsId", couponId);
map.put("childOrdeStatusList", "2,3");
List<HighChildOrder> childOrderList = highOrderService.getChildOrderList(map);
// 限购数量 大于购买数量
if (coupon != null && childOrderList.size() > coupon.getLimitNumber()) {
status = true;
}
return status;
}
} }

@ -143,6 +143,8 @@ public class HighOrderServiceImpl implements HighOrderService {
code.setReceiveTime(new Date()); code.setReceiveTime(new Date());
highCouponCodeService.updateCouponCode(code); highCouponCodeService.updateCouponCode(code);
HighCoupon coupon = highCouponService.getCouponById(highChildOrder.getGoodsId());
// 卡卷关联用户 // 卡卷关联用户
HighUserCoupon highUserCoupon = new HighUserCoupon(); HighUserCoupon highUserCoupon = new HighUserCoupon();
highUserCoupon.setMerchantId(code.getMerchantId()); highUserCoupon.setMerchantId(code.getMerchantId());
@ -150,7 +152,15 @@ public class HighOrderServiceImpl implements HighOrderService {
highUserCoupon.setUserId(highOrder.getMemId()); highUserCoupon.setUserId(highOrder.getMemId());
highUserCoupon.setCouponCodeId(code.getId()); highUserCoupon.setCouponCodeId(code.getId());
highUserCoupon.setCreateTime(new Date()); highUserCoupon.setCreateTime(new Date());
// 计算使用有效期
Calendar userEndTime = Calendar.getInstance();
userEndTime.add(Calendar.DATE, coupon.getRecycleDay());
if (userEndTime.getTime().compareTo(code.getUseEndTime()) == 1) {
highUserCoupon.setUseEndTime(code.getUseEndTime()); highUserCoupon.setUseEndTime(code.getUseEndTime());
} else {
highUserCoupon.setUseEndTime(userEndTime.getTime());
}
highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
highUserCouponMapper.insert(highUserCoupon); highUserCouponMapper.insert(highUserCoupon);
} }
@ -188,6 +198,42 @@ public class HighOrderServiceImpl implements HighOrderService {
return highChildOrderMapper.selectByExample(example); return highChildOrderMapper.selectByExample(example);
} }
@Override
public List<HighChildOrder> getChildOrderList(Map<String, Object> map) {
HighChildOrderExample example = new HighChildOrderExample();
HighChildOrderExample.Criteria criteria = example.createCriteria();
if (MapUtils.getLong(map, "memId") != null) {
criteria.andOrderIdEqualTo(MapUtils.getLong(map, "memId"));
}
if (MapUtils.getLong(map, "childOrdeStatus") != null) {
criteria.andChildOrdeStatusEqualTo(MapUtils.getInteger(map, "childOrdeStatus"));
}
if (MapUtils.getString(map, "childOrdeStatusList") != null) {
String[] childOrdeStatusLists = MapUtils.getString(map, "childOrdeStatusList").split(",");
List<Integer> integerList = new ArrayList<>();
for (String status :childOrdeStatusLists) {
integerList.add(Integer.parseInt(status));
}
criteria.andChildOrdeStatusIn(integerList);
}
if (MapUtils.getLong(map, "goodsType") != null) {
criteria.andGoodsTypeEqualTo(MapUtils.getInteger(map, "goodsType"));
}
if (MapUtils.getLong(map, "goodsId") != null) {
criteria.andGoodsIdEqualTo(MapUtils.getLong(map, "goodsId"));
}
if (MapUtils.getLong(map, "giveawayType") != null) {
criteria.andGiveawayTypeEqualTo(MapUtils.getBoolean(map, "giveawayType"));
}
return highChildOrderMapper.selectByExample(example);
}
@Override @Override
public HighOrder getOrderById(Long id) { public HighOrder getOrderById(Long id) {
HighOrder order = highOrderMapper.selectByPrimaryKey(id); HighOrder order = highOrderMapper.selectByPrimaryKey(id);

@ -1,20 +1,25 @@
package com.hai.service.impl; package com.hai.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.dao.HighUserCouponMapper; import com.hai.dao.HighUserCouponMapper;
import com.hai.entity.HighCoupon;
import com.hai.entity.HighCouponCode;
import com.hai.entity.HighUserCoupon; import com.hai.entity.HighUserCoupon;
import com.hai.entity.HighUserCouponExample; import com.hai.entity.HighUserCouponExample;
import com.hai.model.HighUserCouponModel; import com.hai.model.HighUserCouponModel;
import com.hai.service.HighCouponCodeService;
import com.hai.service.HighCouponService; import com.hai.service.HighCouponService;
import com.hai.service.HighUserCouponService; import com.hai.service.HighUserCouponService;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
/** /**
* @Auther: 胡锐 * @Auther: 胡锐
@ -30,6 +35,9 @@ public class HighUserCouponServiceImpl implements HighUserCouponService {
@Resource @Resource
private HighCouponService highCouponService; private HighCouponService highCouponService;
@Resource
private HighCouponCodeService highCouponCodeService;
@Override @Override
public void insertUserCoupon(HighUserCoupon highUserCoupon) { public void insertUserCoupon(HighUserCoupon highUserCoupon) {
highUserCouponMapper.insert(highUserCoupon); highUserCouponMapper.insert(highUserCoupon);
@ -72,6 +80,7 @@ public class HighUserCouponServiceImpl implements HighUserCouponService {
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); criteria.andStatusEqualTo(MapUtils.getInteger(map, "status"));
} }
criteria.andStatusNotEqualTo(100);
example.setOrderByClause("create_time desc"); example.setOrderByClause("create_time desc");
List<HighUserCoupon> highUserCoupons = highUserCouponMapper.selectByExample(example); List<HighUserCoupon> highUserCoupons = highUserCouponMapper.selectByExample(example);
if (highUserCoupons.size() > 0) { if (highUserCoupons.size() > 0) {
@ -103,4 +112,54 @@ public class HighUserCouponServiceImpl implements HighUserCouponService {
example.setOrderByClause("create_time desc"); example.setOrderByClause("create_time desc");
return highUserCouponMapper.selectByExample(example); return highUserCouponMapper.selectByExample(example);
} }
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public HighUserCoupon againReceiveCoupon(Long userId, Long couponId) {
// 用户的卡卷
HighUserCoupon userCoupon = getUserCoupon(userId, couponId);
if (userCoupon == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到卡卷");
}
if (userCoupon.getStatus() != 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法重新领取");
}
userCoupon.setStatus(100); // 删除
HighCoupon coupon = highCouponService.getCouponById(userCoupon.getCouponId());
if (coupon == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到卡卷");
}
// 查询待销售
List<HighCouponCode> list = highCouponCodeService.getNoSaleCode(coupon.getId());
if (list == null || list.size() == 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, coupon.getCouponName() + "暂无库存,请联系客服");
}
HighCouponCode highCouponCode = list.get(0);
highCouponCode.setChildOrderId(userCoupon.getId());
highCouponCode.setStatus(2); // 状态:1.待销售 2.未使用 3.已使用 99.预支付
highCouponCodeService.updateCouponCode(highCouponCode);
// 卡卷关联用户
HighUserCoupon highUserCoupon = new HighUserCoupon();
highUserCoupon.setMerchantId(coupon.getMerchantId());
highUserCoupon.setCouponId(coupon.getId());
highUserCoupon.setUserId(userId);
highUserCoupon.setCouponCodeId(highCouponCode.getId());
highUserCoupon.setCreateTime(new Date());
// 计算使用有效期
Calendar userEndTime = Calendar.getInstance();
userEndTime.add(Calendar.DATE, coupon.getRecycleDay());
if (userEndTime.getTime().compareTo(highCouponCode.getUseEndTime()) == 1) {
highUserCoupon.setUseEndTime(highCouponCode.getUseEndTime());
} else {
highUserCoupon.setUseEndTime(userEndTime.getTime());
}
highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
highUserCouponMapper.insert(highUserCoupon);
return highUserCoupon;
}
} }

@ -1,24 +1,20 @@
package com.hai.service.pay.impl; package com.hai.service.pay.impl;
import com.alibaba.fastjson.JSONObject;
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.dao.HighUserCouponMapper; import com.hai.dao.HighUserCouponMapper;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.service.HighCouponCodeService; import com.hai.service.*;
import com.hai.service.HighOrderService;
import com.hai.service.HighUserService;
import com.hai.service.pay.PayService; import com.hai.service.pay.PayService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -32,6 +28,9 @@ public class GoodsOrderServiceImpl implements PayService {
@Resource @Resource
private HighOrderService highOrderService; private HighOrderService highOrderService;
@Resource
private HighCouponService highCouponService;
@Resource @Resource
private HighCouponCodeService highCouponCodeService; private HighCouponCodeService highCouponCodeService;
@ -70,6 +69,8 @@ public class GoodsOrderServiceImpl implements PayService {
code.setReceiveTime(new Date()); code.setReceiveTime(new Date());
highCouponCodeService.updateCouponCode(code); highCouponCodeService.updateCouponCode(code);
HighCoupon coupon = highCouponService.getCouponById(highChildOrder.getGoodsId());
// 卡卷关联用户 // 卡卷关联用户
HighUserCoupon highUserCoupon = new HighUserCoupon(); HighUserCoupon highUserCoupon = new HighUserCoupon();
highUserCoupon.setMerchantId(code.getMerchantId()); highUserCoupon.setMerchantId(code.getMerchantId());
@ -77,7 +78,15 @@ public class GoodsOrderServiceImpl implements PayService {
highUserCoupon.setUserId(order.getMemId()); highUserCoupon.setUserId(order.getMemId());
highUserCoupon.setCouponCodeId(code.getId()); highUserCoupon.setCouponCodeId(code.getId());
highUserCoupon.setCreateTime(new Date()); highUserCoupon.setCreateTime(new Date());
// 计算使用有效期
Calendar userEndTime = Calendar.getInstance();
userEndTime.add(Calendar.DATE, coupon.getRecycleDay());
if (userEndTime.getTime().compareTo(code.getUseEndTime()) == 1) {
highUserCoupon.setUseEndTime(code.getUseEndTime()); highUserCoupon.setUseEndTime(code.getUseEndTime());
} else {
highUserCoupon.setUseEndTime(userEndTime.getTime());
}
highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
highUserCouponMapper.insert(highUserCoupon); highUserCouponMapper.insert(highUserCoupon);
} }

Loading…
Cancel
Save