From d8ee5d273e69ea3ee448caa213a7a6a7aaa610cb Mon Sep 17 00:00:00 2001 From: 199901012 Date: Tue, 6 Apr 2021 22:00:59 +0800 Subject: [PATCH] =?UTF-8?q?'=E4=BF=AE=E5=A4=8D=E5=B7=B2=E7=9F=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cweb/controller/HighOrderController.java | 2 + .../com/hai/schedule/HighCouponSchedule.java | 3 +- .../hai/schedule/HighDiscountSchedule.java | 2 +- .../com/hai/common/security/UserCenter.java | 2 +- .../com/hai/dao/HighCouponRecycleMapper.java | 65 ++++++++++++++++- .../hai/dao/HighCouponRecycleSqlProvider.java | 73 +++++++++++++++++++ .../impl/HighDiscountUserRelServiceImpl.java | 2 +- .../impl/HighUserCouponServiceImpl.java | 10 ++- 8 files changed, 149 insertions(+), 10 deletions(-) diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java index d831c4a3..ed4ea621 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java @@ -108,6 +108,8 @@ public class HighOrderController { log.error("HighOrderController --> addOrder() error!", "未找到卡卷信息"); throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, ""); } + highOrder.setPayModel(1); // 支付模式:1 金币,2 第三方平台,3 混合 + highOrder.setPayType(3); // 支付方式: 1:支付宝 2:微信 3:金币 // 是否达到限购数量 if (highCouponService.userBuyLimitNumber(userInfoModel.getHighUser().getId(), coupon.getId()) == true) { log.error("HighOrderController --> addOrder() error!", "已达到限购数量"); 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 68c564db..6bd8676b 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java @@ -29,8 +29,7 @@ public class HighCouponSchedule { * @Description 处理过期的卡券 * @Date 2021/4/4 22:44 **/ - // @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 - @Scheduled(cron = "0 0 0 * * ?") //每天 凌晨0点执行 + @Scheduled(cron = "5 0 0 * * ?") //每日凌晨12点5秒执行一次 public void expiredCoupon() { // 查询过期的卡券 List userCoupons = highUserCouponService.getOverdueCoupon(); diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java index b370a79c..9abb88cf 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java @@ -29,7 +29,7 @@ public class HighDiscountSchedule { * @Description 处理过期的优惠券 * @Date 2021/4/4 22:44 **/ - @Scheduled(cron = "0 0 0 * * ?") //每1分钟执行一次 + @Scheduled(cron = "5 0 0 * * ?") //每日凌晨12点5秒执行一次 public void expiredDiscount() { List expiredDiscount = highDiscountUserRelService.getExpiredDiscount(); for (HighDiscountUserRel rel : expiredDiscount) { diff --git a/hai-service/src/main/java/com/hai/common/security/UserCenter.java b/hai-service/src/main/java/com/hai/common/security/UserCenter.java index 63044d0e..43c9d1e9 100644 --- a/hai-service/src/main/java/com/hai/common/security/UserCenter.java +++ b/hai-service/src/main/java/com/hai/common/security/UserCenter.java @@ -19,7 +19,7 @@ public class UserCenter { private static Logger log = LoggerFactory.getLogger(UserCenter.class); private static final String COOKIE_FIELD = "_ida"; - private static final int EXPIRE = 3600;//cookie过期时间为1小时,3600秒 + private static final int EXPIRE = 43200;//过期时间为12小时 /** * 判断用户是否登录,并且不能单个用户同时登录 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 353033f9..f0336feb 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponRecycleMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponRecycleMapper.java @@ -3,6 +3,7 @@ package com.hai.dao; import com.hai.entity.HighCouponRecycle; import com.hai.entity.HighCouponRecycleExample; import java.util.List; +import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.DeleteProvider; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.InsertProvider; @@ -10,7 +11,9 @@ import org.apache.ibatis.annotations.Options; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Result; import org.apache.ibatis.annotations.Results; +import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.SelectProvider; +import org.apache.ibatis.annotations.Update; import org.apache.ibatis.annotations.UpdateProvider; import org.apache.ibatis.type.JdbcType; import org.springframework.stereotype.Repository; @@ -29,6 +32,12 @@ public interface HighCouponRecycleMapper extends HighCouponRecycleMapperExt { @DeleteProvider(type=HighCouponRecycleSqlProvider.class, method="deleteByExample") int deleteByExample(HighCouponRecycleExample example); + @Delete({ + "delete from high_coupon_recycle", + "where id = #{id,jdbcType=BIGINT}" + }) + int deleteByPrimaryKey(Long id); + @Insert({ "insert into high_coupon_recycle (coupon_id, coupon_name, ", "merchant_id, coupon_sales_code, ", @@ -56,7 +65,7 @@ public interface HighCouponRecycleMapper extends HighCouponRecycleMapperExt { @SelectProvider(type=HighCouponRecycleSqlProvider.class, method="selectByExample") @Results({ - @Result(column="id", property="id", jdbcType=JdbcType.BIGINT), + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_name", property="couponName", jdbcType=JdbcType.VARCHAR), @Result(column="merchant_id", property="merchantId", jdbcType=JdbcType.BIGINT), @@ -76,9 +85,63 @@ public interface HighCouponRecycleMapper extends HighCouponRecycleMapperExt { }) List selectByExample(HighCouponRecycleExample example); + @Select({ + "select", + "id, coupon_id, coupon_name, merchant_id, coupon_sales_code, coupon_code_id, ", + "user_id, user_phone, order_no, order_id, child_order_id, `type`, receive_time, ", + "create_time, ext_1, ext_3, ext_2", + "from high_coupon_recycle", + "where id = #{id,jdbcType=BIGINT}" + }) + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT), + @Result(column="coupon_name", property="couponName", jdbcType=JdbcType.VARCHAR), + @Result(column="merchant_id", property="merchantId", jdbcType=JdbcType.BIGINT), + @Result(column="coupon_sales_code", property="couponSalesCode", jdbcType=JdbcType.VARCHAR), + @Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT), + @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT), + @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), + @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) + }) + HighCouponRecycle selectByPrimaryKey(Long id); + @UpdateProvider(type=HighCouponRecycleSqlProvider.class, method="updateByExampleSelective") int updateByExampleSelective(@Param("record") HighCouponRecycle record, @Param("example") HighCouponRecycleExample example); @UpdateProvider(type=HighCouponRecycleSqlProvider.class, method="updateByExample") int updateByExample(@Param("record") HighCouponRecycle record, @Param("example") HighCouponRecycleExample example); + + @UpdateProvider(type=HighCouponRecycleSqlProvider.class, method="updateByPrimaryKeySelective") + int updateByPrimaryKeySelective(HighCouponRecycle record); + + @Update({ + "update high_coupon_recycle", + "set coupon_id = #{couponId,jdbcType=BIGINT},", + "coupon_name = #{couponName,jdbcType=VARCHAR},", + "merchant_id = #{merchantId,jdbcType=BIGINT},", + "coupon_sales_code = #{couponSalesCode,jdbcType=VARCHAR},", + "coupon_code_id = #{couponCodeId,jdbcType=BIGINT},", + "user_id = #{userId,jdbcType=BIGINT},", + "user_phone = #{userPhone,jdbcType=VARCHAR},", + "order_no = #{orderNo,jdbcType=VARCHAR},", + "order_id = #{orderId,jdbcType=BIGINT},", + "child_order_id = #{childOrderId,jdbcType=BIGINT},", + "`type` = #{type,jdbcType=INTEGER},", + "receive_time = #{receiveTime,jdbcType=TIMESTAMP},", + "create_time = #{createTime,jdbcType=TIMESTAMP},", + "ext_1 = #{ext1,jdbcType=VARCHAR},", + "ext_3 = #{ext3,jdbcType=VARCHAR},", + "ext_2 = #{ext2,jdbcType=VARCHAR}", + "where id = #{id,jdbcType=BIGINT}" + }) + int updateByPrimaryKey(HighCouponRecycle record); } \ No newline at end of file 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 b6e0bc32..40e65f28 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponRecycleSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponRecycleSqlProvider.java @@ -234,6 +234,79 @@ public class HighCouponRecycleSqlProvider { return sql.toString(); } + public String updateByPrimaryKeySelective(HighCouponRecycle record) { + SQL sql = new SQL(); + sql.UPDATE("high_coupon_recycle"); + + if (record.getCouponId() != null) { + sql.SET("coupon_id = #{couponId,jdbcType=BIGINT}"); + } + + if (record.getCouponName() != null) { + sql.SET("coupon_name = #{couponName,jdbcType=VARCHAR}"); + } + + if (record.getMerchantId() != null) { + sql.SET("merchant_id = #{merchantId,jdbcType=BIGINT}"); + } + + if (record.getCouponSalesCode() != null) { + sql.SET("coupon_sales_code = #{couponSalesCode,jdbcType=VARCHAR}"); + } + + if (record.getCouponCodeId() != null) { + sql.SET("coupon_code_id = #{couponCodeId,jdbcType=BIGINT}"); + } + + if (record.getUserId() != null) { + sql.SET("user_id = #{userId,jdbcType=BIGINT}"); + } + + if (record.getUserPhone() != null) { + sql.SET("user_phone = #{userPhone,jdbcType=VARCHAR}"); + } + + if (record.getOrderNo() != null) { + sql.SET("order_no = #{orderNo,jdbcType=VARCHAR}"); + } + + if (record.getOrderId() != null) { + sql.SET("order_id = #{orderId,jdbcType=BIGINT}"); + } + + if (record.getChildOrderId() != null) { + sql.SET("child_order_id = #{childOrderId,jdbcType=BIGINT}"); + } + + if (record.getType() != null) { + sql.SET("`type` = #{type,jdbcType=INTEGER}"); + } + + if (record.getReceiveTime() != null) { + sql.SET("receive_time = #{receiveTime,jdbcType=TIMESTAMP}"); + } + + if (record.getCreateTime() != null) { + sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getExt1() != null) { + sql.SET("ext_1 = #{ext1,jdbcType=VARCHAR}"); + } + + if (record.getExt3() != null) { + sql.SET("ext_3 = #{ext3,jdbcType=VARCHAR}"); + } + + if (record.getExt2() != null) { + sql.SET("ext_2 = #{ext2,jdbcType=VARCHAR}"); + } + + sql.WHERE("id = #{id,jdbcType=BIGINT}"); + + return sql.toString(); + } + protected void applyWhere(SQL sql, HighCouponRecycleExample example, boolean includeExamplePhrase) { if (example == null) { return; diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java index 04d06dce..b6862287 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java @@ -144,7 +144,7 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic @Override public List getExpiredDiscount() { HighDiscountUserRelExample example = new HighDiscountUserRelExample(); - example.createCriteria().andStatusEqualTo(1).andUseEndTimeGreaterThanOrEqualTo(new Date()); + example.createCriteria().andStatusEqualTo(1).andUseEndTimeLessThanOrEqualTo(new Date()); return highDiscountUserRelMapper.selectByExample(example); } } 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 9d206632..28522477 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 @@ -55,7 +55,7 @@ public class HighUserCouponServiceImpl implements HighUserCouponService { @Override public List getOverdueCoupon() { HighUserCouponExample example = new HighUserCouponExample(); - example.createCriteria().andStatusEqualTo(1).andUseEndTimeGreaterThanOrEqualTo(new Date()); + example.createCriteria().andStatusEqualTo(1).andUseEndTimeLessThanOrEqualTo(new Date()); return highUserCouponMapper.selectByExample(example); } @@ -181,8 +181,6 @@ public class HighUserCouponServiceImpl implements HighUserCouponService { // 查询销售码 HighCouponCode couponCode = highCouponCodeService.getCouponCodeById(highUserCoupon.getCouponCodeId()); - couponCode.setChildOrderId(null); - couponCode.setReceiveTime(null); HighUser highUser = highUserService.findByUserId(highUserCoupon.getUserId()); @@ -190,7 +188,7 @@ public class HighUserCouponServiceImpl implements HighUserCouponService { HighCoupon coupon = highCouponService.getCouponById(highUserCoupon.getCouponId()); HighChildOrder childOrder = highOrderService.getChildOrderById(couponCode.getChildOrderId()); - HighOrder order = highOrderService.getOrderById(childOrder.getId()); + HighOrder order = highOrderService.getOrderById(childOrder.getOrderId()); // 归库记录 HighCouponRecycle highCouponRecycle = new HighCouponRecycle(); @@ -212,5 +210,9 @@ public class HighUserCouponServiceImpl implements HighUserCouponService { highCouponRecycle.setReceiveTime(highUserCoupon.getCreateTime()); // 领取时间 highCouponRecycle.setCreateTime(new Date()); highCouponRecycleService.insertCouponRecycle(highCouponRecycle); + + couponCode.setChildOrderId(null); + couponCode.setReceiveTime(null); + highCouponCodeService.updateCouponCode(couponCode); } }