From 1d4db5aa228fa54afaebcb0389846c4a2abf49a5 Mon Sep 17 00:00:00 2001 From: 199901012 Date: Mon, 5 Apr 2021 14:13:31 +0800 Subject: [PATCH] =?UTF-8?q?'=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hai/schedule/HighCouponSchedule.java | 10 +- .../hai/common/security/AESEncodeUtil.java | 6 +- .../com/hai/dao/HighCouponRecycleMapper.java | 7 +- .../hai/dao/HighCouponRecycleSqlProvider.java | 10 + .../com/hai/dao/HighUserCouponMapper.java | 29 ++- .../hai/dao/HighUserCouponSqlProvider.java | 42 ++++ .../com/hai/entity/HighCouponRecycle.java | 16 ++ .../hai/entity/HighCouponRecycleExample.java | 60 ++++++ .../java/com/hai/entity/HighUserCoupon.java | 54 ++++- .../com/hai/entity/HighUserCouponExample.java | 190 ++++++++++++++++++ .../com/hai/service/HighOrderService.java | 9 +- .../hai/service/HighUserCouponService.java | 7 + .../impl/HighCouponCodeServiceImpl.java | 2 + .../service/impl/HighOrderServiceImpl.java | 6 + .../impl/HighUserCouponServiceImpl.java | 60 +++++- .../pay/impl/GoodsOrderServiceImpl.java | 1 + 16 files changed, 477 insertions(+), 32 deletions(-) diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java index 455c2fa9..76c5dd48 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java @@ -1,12 +1,10 @@ package com.hai.schedule; -import com.hai.entity.HighUserCoupon; import com.hai.service.HighUserCouponService; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.Scheduled; import javax.annotation.Resource; -import java.util.List; /** * @Auther: 胡锐 @@ -27,12 +25,6 @@ public class HighCouponSchedule { // @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 @Scheduled(cron = "0 0 0 * * ?") //每天 凌晨0点执行 public void expiredCoupon() { - List userCoupons = highUserCouponService.getOverdueCoupon(); - for (HighUserCoupon highUserCoupon : userCoupons) { - highUserCoupon.setStatus(0); // 状态 0:已过期 1:未使用 2:已使用 - highUserCouponService.updateUserCoupon(highUserCoupon); - - - } + highUserCouponService.expiredCoupon(); } } diff --git a/hai-service/src/main/java/com/hai/common/security/AESEncodeUtil.java b/hai-service/src/main/java/com/hai/common/security/AESEncodeUtil.java index c8ce24c8..a63222fc 100644 --- a/hai-service/src/main/java/com/hai/common/security/AESEncodeUtil.java +++ b/hai-service/src/main/java/com/hai/common/security/AESEncodeUtil.java @@ -61,14 +61,16 @@ public class AESEncodeUtil { public static void main(String[] args) throws Exception{ long currentTimeMillis = System.currentTimeMillis(); + + System.out.println(AESEncodeUtil.aesEncrypt("1")); /* String content = "{\"create_time\":1573544092110,\"order_serial_no\":\"40280e816db49c0b016db4a2c31f0004\",\"product_code\":\"8a9e80045cf85e54015cf8809fcd\",\"product_name\":\"平安发票贷\",\"uscc\":\"91370781687233838E\"}"; System.out.println("加密前" + content); String encrypt = com.sun.org.apache.xml.internal.security.utils.Base64.encode(aesEncryptToBytes(content, "WdOjUqtRxcBshw")); System.out.println("加密后" + encrypt);*/ - String decrypt = aesDecryptByBytes(base64Decode("i98CPRG2UI2kRzP9WE6WyF7hQQmZB5nOvc9s8BoISUJlrt59R3TPFiDYI9FNpj3BtKKR8P9JMoTSRP0/lP+SzA=="), "WdOjUqtRxcBshw"); +/* String decrypt = aesDecryptByBytes(base64Decode("i98CPRG2UI2kRzP9WE6WyF7hQQmZB5nOvc9s8BoISUJlrt59R3TPFiDYI9FNpj3BtKKR8P9JMoTSRP0/lP+SzA=="), "WdOjUqtRxcBshw"); System.out.println("解密后" + decrypt); - System.out.println(System.currentTimeMillis() - currentTimeMillis); + System.out.println(System.currentTimeMillis() - currentTimeMillis);*/ } } diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponRecycleMapper.java b/hai-service/src/main/java/com/hai/dao/HighCouponRecycleMapper.java index 9f0fa836..353033f9 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponRecycleMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponRecycleMapper.java @@ -34,14 +34,16 @@ public interface HighCouponRecycleMapper extends HighCouponRecycleMapperExt { "merchant_id, coupon_sales_code, ", "coupon_code_id, user_id, ", "user_phone, order_no, ", - "order_id, `type`, receive_time, ", + "order_id, child_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}, #{type,jdbcType=INTEGER}, #{receiveTime,jdbcType=TIMESTAMP}, ", + "#{orderId,jdbcType=BIGINT}, #{childOrderId,jdbcType=BIGINT}, ", + "#{type,jdbcType=INTEGER}, #{receiveTime,jdbcType=TIMESTAMP}, ", "#{createTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ", "#{ext3,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR})" }) @@ -64,6 +66,7 @@ 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="child_order_id", property="childOrderId", 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), diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponRecycleSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighCouponRecycleSqlProvider.java index b15660dc..b6e0bc32 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponRecycleSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponRecycleSqlProvider.java @@ -64,6 +64,10 @@ public class HighCouponRecycleSqlProvider { sql.VALUES("order_id", "#{orderId,jdbcType=BIGINT}"); } + if (record.getChildOrderId() != null) { + sql.VALUES("child_order_id", "#{childOrderId,jdbcType=BIGINT}"); + } + if (record.getType() != null) { sql.VALUES("`type`", "#{type,jdbcType=INTEGER}"); } @@ -107,6 +111,7 @@ public class HighCouponRecycleSqlProvider { sql.SELECT("user_phone"); sql.SELECT("order_no"); sql.SELECT("order_id"); + sql.SELECT("child_order_id"); sql.SELECT("`type`"); sql.SELECT("receive_time"); sql.SELECT("create_time"); @@ -170,6 +175,10 @@ public class HighCouponRecycleSqlProvider { sql.SET("order_id = #{record.orderId,jdbcType=BIGINT}"); } + if (record.getChildOrderId() != null) { + sql.SET("child_order_id = #{record.childOrderId,jdbcType=BIGINT}"); + } + if (record.getType() != null) { sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); } @@ -212,6 +221,7 @@ 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("child_order_id = #{record.childOrderId,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}"); diff --git a/hai-service/src/main/java/com/hai/dao/HighUserCouponMapper.java b/hai-service/src/main/java/com/hai/dao/HighUserCouponMapper.java index a813d021..42179e03 100644 --- a/hai-service/src/main/java/com/hai/dao/HighUserCouponMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighUserCouponMapper.java @@ -41,14 +41,18 @@ public interface HighUserCouponMapper extends HighUserCouponMapperExt { @Insert({ "insert into high_user_coupon (merchant_id, coupon_id, ", "user_id, coupon_code_id, ", - "create_time, use_end_time, ", - "`status`, ext_1, ext_2, ", - "ext_3, ext_4)", + "store_id, create_time, ", + "consume_time, use_end_time, ", + "qr_code_img, `status`, ", + "ext_1, ext_2, ext_3, ", + "ext_4)", "values (#{merchantId,jdbcType=BIGINT}, #{couponId,jdbcType=BIGINT}, ", "#{userId,jdbcType=BIGINT}, #{couponCodeId,jdbcType=BIGINT}, ", - "#{createTime,jdbcType=TIMESTAMP}, #{useEndTime,jdbcType=TIMESTAMP}, ", - "#{status,jdbcType=INTEGER}, #{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, ", - "#{ext3,jdbcType=VARCHAR}, #{ext4,jdbcType=VARCHAR})" + "#{storeId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, ", + "#{consumeTime,jdbcType=TIMESTAMP}, #{useEndTime,jdbcType=TIMESTAMP}, ", + "#{qrCodeImg,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ", + "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR}, ", + "#{ext4,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(HighUserCoupon record); @@ -64,8 +68,11 @@ public interface HighUserCouponMapper extends HighUserCouponMapperExt { @Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT), @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT), + @Result(column="store_id", property="storeId", jdbcType=JdbcType.BIGINT), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="consume_time", property="consumeTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="use_end_time", property="useEndTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="qr_code_img", property="qrCodeImg", jdbcType=JdbcType.VARCHAR), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), @@ -76,8 +83,8 @@ public interface HighUserCouponMapper extends HighUserCouponMapperExt { @Select({ "select", - "id, merchant_id, coupon_id, user_id, coupon_code_id, create_time, use_end_time, ", - "`status`, ext_1, ext_2, ext_3, ext_4", + "id, merchant_id, coupon_id, user_id, coupon_code_id, store_id, create_time, ", + "consume_time, use_end_time, qr_code_img, `status`, ext_1, ext_2, ext_3, ext_4", "from high_user_coupon", "where id = #{id,jdbcType=BIGINT}" }) @@ -87,8 +94,11 @@ public interface HighUserCouponMapper extends HighUserCouponMapperExt { @Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT), @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT), + @Result(column="store_id", property="storeId", jdbcType=JdbcType.BIGINT), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="consume_time", property="consumeTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="use_end_time", property="useEndTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="qr_code_img", property="qrCodeImg", jdbcType=JdbcType.VARCHAR), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), @@ -112,8 +122,11 @@ public interface HighUserCouponMapper extends HighUserCouponMapperExt { "coupon_id = #{couponId,jdbcType=BIGINT},", "user_id = #{userId,jdbcType=BIGINT},", "coupon_code_id = #{couponCodeId,jdbcType=BIGINT},", + "store_id = #{storeId,jdbcType=BIGINT},", "create_time = #{createTime,jdbcType=TIMESTAMP},", + "consume_time = #{consumeTime,jdbcType=TIMESTAMP},", "use_end_time = #{useEndTime,jdbcType=TIMESTAMP},", + "qr_code_img = #{qrCodeImg,jdbcType=VARCHAR},", "`status` = #{status,jdbcType=INTEGER},", "ext_1 = #{ext1,jdbcType=VARCHAR},", "ext_2 = #{ext2,jdbcType=VARCHAR},", diff --git a/hai-service/src/main/java/com/hai/dao/HighUserCouponSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighUserCouponSqlProvider.java index c5b027e1..3bcd0189 100644 --- a/hai-service/src/main/java/com/hai/dao/HighUserCouponSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighUserCouponSqlProvider.java @@ -44,14 +44,26 @@ public class HighUserCouponSqlProvider { sql.VALUES("coupon_code_id", "#{couponCodeId,jdbcType=BIGINT}"); } + if (record.getStoreId() != null) { + sql.VALUES("store_id", "#{storeId,jdbcType=BIGINT}"); + } + if (record.getCreateTime() != null) { sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}"); } + if (record.getConsumeTime() != null) { + sql.VALUES("consume_time", "#{consumeTime,jdbcType=TIMESTAMP}"); + } + if (record.getUseEndTime() != null) { sql.VALUES("use_end_time", "#{useEndTime,jdbcType=TIMESTAMP}"); } + if (record.getQrCodeImg() != null) { + sql.VALUES("qr_code_img", "#{qrCodeImg,jdbcType=VARCHAR}"); + } + if (record.getStatus() != null) { sql.VALUES("`status`", "#{status,jdbcType=INTEGER}"); } @@ -86,8 +98,11 @@ public class HighUserCouponSqlProvider { sql.SELECT("coupon_id"); sql.SELECT("user_id"); sql.SELECT("coupon_code_id"); + sql.SELECT("store_id"); sql.SELECT("create_time"); + sql.SELECT("consume_time"); sql.SELECT("use_end_time"); + sql.SELECT("qr_code_img"); sql.SELECT("`status`"); sql.SELECT("ext_1"); sql.SELECT("ext_2"); @@ -130,14 +145,26 @@ public class HighUserCouponSqlProvider { sql.SET("coupon_code_id = #{record.couponCodeId,jdbcType=BIGINT}"); } + if (record.getStoreId() != null) { + sql.SET("store_id = #{record.storeId,jdbcType=BIGINT}"); + } + if (record.getCreateTime() != null) { sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); } + if (record.getConsumeTime() != null) { + sql.SET("consume_time = #{record.consumeTime,jdbcType=TIMESTAMP}"); + } + if (record.getUseEndTime() != null) { sql.SET("use_end_time = #{record.useEndTime,jdbcType=TIMESTAMP}"); } + if (record.getQrCodeImg() != null) { + sql.SET("qr_code_img = #{record.qrCodeImg,jdbcType=VARCHAR}"); + } + if (record.getStatus() != null) { sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); } @@ -171,8 +198,11 @@ public class HighUserCouponSqlProvider { sql.SET("coupon_id = #{record.couponId,jdbcType=BIGINT}"); sql.SET("user_id = #{record.userId,jdbcType=BIGINT}"); sql.SET("coupon_code_id = #{record.couponCodeId,jdbcType=BIGINT}"); + sql.SET("store_id = #{record.storeId,jdbcType=BIGINT}"); sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); + sql.SET("consume_time = #{record.consumeTime,jdbcType=TIMESTAMP}"); sql.SET("use_end_time = #{record.useEndTime,jdbcType=TIMESTAMP}"); + sql.SET("qr_code_img = #{record.qrCodeImg,jdbcType=VARCHAR}"); sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); @@ -204,14 +234,26 @@ public class HighUserCouponSqlProvider { sql.SET("coupon_code_id = #{couponCodeId,jdbcType=BIGINT}"); } + if (record.getStoreId() != null) { + sql.SET("store_id = #{storeId,jdbcType=BIGINT}"); + } + if (record.getCreateTime() != null) { sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}"); } + if (record.getConsumeTime() != null) { + sql.SET("consume_time = #{consumeTime,jdbcType=TIMESTAMP}"); + } + if (record.getUseEndTime() != null) { sql.SET("use_end_time = #{useEndTime,jdbcType=TIMESTAMP}"); } + if (record.getQrCodeImg() != null) { + sql.SET("qr_code_img = #{qrCodeImg,jdbcType=VARCHAR}"); + } + if (record.getStatus() != null) { sql.SET("`status` = #{status,jdbcType=INTEGER}"); } diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponRecycle.java b/hai-service/src/main/java/com/hai/entity/HighCouponRecycle.java index 97c9c073..475cb097 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponRecycle.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponRecycle.java @@ -63,6 +63,11 @@ public class HighCouponRecycle implements Serializable { */ private Long orderId; + /** + * 子订单id + */ + private Long childOrderId; + /** * 类型:1.过期 2.退款 */ @@ -166,6 +171,14 @@ public class HighCouponRecycle implements Serializable { this.orderId = orderId; } + public Long getChildOrderId() { + return childOrderId; + } + + public void setChildOrderId(Long childOrderId) { + this.childOrderId = childOrderId; + } + public Integer getType() { return type; } @@ -236,6 +249,7 @@ 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.getChildOrderId() == null ? other.getChildOrderId() == null : this.getChildOrderId().equals(other.getChildOrderId())) && (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())) @@ -258,6 +272,7 @@ 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 + ((getChildOrderId() == null) ? 0 : getChildOrderId().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()); @@ -283,6 +298,7 @@ public class HighCouponRecycle implements Serializable { sb.append(", userPhone=").append(userPhone); sb.append(", orderNo=").append(orderNo); sb.append(", orderId=").append(orderId); + sb.append(", childOrderId=").append(childOrderId); sb.append(", type=").append(type); sb.append(", receiveTime=").append(receiveTime); sb.append(", createTime=").append(createTime); diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponRecycleExample.java b/hai-service/src/main/java/com/hai/entity/HighCouponRecycleExample.java index e5690719..d1bf1d25 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponRecycleExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponRecycleExample.java @@ -765,6 +765,66 @@ public class HighCouponRecycleExample { return (Criteria) this; } + public Criteria andChildOrderIdIsNull() { + addCriterion("child_order_id is null"); + return (Criteria) this; + } + + public Criteria andChildOrderIdIsNotNull() { + addCriterion("child_order_id is not null"); + return (Criteria) this; + } + + public Criteria andChildOrderIdEqualTo(Long value) { + addCriterion("child_order_id =", value, "childOrderId"); + return (Criteria) this; + } + + public Criteria andChildOrderIdNotEqualTo(Long value) { + addCriterion("child_order_id <>", value, "childOrderId"); + return (Criteria) this; + } + + public Criteria andChildOrderIdGreaterThan(Long value) { + addCriterion("child_order_id >", value, "childOrderId"); + return (Criteria) this; + } + + public Criteria andChildOrderIdGreaterThanOrEqualTo(Long value) { + addCriterion("child_order_id >=", value, "childOrderId"); + return (Criteria) this; + } + + public Criteria andChildOrderIdLessThan(Long value) { + addCriterion("child_order_id <", value, "childOrderId"); + return (Criteria) this; + } + + public Criteria andChildOrderIdLessThanOrEqualTo(Long value) { + addCriterion("child_order_id <=", value, "childOrderId"); + return (Criteria) this; + } + + public Criteria andChildOrderIdIn(List values) { + addCriterion("child_order_id in", values, "childOrderId"); + return (Criteria) this; + } + + public Criteria andChildOrderIdNotIn(List values) { + addCriterion("child_order_id not in", values, "childOrderId"); + return (Criteria) this; + } + + public Criteria andChildOrderIdBetween(Long value1, Long value2) { + addCriterion("child_order_id between", value1, value2, "childOrderId"); + return (Criteria) this; + } + + public Criteria andChildOrderIdNotBetween(Long value1, Long value2) { + addCriterion("child_order_id not between", value1, value2, "childOrderId"); + return (Criteria) this; + } + public Criteria andTypeIsNull() { addCriterion("`type` is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/entity/HighUserCoupon.java b/hai-service/src/main/java/com/hai/entity/HighUserCoupon.java index 07f8bd08..c563f12f 100644 --- a/hai-service/src/main/java/com/hai/entity/HighUserCoupon.java +++ b/hai-service/src/main/java/com/hai/entity/HighUserCoupon.java @@ -41,15 +41,30 @@ public class HighUserCoupon implements Serializable { private Long couponCodeId; /** - * 创建时间 + * (消核门店) 门店id + */ + private Long storeId; + + /** + * 领取时间 */ private Date createTime; + /** + * 消费时间 + */ + private Date consumeTime; + /** * 使用截止时间 */ private Date useEndTime; + /** + * 二维码 + */ + private String qrCodeImg; + /** * 状态 0:已过期 1:未使用 2:已使用 */ @@ -65,6 +80,8 @@ public class HighUserCoupon implements Serializable { private HighCouponModel highCouponModel; + private static final long serialVersionUID = 1L; + public HighCouponModel getHighCouponModel() { return highCouponModel; } @@ -73,8 +90,6 @@ public class HighUserCoupon implements Serializable { this.highCouponModel = highCouponModel; } - private static final long serialVersionUID = 1L; - public Long getId() { return id; } @@ -115,6 +130,14 @@ public class HighUserCoupon implements Serializable { this.couponCodeId = couponCodeId; } + public Long getStoreId() { + return storeId; + } + + public void setStoreId(Long storeId) { + this.storeId = storeId; + } + public Date getCreateTime() { return createTime; } @@ -123,6 +146,14 @@ public class HighUserCoupon implements Serializable { this.createTime = createTime; } + public Date getConsumeTime() { + return consumeTime; + } + + public void setConsumeTime(Date consumeTime) { + this.consumeTime = consumeTime; + } + public Date getUseEndTime() { return useEndTime; } @@ -131,6 +162,14 @@ public class HighUserCoupon implements Serializable { this.useEndTime = useEndTime; } + public String getQrCodeImg() { + return qrCodeImg; + } + + public void setQrCodeImg(String qrCodeImg) { + this.qrCodeImg = qrCodeImg; + } + public Integer getStatus() { return status; } @@ -188,8 +227,11 @@ public class HighUserCoupon implements Serializable { && (this.getCouponId() == null ? other.getCouponId() == null : this.getCouponId().equals(other.getCouponId())) && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) && (this.getCouponCodeId() == null ? other.getCouponCodeId() == null : this.getCouponCodeId().equals(other.getCouponCodeId())) + && (this.getStoreId() == null ? other.getStoreId() == null : this.getStoreId().equals(other.getStoreId())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) + && (this.getConsumeTime() == null ? other.getConsumeTime() == null : this.getConsumeTime().equals(other.getConsumeTime())) && (this.getUseEndTime() == null ? other.getUseEndTime() == null : this.getUseEndTime().equals(other.getUseEndTime())) + && (this.getQrCodeImg() == null ? other.getQrCodeImg() == null : this.getQrCodeImg().equals(other.getQrCodeImg())) && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) && (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1())) && (this.getExt2() == null ? other.getExt2() == null : this.getExt2().equals(other.getExt2())) @@ -206,8 +248,11 @@ public class HighUserCoupon implements Serializable { result = prime * result + ((getCouponId() == null) ? 0 : getCouponId().hashCode()); result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); result = prime * result + ((getCouponCodeId() == null) ? 0 : getCouponCodeId().hashCode()); + result = prime * result + ((getStoreId() == null) ? 0 : getStoreId().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); + result = prime * result + ((getConsumeTime() == null) ? 0 : getConsumeTime().hashCode()); result = prime * result + ((getUseEndTime() == null) ? 0 : getUseEndTime().hashCode()); + result = prime * result + ((getQrCodeImg() == null) ? 0 : getQrCodeImg().hashCode()); result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode()); result = prime * result + ((getExt2() == null) ? 0 : getExt2().hashCode()); @@ -227,8 +272,11 @@ public class HighUserCoupon implements Serializable { sb.append(", couponId=").append(couponId); sb.append(", userId=").append(userId); sb.append(", couponCodeId=").append(couponCodeId); + sb.append(", storeId=").append(storeId); sb.append(", createTime=").append(createTime); + sb.append(", consumeTime=").append(consumeTime); sb.append(", useEndTime=").append(useEndTime); + sb.append(", qrCodeImg=").append(qrCodeImg); sb.append(", status=").append(status); sb.append(", ext1=").append(ext1); sb.append(", ext2=").append(ext2); diff --git a/hai-service/src/main/java/com/hai/entity/HighUserCouponExample.java b/hai-service/src/main/java/com/hai/entity/HighUserCouponExample.java index 821bf507..0d67fceb 100644 --- a/hai-service/src/main/java/com/hai/entity/HighUserCouponExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighUserCouponExample.java @@ -425,6 +425,66 @@ public class HighUserCouponExample { return (Criteria) this; } + public Criteria andStoreIdIsNull() { + addCriterion("store_id is null"); + return (Criteria) this; + } + + public Criteria andStoreIdIsNotNull() { + addCriterion("store_id is not null"); + return (Criteria) this; + } + + public Criteria andStoreIdEqualTo(Long value) { + addCriterion("store_id =", value, "storeId"); + return (Criteria) this; + } + + public Criteria andStoreIdNotEqualTo(Long value) { + addCriterion("store_id <>", value, "storeId"); + return (Criteria) this; + } + + public Criteria andStoreIdGreaterThan(Long value) { + addCriterion("store_id >", value, "storeId"); + return (Criteria) this; + } + + public Criteria andStoreIdGreaterThanOrEqualTo(Long value) { + addCriterion("store_id >=", value, "storeId"); + return (Criteria) this; + } + + public Criteria andStoreIdLessThan(Long value) { + addCriterion("store_id <", value, "storeId"); + return (Criteria) this; + } + + public Criteria andStoreIdLessThanOrEqualTo(Long value) { + addCriterion("store_id <=", value, "storeId"); + return (Criteria) this; + } + + public Criteria andStoreIdIn(List values) { + addCriterion("store_id in", values, "storeId"); + return (Criteria) this; + } + + public Criteria andStoreIdNotIn(List values) { + addCriterion("store_id not in", values, "storeId"); + return (Criteria) this; + } + + public Criteria andStoreIdBetween(Long value1, Long value2) { + addCriterion("store_id between", value1, value2, "storeId"); + return (Criteria) this; + } + + public Criteria andStoreIdNotBetween(Long value1, Long value2) { + addCriterion("store_id not between", value1, value2, "storeId"); + return (Criteria) this; + } + public Criteria andCreateTimeIsNull() { addCriterion("create_time is null"); return (Criteria) this; @@ -485,6 +545,66 @@ public class HighUserCouponExample { return (Criteria) this; } + public Criteria andConsumeTimeIsNull() { + addCriterion("consume_time is null"); + return (Criteria) this; + } + + public Criteria andConsumeTimeIsNotNull() { + addCriterion("consume_time is not null"); + return (Criteria) this; + } + + public Criteria andConsumeTimeEqualTo(Date value) { + addCriterion("consume_time =", value, "consumeTime"); + return (Criteria) this; + } + + public Criteria andConsumeTimeNotEqualTo(Date value) { + addCriterion("consume_time <>", value, "consumeTime"); + return (Criteria) this; + } + + public Criteria andConsumeTimeGreaterThan(Date value) { + addCriterion("consume_time >", value, "consumeTime"); + return (Criteria) this; + } + + public Criteria andConsumeTimeGreaterThanOrEqualTo(Date value) { + addCriterion("consume_time >=", value, "consumeTime"); + return (Criteria) this; + } + + public Criteria andConsumeTimeLessThan(Date value) { + addCriterion("consume_time <", value, "consumeTime"); + return (Criteria) this; + } + + public Criteria andConsumeTimeLessThanOrEqualTo(Date value) { + addCriterion("consume_time <=", value, "consumeTime"); + return (Criteria) this; + } + + public Criteria andConsumeTimeIn(List values) { + addCriterion("consume_time in", values, "consumeTime"); + return (Criteria) this; + } + + public Criteria andConsumeTimeNotIn(List values) { + addCriterion("consume_time not in", values, "consumeTime"); + return (Criteria) this; + } + + public Criteria andConsumeTimeBetween(Date value1, Date value2) { + addCriterion("consume_time between", value1, value2, "consumeTime"); + return (Criteria) this; + } + + public Criteria andConsumeTimeNotBetween(Date value1, Date value2) { + addCriterion("consume_time not between", value1, value2, "consumeTime"); + return (Criteria) this; + } + public Criteria andUseEndTimeIsNull() { addCriterion("use_end_time is null"); return (Criteria) this; @@ -545,6 +665,76 @@ public class HighUserCouponExample { return (Criteria) this; } + public Criteria andQrCodeImgIsNull() { + addCriterion("qr_code_img is null"); + return (Criteria) this; + } + + public Criteria andQrCodeImgIsNotNull() { + addCriterion("qr_code_img is not null"); + return (Criteria) this; + } + + public Criteria andQrCodeImgEqualTo(String value) { + addCriterion("qr_code_img =", value, "qrCodeImg"); + return (Criteria) this; + } + + public Criteria andQrCodeImgNotEqualTo(String value) { + addCriterion("qr_code_img <>", value, "qrCodeImg"); + return (Criteria) this; + } + + public Criteria andQrCodeImgGreaterThan(String value) { + addCriterion("qr_code_img >", value, "qrCodeImg"); + return (Criteria) this; + } + + public Criteria andQrCodeImgGreaterThanOrEqualTo(String value) { + addCriterion("qr_code_img >=", value, "qrCodeImg"); + return (Criteria) this; + } + + public Criteria andQrCodeImgLessThan(String value) { + addCriterion("qr_code_img <", value, "qrCodeImg"); + return (Criteria) this; + } + + public Criteria andQrCodeImgLessThanOrEqualTo(String value) { + addCriterion("qr_code_img <=", value, "qrCodeImg"); + return (Criteria) this; + } + + public Criteria andQrCodeImgLike(String value) { + addCriterion("qr_code_img like", value, "qrCodeImg"); + return (Criteria) this; + } + + public Criteria andQrCodeImgNotLike(String value) { + addCriterion("qr_code_img not like", value, "qrCodeImg"); + return (Criteria) this; + } + + public Criteria andQrCodeImgIn(List values) { + addCriterion("qr_code_img in", values, "qrCodeImg"); + return (Criteria) this; + } + + public Criteria andQrCodeImgNotIn(List values) { + addCriterion("qr_code_img not in", values, "qrCodeImg"); + return (Criteria) this; + } + + public Criteria andQrCodeImgBetween(String value1, String value2) { + addCriterion("qr_code_img between", value1, value2, "qrCodeImg"); + return (Criteria) this; + } + + public Criteria andQrCodeImgNotBetween(String value1, String value2) { + addCriterion("qr_code_img not between", value1, value2, "qrCodeImg"); + return (Criteria) this; + } + public Criteria andStatusIsNull() { addCriterion("`status` is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/service/HighOrderService.java b/hai-service/src/main/java/com/hai/service/HighOrderService.java index 360f16ec..6dc17ec5 100644 --- a/hai-service/src/main/java/com/hai/service/HighOrderService.java +++ b/hai-service/src/main/java/com/hai/service/HighOrderService.java @@ -42,6 +42,13 @@ public interface HighOrderService { **/ Integer getUndoneChildOrder(Long orderId); + /** + * @Author 胡锐 + * @Description 查询子商品 + * @Date 2021/4/5 13:23 + **/ + HighChildOrder getChildOrderById(Long childOrderId); + /** * 根据订单id 查询子商品 * @param orderId @@ -114,7 +121,7 @@ public interface HighOrderService { /** * @Author 袁野 - * @Description 根据未使用优惠券 + * @Description 未使用优惠券数量 * @Date 2021/3/27 15:50 **/ Integer countUnusedDiscountByUserId(Long userId , Integer status); diff --git a/hai-service/src/main/java/com/hai/service/HighUserCouponService.java b/hai-service/src/main/java/com/hai/service/HighUserCouponService.java index 74987f6f..82cfe0ba 100644 --- a/hai-service/src/main/java/com/hai/service/HighUserCouponService.java +++ b/hai-service/src/main/java/com/hai/service/HighUserCouponService.java @@ -65,5 +65,12 @@ public interface HighUserCouponService { **/ HighUserCoupon againReceiveCoupon(Long userId,Long couponId); + /** + * @Author 胡锐 + * @Description 处理过期的卡券 + * @Date 2021/4/5 12:26 + **/ + void expiredCoupon(); + } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java index 0301179a..ebfa787e 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java @@ -97,6 +97,8 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService { if (userCoupon == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "卡卷状态异常"); } + userCoupon.setStoreId(userInfoModel.getMerchantStore().getId()); + userCoupon.setConsumeTime(new Date()); userCoupon.setStatus(2); // 状态 0:已过期 1:未使用 2:已使用 highUserCouponService.updateUserCoupon(userCoupon); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java index 88af9718..9b7a735f 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java @@ -164,6 +164,7 @@ public class HighOrderServiceImpl implements HighOrderService { highUserCoupon.setUserId(highOrder.getMemId()); highUserCoupon.setCouponCodeId(code.getId()); highUserCoupon.setCreateTime(new Date()); + highUserCoupon.setQrCodeImg(code.getExt1()); // 计算使用有效期 Calendar userEndTime = Calendar.getInstance(); @@ -208,6 +209,11 @@ public class HighOrderServiceImpl implements HighOrderService { return count; } + @Override + public HighChildOrder getChildOrderById(Long childOrderId) { + return highChildOrderMapper.selectByPrimaryKey(childOrderId); + } + @Override public List getChildOrderByOrder(Long orderId) { HighChildOrderExample example = new HighChildOrderExample(); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java index fc9e8e1a..2ac140f5 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java @@ -5,14 +5,9 @@ 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.entity.*; import com.hai.model.HighUserCouponModel; -import com.hai.service.HighCouponCodeService; -import com.hai.service.HighCouponService; -import com.hai.service.HighUserCouponService; +import com.hai.service.*; import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; @@ -38,6 +33,15 @@ public class HighUserCouponServiceImpl implements HighUserCouponService { @Resource private HighCouponCodeService highCouponCodeService; + @Resource + private HighCouponRecycleService highCouponRecycleService; + + @Resource + private HighOrderService highOrderService; + + @Resource + private HighUserService highUserService; + @Override public void insertUserCoupon(HighUserCoupon highUserCoupon) { highUserCouponMapper.insert(highUserCoupon); @@ -166,4 +170,46 @@ public class HighUserCouponServiceImpl implements HighUserCouponService { return highUserCoupon; } + + @Override + public void expiredCoupon() { + // 查询过期的卡券 + List userCoupons = getOverdueCoupon(); + for (HighUserCoupon highUserCoupon : userCoupons) { + highUserCoupon.setStatus(0); // 状态 0:已过期 1:未使用 2:已使用 + highUserCoupon.setQrCodeImg(null); + updateUserCoupon(highUserCoupon); + + // 查询销售码 + HighCouponCode couponCode = highCouponCodeService.getCouponCodeById(highUserCoupon.getCouponCodeId()); + couponCode.setChildOrderId(null); + couponCode.setReceiveTime(null); + + // 查询卡券信息 + HighCoupon coupon = highCouponService.getCouponById(highUserCoupon.getCouponId()); + + HighChildOrder childOrder = highOrderService.getChildOrderById(couponCode.getChildOrderId()); + HighOrder order = highOrderService.getOrderById(childOrder.getId()); + + + + // 归库记录 + HighCouponRecycle highCouponRecycle = new HighCouponRecycle(); + highCouponRecycle.setCouponId(coupon.getId()); + highCouponRecycle.setCouponName(coupon.getCouponName()); + highCouponRecycle.setMerchantId(coupon.getMerchantId()); + + highCouponRecycle.setCouponSalesCode(couponCode.getSalesCode()); + highCouponRecycle.setCouponCodeId(couponCode.getId()); + + highCouponRecycle.setOrderId(childOrder.getOrderId()); + highCouponRecycle.setOrderNo(order.getOrderNo()); + highCouponRecycle.setChildOrderId(childOrder.getId()); + + highCouponRecycle.setType(1); // 类型:1.过期 2.退款 + highCouponRecycle.setReceiveTime(highUserCoupon.getCreateTime()); // 领取时间 + highCouponRecycle.setCreateTime(new Date()); + highCouponRecycleService.insertCouponRecycle(highCouponRecycle); + } + } } diff --git a/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java index a93e0e31..2efd8792 100644 --- a/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java @@ -78,6 +78,7 @@ public class GoodsOrderServiceImpl implements PayService { highUserCoupon.setUserId(order.getMemId()); highUserCoupon.setCouponCodeId(code.getId()); highUserCoupon.setCreateTime(new Date()); + highUserCoupon.setQrCodeImg(code.getExt1()); // 计算使用有效期 Calendar userEndTime = Calendar.getInstance();