'完成限购、归库'

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.utils.ResponseMsgUtil;
import com.hai.entity.BsCompany;
import com.hai.entity.HighCoupon;
import com.hai.entity.HighUserCoupon;
import com.hai.model.HighUserCouponModel;
import com.hai.model.HighUserModel;
@ -51,6 +52,9 @@ public class HighCouponController {
@Resource
private HighCouponCodeService highCouponCodeService;
@Resource
private HighOrderService highOrderService;
@Resource
private HighUserCouponService highUserCouponService;
@ -90,10 +94,15 @@ public class HighCouponController {
@RequestMapping(value="/getCouponById",method = RequestMethod.GET)
@ResponseBody
@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 {
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) {
log.error("HighCouponController -> getCouponById() error!",e);
@ -101,8 +110,6 @@ public class HighCouponController {
}
}
@RequestMapping(value = "/getUserCouponList", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取用户卡卷列表")
@ -129,10 +136,9 @@ public class HighCouponController {
}
}
@RequestMapping(value = "/getUserCouponDetail", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取用户卡卷")
@ApiOperation(value = "获取用户卡卷详细")
public ResponseData getUserCouponDetail(@RequestParam(name = "couponId", required = true) Long couponId,
HttpServletRequest request) {
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!", "未找到卡卷信息");
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) {
log.error("HighOrderController --> addOrder() error!", "卡卷库存数量不足");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COUPON_STOCK_INSUFFICIENT, "");
}
childOrder.setGoodsName(coupon.getCouponName());
childOrder.setGoodsImg(coupon.getCouponImg());
childOrder.setGoodsSpecName("默认");

@ -123,8 +123,8 @@ public class OrderController {
map.put("orderNo", order.getOrderNo());
map.put("payPrice", order.getPayPrice());
map.put("orderScene", orderScene);
map.put("body","购买卡券");
map.put("subject","购买卡券");
map.put("body","购买产品");
map.put("subject","购买产品");
//微信支付
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 0 * * ?") //每天 凌晨0点执行
public void certification() {
public void expiredCoupon() {
List<HighUserCoupon> userCoupons = highUserCouponService.getOverdueCoupon();
for (HighUserCoupon highUserCoupon : userCoupons) {
highUserCoupon.setStatus(0); // 状态 0:已过期 1:未使用 2:已使用

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

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

@ -34,16 +34,16 @@ public interface HighCouponRecycleMapper extends HighCouponRecycleMapperExt {
"merchant_id, coupon_sales_code, ",
"coupon_code_id, user_id, ",
"user_phone, order_no, ",
"order_id, receive_time, ",
"create_time, `status`, ",
"ext_1, ext_3, ext_2)",
"order_id, `type`, receive_time, ",
"create_time, ext_1, ",
"ext_3, ext_2)",
"values (#{couponId,jdbcType=BIGINT}, #{couponName,jdbcType=VARCHAR}, ",
"#{merchantId,jdbcType=BIGINT}, #{couponSalesCode,jdbcType=VARCHAR}, ",
"#{couponCodeId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, ",
"#{userPhone,jdbcType=VARCHAR}, #{orderNo,jdbcType=VARCHAR}, ",
"#{orderId,jdbcType=BIGINT}, #{receiveTime,jdbcType=TIMESTAMP}, ",
"#{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, ",
"#{ext1,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR})"
"#{orderId,jdbcType=BIGINT}, #{type,jdbcType=INTEGER}, #{receiveTime,jdbcType=TIMESTAMP}, ",
"#{createTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ",
"#{ext3,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR})"
})
@Options(useGeneratedKeys=true,keyProperty="id")
int insert(HighCouponRecycle record);
@ -64,9 +64,9 @@ public interface HighCouponRecycleMapper extends HighCouponRecycleMapperExt {
@Result(column="user_phone", property="userPhone", jdbcType=JdbcType.VARCHAR),
@Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR),
@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="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_3", property="ext3", 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}");
}
if (record.getType() != null) {
sql.VALUES("`type`", "#{type,jdbcType=INTEGER}");
}
if (record.getReceiveTime() != null) {
sql.VALUES("receive_time", "#{receiveTime,jdbcType=TIMESTAMP}");
}
@ -72,10 +76,6 @@ public class HighCouponRecycleSqlProvider {
sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
}
if (record.getStatus() != null) {
sql.VALUES("`status`", "#{status,jdbcType=INTEGER}");
}
if (record.getExt1() != null) {
sql.VALUES("ext_1", "#{ext1,jdbcType=VARCHAR}");
}
@ -107,9 +107,9 @@ public class HighCouponRecycleSqlProvider {
sql.SELECT("user_phone");
sql.SELECT("order_no");
sql.SELECT("order_id");
sql.SELECT("`type`");
sql.SELECT("receive_time");
sql.SELECT("create_time");
sql.SELECT("`status`");
sql.SELECT("ext_1");
sql.SELECT("ext_3");
sql.SELECT("ext_2");
@ -170,6 +170,10 @@ public class HighCouponRecycleSqlProvider {
sql.SET("order_id = #{record.orderId,jdbcType=BIGINT}");
}
if (record.getType() != null) {
sql.SET("`type` = #{record.type,jdbcType=INTEGER}");
}
if (record.getReceiveTime() != null) {
sql.SET("receive_time = #{record.receiveTime,jdbcType=TIMESTAMP}");
}
@ -178,10 +182,6 @@ public class HighCouponRecycleSqlProvider {
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
}
if (record.getStatus() != null) {
sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
}
if (record.getExt1() != null) {
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("order_no = #{record.orderNo,jdbcType=VARCHAR}");
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("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}");
sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}");
sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}");

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

@ -245,6 +245,66 @@ public class HighChildOrderExample {
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() {
addCriterion("goods_type is null");
return (Criteria) this;

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

@ -765,6 +765,66 @@ public class HighCouponRecycleExample {
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() {
addCriterion("receive_time is null");
return (Criteria) this;
@ -885,66 +945,6 @@ public class HighCouponRecycleExample {
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() {
addCriterion("ext_1 is null");
return (Criteria) this;

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

@ -89,4 +89,5 @@ public interface HighCouponCodeService {
**/
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;
import com.hai.entity.HighApprove;
import com.hai.entity.HighCoupon;
import com.hai.entity.HighCouponCode;
import com.hai.entity.*;
import com.hai.model.HighCouponModel;
import java.util.List;
@ -114,4 +112,11 @@ public interface HighCouponService {
**/
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);
/**
* @Author 胡锐
* @Description 查询子商品列表
* @Date 2021/4/2 21:51
**/
List<HighChildOrder> getChildOrderList(Map<String, Object> map);
/**
* @Author 胡锐
* @Description 根据id查询

@ -58,4 +58,12 @@ public interface HighUserCouponService {
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
public List<HighCouponCode> getNoSaleCode(Long couponId) {
Map<String, Object> map = new HashMap<>();
map.put("couponId", couponId);
map.put("status", 1);
return getCouponCodeList(map);
HighCouponCodeExample example = new HighCouponCodeExample();
example.createCriteria().andCouponIdEqualTo(couponId).andStatusEqualTo(1);
return highCouponCodeMapper.selectByExample(example);
}
@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
private HighMerchantService highMerchantService;
@Resource
private HighOrderService highOrderService;
@Resource
private HighApproveService highApproveService;
@ -377,4 +380,26 @@ public class HighCouponServiceImpl implements HighCouponService {
example.createCriteria().andMerchantIdEqualTo(merchantId).andStatusEqualTo(1).andStatusNotEqualTo(0);
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());
highCouponCodeService.updateCouponCode(code);
HighCoupon coupon = highCouponService.getCouponById(highChildOrder.getGoodsId());
// 卡卷关联用户
HighUserCoupon highUserCoupon = new HighUserCoupon();
highUserCoupon.setMerchantId(code.getMerchantId());
@ -150,7 +152,15 @@ public class HighOrderServiceImpl implements HighOrderService {
highUserCoupon.setUserId(highOrder.getMemId());
highUserCoupon.setCouponCodeId(code.getId());
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());
} else {
highUserCoupon.setUseEndTime(userEndTime.getTime());
}
highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
highUserCouponMapper.insert(highUserCoupon);
}
@ -188,6 +198,42 @@ public class HighOrderServiceImpl implements HighOrderService {
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
public HighOrder getOrderById(Long id) {
HighOrder order = highOrderMapper.selectByPrimaryKey(id);

@ -1,20 +1,25 @@
package com.hai.service.impl;
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.entity.HighCoupon;
import com.hai.entity.HighCouponCode;
import com.hai.entity.HighUserCoupon;
import com.hai.entity.HighUserCouponExample;
import com.hai.model.HighUserCouponModel;
import com.hai.service.HighCouponCodeService;
import com.hai.service.HighCouponService;
import com.hai.service.HighUserCouponService;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @Auther: 胡锐
@ -30,6 +35,9 @@ public class HighUserCouponServiceImpl implements HighUserCouponService {
@Resource
private HighCouponService highCouponService;
@Resource
private HighCouponCodeService highCouponCodeService;
@Override
public void insertUserCoupon(HighUserCoupon highUserCoupon) {
highUserCouponMapper.insert(highUserCoupon);
@ -72,6 +80,7 @@ public class HighUserCouponServiceImpl implements HighUserCouponService {
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status"));
}
criteria.andStatusNotEqualTo(100);
example.setOrderByClause("create_time desc");
List<HighUserCoupon> highUserCoupons = highUserCouponMapper.selectByExample(example);
if (highUserCoupons.size() > 0) {
@ -103,4 +112,54 @@ public class HighUserCouponServiceImpl implements HighUserCouponService {
example.setOrderByClause("create_time desc");
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;
import com.alibaba.fastjson.JSONObject;
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.entity.*;
import com.hai.service.HighCouponCodeService;
import com.hai.service.HighOrderService;
import com.hai.service.HighUserService;
import com.hai.service.*;
import com.hai.service.pay.PayService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
@ -32,6 +28,9 @@ public class GoodsOrderServiceImpl implements PayService {
@Resource
private HighOrderService highOrderService;
@Resource
private HighCouponService highCouponService;
@Resource
private HighCouponCodeService highCouponCodeService;
@ -70,6 +69,8 @@ public class GoodsOrderServiceImpl implements PayService {
code.setReceiveTime(new Date());
highCouponCodeService.updateCouponCode(code);
HighCoupon coupon = highCouponService.getCouponById(highChildOrder.getGoodsId());
// 卡卷关联用户
HighUserCoupon highUserCoupon = new HighUserCoupon();
highUserCoupon.setMerchantId(code.getMerchantId());
@ -77,7 +78,15 @@ public class GoodsOrderServiceImpl implements PayService {
highUserCoupon.setUserId(order.getMemId());
highUserCoupon.setCouponCodeId(code.getId());
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());
} else {
highUserCoupon.setUseEndTime(userEndTime.getTime());
}
highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
highUserCouponMapper.insert(highUserCoupon);
}

Loading…
Cancel
Save