Browse Source

[卡券][修改]:限时抢购按小时下架,限时抢购每到发送时间不传C端

release_toaliyun_real
hupeng 7 years ago
parent
commit
faceb3be7d
9 changed files with 126 additions and 21 deletions
  1. +1
    -1
      mallinkAdmin/src/main/java/com/iformall/controller/WxCouponChannelController.java
  2. +11
    -3
      mallinkAdmin/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java
  3. +7
    -1
      mallinkCApi/src/main/java/com/iformall/controller/WxCouponChannelController.java
  4. +3
    -1
      mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java
  5. +2
    -1
      mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java
  6. +1
    -1
      mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java
  7. +5
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java
  8. +92
    -11
      mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml
  9. +4
    -0
      mallinkService/src/main/resources/mapper/WxCouponMapper.xml

+ 1
- 1
mallinkAdmin/src/main/java/com/iformall/controller/WxCouponChannelController.java View File

@@ -51,7 +51,7 @@ public class WxCouponChannelController extends BaseController {
}
wxCouponChannel.setTenantId(getUser().getTenantId());
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);
}



+ 11
- 3
mallinkAdmin/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java View File

@@ -14,17 +14,19 @@ public class CouponExpiringSchedule {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private WxCouponMapper wxCouponMapper;

@Autowired
private WxCouponChannelMapper wxCouponChannelMapper;



@Scheduled(cron = "0 5 0 * * ?") // 每天凌晨00:05
//@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
public void couponExpiringSchedule() {



wxCouponMapper.offExpiriedCouponByValidDate();
}

@Scheduled(cron = "0 5 0 * * ?") // 每天凌晨00:05
@@ -35,4 +37,10 @@ public class CouponExpiringSchedule {
wxCouponChannelMapper.offExpiriedCouponChannelByValidDate();
wxCouponChannelMapper.offExpiriedCouponChannelByCouponStatus();
}

@Scheduled(cron = "0 0 0/1 * * ?") // 每小时(整点)执行//限时抢购
//@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次
public void couponChannel2ExpiringSchedule() {
wxCouponChannelMapper.offExpiriedCouponChannel2ByEndTime();
}
}

+ 7
- 1
mallinkCApi/src/main/java/com/iformall/controller/WxCouponChannelController.java View File

@@ -2,6 +2,7 @@ package com.iformall.controller;

import com.iformall.domain.vo.WxCouponChannelVo;
import com.iformall.enums.EnumCouponChannelStatus;
import com.iformall.enums.EnumCouponChannelType;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -38,7 +39,12 @@ public class WxCouponChannelController extends BaseController {
wxCouponChannel.setTenantId(getTenantId());
wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode());
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);
}



+ 3
- 1
mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java View File

@@ -10,6 +10,7 @@ public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, Str
List<WxCouponChannel> findList(WxCouponChannel wxCouponChannel);

List<WxCouponChannelVo> findVoList(WxCouponChannel wxCouponChannel);
List<WxCouponChannelVo> findVoListForCouponChannel2(WxCouponChannel wxCouponChannel);

void updateStatusByCouponId(WxCouponChannel wxCouponChannel);

@@ -18,6 +19,7 @@ public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, Str
void offExpiriedCouponChannelByValidDate();

void offExpiriedCouponChannelByCouponStatus();

void offExpiriedCouponChannel2ByEndTime();
}

+ 2
- 1
mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java View File

@@ -14,5 +14,6 @@ public interface WxCouponMapper extends CommonMapper<WxCoupon, Long> {
WxCouponCVo selectDetailForCUser(WxCouponChannel wxCouponChannel);

void reduceInventory(@Param("id")Long id,@Param("number")Integer number);

void offExpiriedCouponByValidDate();
}

+ 1
- 1
mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java View File

@@ -28,7 +28,7 @@ public interface WxCouponChannelService {
* @param pageSize
* @return
*/
PageInfo<WxCouponChannelVo> listPageCAPI(WxCouponChannel record, Integer pageIndex, Integer pageSize);
PageInfo<WxCouponChannelVo> listPageCAPI(WxCouponChannel record, Integer pageIndex, Integer pageSize, boolean couponChannel2);

/**
* 根据实体查询Vo分页列表


+ 5
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java View File

@@ -192,10 +192,13 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
* @return
*/
@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<>();
PageHelper.startPage(pageIndex, pageSize);
wxCouponChannelVoList = wxCouponChannelMapper.findVoList(record);
if (couponChannel2)
wxCouponChannelVoList = wxCouponChannelMapper.findVoListForCouponChannel2(record);
else
wxCouponChannelVoList = wxCouponChannelMapper.findVoList(record);
if(wxCouponChannelVoList.isEmpty()){
return new PageInfo<>(wxCouponChannelVoList);
}


+ 92
- 11
mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml View File

@@ -41,7 +41,6 @@
and `coupon_id` = #{couponId}
</if>


<if test=" null != type ">
and `type` = #{type}
</if>
@@ -107,14 +106,6 @@
<include refid="dynamicWhereConditions" />
</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 wx_coupon_channel set status=#{status} where tenant_id=#{tenantId} and coupon_id=#{couponId}
</update>
@@ -135,16 +126,101 @@
</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` &lt; 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 wx_coupon_channel SET status = 1, update_date = now()
where status = 0 and end_time &lt; now()

</update>

<update id="offExpiriedCouponChannelByValidDate">
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 &lt; now()
where cc.status = 0 and cc.coupon_id = c.id and c.valid_type = 1 and c.valid_end_date &lt; now()
</update>

<update id="offExpiriedCouponChannelByCouponStatus">
@@ -152,4 +228,9 @@
where cc.status = 0 and cc.coupon_id = c.id and c.status = 1
</update>

<update id="offExpiriedCouponChannel2ByEndTime">
update wx_coupon_channel SET status = 1, update_date = now()
where status = 0 and target_ad = 2 and end_time &lt; now()
</update>

</mapper>

+ 4
- 0
mallinkService/src/main/resources/mapper/WxCouponMapper.xml View File

@@ -247,5 +247,9 @@
update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and remain_inventory>= #{number}
</update>

<update id="offExpiriedCouponByValidDate">
update wx_coupon SET status = 1, update_date = now()
where status = 0 and valid_type = 1 and valid_end_date &lt; now()
</update>

</mapper>

Loading…
Cancel
Save