| @@ -51,7 +51,7 @@ public class WxCouponChannelController extends BaseController { | |||||
| } | } | ||||
| wxCouponChannel.setTenantId(getUser().getTenantId()); | wxCouponChannel.setTenantId(getUser().getTenantId()); | ||||
| wxCouponChannel.setSortColumns(WxCouponChannel.Field.Id_DESC); | wxCouponChannel.setSortColumns(WxCouponChannel.Field.Id_DESC); | ||||
| final PageInfo<WxCouponChannelVo> page = wxCouponChannelService.listPageCAPI(wxCouponChannel, pageNum, pageSize); | |||||
| final PageInfo<WxCouponChannelVo> page = wxCouponChannelService.listPageCAPI(wxCouponChannel, pageNum, pageSize ,false); | |||||
| return new ResultData(page); | return new ResultData(page); | ||||
| } | } | ||||
| @@ -14,17 +14,19 @@ public class CouponExpiringSchedule { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | |||||
| private WxCouponMapper wxCouponMapper; | |||||
| @Autowired | @Autowired | ||||
| private WxCouponChannelMapper wxCouponChannelMapper; | private WxCouponChannelMapper wxCouponChannelMapper; | ||||
| @Scheduled(cron = "0 5 0 * * ?") // 每天凌晨00:05 | @Scheduled(cron = "0 5 0 * * ?") // 每天凌晨00:05 | ||||
| //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | ||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| public void couponExpiringSchedule() { | public void couponExpiringSchedule() { | ||||
| wxCouponMapper.offExpiriedCouponByValidDate(); | |||||
| } | } | ||||
| @Scheduled(cron = "0 5 0 * * ?") // 每天凌晨00:05 | @Scheduled(cron = "0 5 0 * * ?") // 每天凌晨00:05 | ||||
| @@ -35,4 +37,10 @@ public class CouponExpiringSchedule { | |||||
| wxCouponChannelMapper.offExpiriedCouponChannelByValidDate(); | wxCouponChannelMapper.offExpiriedCouponChannelByValidDate(); | ||||
| wxCouponChannelMapper.offExpiriedCouponChannelByCouponStatus(); | wxCouponChannelMapper.offExpiriedCouponChannelByCouponStatus(); | ||||
| } | } | ||||
| @Scheduled(cron = "0 0 0/1 * * ?") // 每小时(整点)执行//限时抢购 | |||||
| //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | |||||
| public void couponChannel2ExpiringSchedule() { | |||||
| wxCouponChannelMapper.offExpiriedCouponChannel2ByEndTime(); | |||||
| } | |||||
| } | } | ||||
| @@ -2,6 +2,7 @@ package com.iformall.controller; | |||||
| import com.iformall.domain.vo.WxCouponChannelVo; | import com.iformall.domain.vo.WxCouponChannelVo; | ||||
| import com.iformall.enums.EnumCouponChannelStatus; | import com.iformall.enums.EnumCouponChannelStatus; | ||||
| import com.iformall.enums.EnumCouponChannelType; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| @@ -38,7 +39,12 @@ public class WxCouponChannelController extends BaseController { | |||||
| wxCouponChannel.setTenantId(getTenantId()); | wxCouponChannel.setTenantId(getTenantId()); | ||||
| wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); | wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); | ||||
| wxCouponChannel.setSortColumns(WxCouponChannel.Field.CreateDate_DESC); | wxCouponChannel.setSortColumns(WxCouponChannel.Field.CreateDate_DESC); | ||||
| final PageInfo<WxCouponChannelVo> page = wxCouponChannelService.listPageCAPI(wxCouponChannel, pageNum, pageSize); | |||||
| PageInfo<WxCouponChannelVo> page; | |||||
| if (wxCouponChannel.getTargetAd() != null | |||||
| && wxCouponChannel.getTargetAd().equals(EnumCouponChannelType.COUPON_CHANNEL_ID_TIMED.getCode())) | |||||
| page = wxCouponChannelService.listPageCAPI(wxCouponChannel, pageNum, pageSize,true); | |||||
| else | |||||
| page = wxCouponChannelService.listPageCAPI(wxCouponChannel, pageNum, pageSize,false); | |||||
| return new ResultData(page); | return new ResultData(page); | ||||
| } | } | ||||
| @@ -10,6 +10,7 @@ public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, Str | |||||
| List<WxCouponChannel> findList(WxCouponChannel wxCouponChannel); | List<WxCouponChannel> findList(WxCouponChannel wxCouponChannel); | ||||
| List<WxCouponChannelVo> findVoList(WxCouponChannel wxCouponChannel); | List<WxCouponChannelVo> findVoList(WxCouponChannel wxCouponChannel); | ||||
| List<WxCouponChannelVo> findVoListForCouponChannel2(WxCouponChannel wxCouponChannel); | |||||
| void updateStatusByCouponId(WxCouponChannel wxCouponChannel); | void updateStatusByCouponId(WxCouponChannel wxCouponChannel); | ||||
| @@ -18,6 +19,7 @@ public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, Str | |||||
| void offExpiriedCouponChannelByValidDate(); | void offExpiriedCouponChannelByValidDate(); | ||||
| void offExpiriedCouponChannelByCouponStatus(); | void offExpiriedCouponChannelByCouponStatus(); | ||||
| void offExpiriedCouponChannel2ByEndTime(); | |||||
| } | } | ||||
| @@ -14,5 +14,6 @@ public interface WxCouponMapper extends CommonMapper<WxCoupon, Long> { | |||||
| WxCouponCVo selectDetailForCUser(WxCouponChannel wxCouponChannel); | WxCouponCVo selectDetailForCUser(WxCouponChannel wxCouponChannel); | ||||
| void reduceInventory(@Param("id")Long id,@Param("number")Integer number); | void reduceInventory(@Param("id")Long id,@Param("number")Integer number); | ||||
| void offExpiriedCouponByValidDate(); | |||||
| } | } | ||||
| @@ -28,7 +28,7 @@ public interface WxCouponChannelService { | |||||
| * @param pageSize | * @param pageSize | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| PageInfo<WxCouponChannelVo> listPageCAPI(WxCouponChannel record, Integer pageIndex, Integer pageSize); | |||||
| PageInfo<WxCouponChannelVo> listPageCAPI(WxCouponChannel record, Integer pageIndex, Integer pageSize, boolean couponChannel2); | |||||
| /** | /** | ||||
| * 根据实体查询Vo分页列表 | * 根据实体查询Vo分页列表 | ||||
| @@ -192,10 +192,13 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| * @return | * @return | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public PageInfo<WxCouponChannelVo> listPageCAPI(WxCouponChannel record, Integer pageIndex, Integer pageSize) { | |||||
| public PageInfo<WxCouponChannelVo> listPageCAPI(WxCouponChannel record, Integer pageIndex, Integer pageSize, boolean couponChannel2) { | |||||
| List<WxCouponChannelVo> wxCouponChannelVoList = new ArrayList<>(); | List<WxCouponChannelVo> wxCouponChannelVoList = new ArrayList<>(); | ||||
| PageHelper.startPage(pageIndex, pageSize); | PageHelper.startPage(pageIndex, pageSize); | ||||
| wxCouponChannelVoList = wxCouponChannelMapper.findVoList(record); | |||||
| if (couponChannel2) | |||||
| wxCouponChannelVoList = wxCouponChannelMapper.findVoListForCouponChannel2(record); | |||||
| else | |||||
| wxCouponChannelVoList = wxCouponChannelMapper.findVoList(record); | |||||
| if(wxCouponChannelVoList.isEmpty()){ | if(wxCouponChannelVoList.isEmpty()){ | ||||
| return new PageInfo<>(wxCouponChannelVoList); | return new PageInfo<>(wxCouponChannelVoList); | ||||
| } | } | ||||
| @@ -41,7 +41,6 @@ | |||||
| and `coupon_id` = #{couponId} | and `coupon_id` = #{couponId} | ||||
| </if> | </if> | ||||
| <if test=" null != type "> | <if test=" null != type "> | ||||
| and `type` = #{type} | and `type` = #{type} | ||||
| </if> | </if> | ||||
| @@ -107,14 +106,6 @@ | |||||
| <include refid="dynamicWhereConditions" /> | <include refid="dynamicWhereConditions" /> | ||||
| </select> | </select> | ||||
| <select id="findVoList" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="CouponChannelVoMap"> | |||||
| select <include refid="allColumns" /> from wx_coupon_channel | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <update id="updateStatusByCouponId" parameterType="com.iformall.domain.po.WxCouponChannel"> | <update id="updateStatusByCouponId" parameterType="com.iformall.domain.po.WxCouponChannel"> | ||||
| update wx_coupon_channel set status=#{status} where tenant_id=#{tenantId} and coupon_id=#{couponId} | update wx_coupon_channel set status=#{status} where tenant_id=#{tenantId} and coupon_id=#{couponId} | ||||
| </update> | </update> | ||||
| @@ -135,16 +126,101 @@ | |||||
| </resultMap> | </resultMap> | ||||
| <select id="findVoList" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="CouponChannelVoMap"> | |||||
| select <include refid="allColumns" /> from wx_coupon_channel | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <select id="findVoListForCouponChannel2" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="CouponChannelVoMap"> | |||||
| select <include refid="allColumns" /> from wx_coupon_channel | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != merchantId "> | |||||
| and `merchant_id` = #{merchantId} | |||||
| </if> | |||||
| <if test=" null != couponId "> | |||||
| and `coupon_id` = #{couponId} | |||||
| </if> | |||||
| <if test=" null != type "> | |||||
| and `type` = #{type} | |||||
| </if> | |||||
| <if test=" null != title "> | |||||
| and `title` like concat('%', #{title},'%') | |||||
| </if> | |||||
| <if test=" null != targetAd "> | |||||
| and `target_ad` = #{targetAd} | |||||
| </if> | |||||
| <if test=" null != business and '0' == business"> | |||||
| and JSON_CONTAINS(`business`->'$',JSON_ARRAY('0')) | |||||
| </if> | |||||
| <if test=" null != business and '0' != business"> | |||||
| and (JSON_CONTAINS(`business`->'$',JSON_ARRAY('0')) or (JSON_CONTAINS(`business`->'$',JSON_ARRAY(#{business})))) | |||||
| </if> | |||||
| <if test=" null != beginTime "> | |||||
| and `begin_time` = #{beginTime} | |||||
| </if> | |||||
| <if test=" null != targetAd and 2 == targetAd"> | |||||
| and `begin_time` < now() | |||||
| </if> | |||||
| <if test=" null != endTime "> | |||||
| and `end_time` = #{endTime} | |||||
| </if> | |||||
| <if test=" null != status "> | |||||
| and `status` = #{status} | |||||
| </if> | |||||
| <if test=" null != createDate "> | |||||
| and `create_date` = #{createDate} | |||||
| </if> | |||||
| <if test=" null != updateDate "> | |||||
| and `update_date` = #{updateDate} | |||||
| </if> | |||||
| <if test=" null != subTargetId "> | |||||
| and `sub_target_id` = #{subTargetId} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != couponIds "> | |||||
| and coupon_id in | |||||
| <foreach collection="couponIds" index="index" item="couponIdsItem" open="(" separator="," close=")"> | |||||
| #{couponIdsItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </select> | |||||
| <update id="offExpiriedCouponChannelByEndTime"> | <update id="offExpiriedCouponChannelByEndTime"> | ||||
| update wx_coupon_channel SET status = 1, update_date = now() | update wx_coupon_channel SET status = 1, update_date = now() | ||||
| where status = 0 and end_time < now() | where status = 0 and end_time < now() | ||||
| </update> | </update> | ||||
| <update id="offExpiriedCouponChannelByValidDate"> | <update id="offExpiriedCouponChannelByValidDate"> | ||||
| update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now() | update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now() | ||||
| where cc.status = 0 and cc.coupon_id = c.id and c.valid_type = 1 and valid_end_date < now() | |||||
| where cc.status = 0 and cc.coupon_id = c.id and c.valid_type = 1 and c.valid_end_date < now() | |||||
| </update> | </update> | ||||
| <update id="offExpiriedCouponChannelByCouponStatus"> | <update id="offExpiriedCouponChannelByCouponStatus"> | ||||
| @@ -152,4 +228,9 @@ | |||||
| where cc.status = 0 and cc.coupon_id = c.id and c.status = 1 | where cc.status = 0 and cc.coupon_id = c.id and c.status = 1 | ||||
| </update> | </update> | ||||
| <update id="offExpiriedCouponChannel2ByEndTime"> | |||||
| update wx_coupon_channel SET status = 1, update_date = now() | |||||
| where status = 0 and target_ad = 2 and end_time < now() | |||||
| </update> | |||||
| </mapper> | </mapper> | ||||
| @@ -247,5 +247,9 @@ | |||||
| update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and remain_inventory>= #{number} | update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and remain_inventory>= #{number} | ||||
| </update> | </update> | ||||
| <update id="offExpiriedCouponByValidDate"> | |||||
| update wx_coupon SET status = 1, update_date = now() | |||||
| where status = 0 and valid_type = 1 and valid_end_date < now() | |||||
| </update> | |||||
| </mapper> | </mapper> | ||||