diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxCouponChannelController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxCouponChannelController.java index 084368025..167c1a6da 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxCouponChannelController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxCouponChannelController.java @@ -1,6 +1,10 @@ package com.iformall.controller; +import com.github.pagehelper.PageInfo; +import com.iformall.domain.vo.WxCouponChannelVo; +import com.iformall.enums.EnumCouponChannelActivityStatus; import com.iformall.enums.EnumCouponChannelStatus; +import com.iformall.enums.EnumCouponChannelType; import io.swagger.annotations.Api; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -15,6 +19,8 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import java.util.Date; + @RestController @RequestMapping("/api/wxCouponChannel") @Api(description = "发券渠道相关接口") @@ -34,20 +40,25 @@ public class WxCouponChannelController extends BaseController { wxCouponChannel.setTenantId(getTenantId()); wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); wxCouponChannel.setSortColumns(WxCouponChannel.Field.CreateDate_DESC); - wxCouponChannel.setIsCRequest(0);//标记为C端调用 - return new ResultData(wxCouponChannelService.listPageCVo(wxCouponChannel, pageNum, pageSize)); - } - @ApiOperation("分页列表接口") - @GetMapping("getCouponChannel") - public ResultData getCouponChannel(@ModelAttribute WxCouponChannel wxCouponChannel) { - if (null == wxCouponChannel) wxCouponChannel = new WxCouponChannel(); - wxCouponChannel.setTenantId(getTenantId()); - wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); - wxCouponChannel.setIsCRequest(0);//标记为C端调用 - return new ResultData(wxCouponChannelService.findCouponChannelVo(wxCouponChannel)); - } + PageInfo page = wxCouponChannelService.listPageCVo(wxCouponChannel, pageNum, pageSize); + + if (wxCouponChannel.getTargetAd()!= null && + wxCouponChannel.getTargetAd().equals(EnumCouponChannelType.COUPON_CHANNEL_ID_TIMED.getCode())) { + Date now = new Date(); + page.getList().stream().forEach(cc->{ + if (cc.getBeginTime().getTime() > now.getTime()) { + cc.setActivityStatus(EnumCouponChannelActivityStatus.PREPARED.getCode()); + } else if (cc.getEndTime().getTime() < now.getTime()) { + cc.setActivityStatus(EnumCouponChannelActivityStatus.ENDED.getCode()); + } else { + cc.setActivityStatus(EnumCouponChannelActivityStatus.STARTED.getCode()); + } + }); + } + return new ResultData(); + } } diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxOrderController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxOrderController.java index 45092e3ce..a3998ae99 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxOrderController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxOrderController.java @@ -10,10 +10,12 @@ import com.iformall.domain.po.WxOrder; import com.iformall.domain.vo.WxOrderCouponPressVo; import com.iformall.domain.vo.WxOrderCouponVo; import com.iformall.enums.EnumCouponChannelStatus; +import com.iformall.enums.EnumCouponChannelType; import com.iformall.enums.EnumOrderStatus; import com.iformall.exception.MallinkException; import com.iformall.service.WxCouponChannelService; import com.iformall.service.WxOrderService; +import com.iformall.utils.DateUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -24,6 +26,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.Date; import java.util.Map; @RestController @@ -111,11 +114,24 @@ public class WxOrderController extends BaseController { WxCouponChannel wxCouponChannel = wxCouponChannelService.getById(couponChannelId); if (wxCouponChannel == null) { logger.error("couponChannelId convert error, " + couponChannelIdStr); - return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "找不到发布的频道"); + return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR); } + + if (wxCouponChannel.getTargetAd().equals(EnumCouponChannelType.COUPON_CHANNEL_ID_TIMED.getCode())) { + Date now = new Date(); + if (wxCouponChannel.getBeginTime().getTime() > now.getTime()) { + logger.error("此券活动未开始:" + couponChannelIdStr); + return new ResultData(ErrorCode.COUPON_CHANNEL_IS_NOT_STARTED); + } + if (wxCouponChannel.getEndTime().getTime() < now.getTime()) { + logger.error("此券活动已结束:" + couponChannelIdStr); + return new ResultData(ErrorCode.COUPON_CHANNEL_IS_END); + } + } + if (wxCouponChannel.getStatus() == EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode()) { logger.error("此券已下架:" + couponChannelIdStr); - return new ResultData(ErrorCode.COUPON_CHANNEL_IS_TAKE_OFF.getCode(), "此券已下架"); + return new ResultData(ErrorCode.COUPON_CHANNEL_IS_TAKE_OFF); } if (StringUtils.isBlank(couponIdStr)) { couponId = wxCouponChannel.getCouponId(); diff --git a/mallinkService/src/main/java/com/iformall/common/ErrorCode.java b/mallinkService/src/main/java/com/iformall/common/ErrorCode.java index abf8e62d9..f72c61f46 100644 --- a/mallinkService/src/main/java/com/iformall/common/ErrorCode.java +++ b/mallinkService/src/main/java/com/iformall/common/ErrorCode.java @@ -88,13 +88,13 @@ public enum ErrorCode{ COUPON_TYPE_IS_NOT_ACTIVE(2025, "此券不能用于主动领取"), COUPON_TYPE_IS_NOT_PASSIVE(2026, "此券不能用于定向投放"), COUPON_CHANNEL_IS_EXISTED(2027, "此券已投放过"), - COUPON_CHANNEL_IS_TAKE_OFF(2031, "此券已下架"), COUPON_SEND_IS_EXISTED(2028, "此券已经添加到该渠道"), COUPON_SEND_IS_INVALID(2029, "此发券渠道不存在"), COUPON_SEND_IS_INVALID_TIME(2030, "发放时间不能晚于使用时间"), - - COUPON_MERCHANT_NOT_FOUND(2031, "卡券关联商户未发现"), - + COUPON_CHANNEL_IS_TAKE_OFF(2031, "此券已下架"), + COUPON_MERCHANT_NOT_FOUND(2032, "卡券关联商户未发现"), + COUPON_CHANNEL_IS_NOT_STARTED(2033, "此券活动未开始"), + COUPON_CHANNEL_IS_END(2033, "此券活动已结束"), PUSH_LIMIT_UP_TO_1DAYLIMIT(2040, "此用户一天内发券到达疲劳度限制"), PUSH_LIMIT_UP_TO_COUPONLIMIT(2041, "此用户发此券到达疲劳度限制"), diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCouponChannel.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponChannel.java index c0f41831a..265cfb6ea 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCouponChannel.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponChannel.java @@ -41,7 +41,7 @@ public class WxCouponChannel implements Serializable { } @Transient - private Integer isCRequest; + private Integer activityStatus; @Transient private Date startdate; @@ -100,12 +100,12 @@ public class WxCouponChannel implements Serializable { @io.swagger.annotations.ApiModelProperty(value="子频道ID",name="subTargetId") private Long subTargetId; - public Integer getIsCRequest() { - return isCRequest; + public Integer getActivityStatus() { + return activityStatus; } - public void setIsCRequest(Integer isCRequest) { - this.isCRequest = isCRequest; + public void setActivityStatus(Integer activityStatus) { + this.activityStatus = activityStatus; } public String getTenantId() { diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumCouponChannelActivityStatus.java b/mallinkService/src/main/java/com/iformall/enums/EnumCouponChannelActivityStatus.java new file mode 100644 index 000000000..5a5862f92 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/enums/EnumCouponChannelActivityStatus.java @@ -0,0 +1,38 @@ +package com.iformall.enums; + +/** + * Created by Stormeye on 2018/08/09. + */ +public enum EnumCouponChannelActivityStatus { + + + PREPARED(0, "预告中"), + STARTED(1, "已开启"), + ENDED(1, "已结束"), + ; + + public static EnumCouponChannelActivityStatus getEnum(Integer code) { + for (EnumCouponChannelActivityStatus value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumCouponChannelActivityStatus(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java index a623b260c..460a44e22 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java @@ -31,12 +31,6 @@ public interface WxCouponChannelService { */ PageInfo listPageCVo(WxCouponChannel record, Integer pageIndex, Integer pageSize); - /** - * 根据实体查询couponChannelVo列表 - * @param record - * @return - */ - List findCouponChannelVo(WxCouponChannel record); WxCouponCVo findDetailVo(Long id); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java index 1552f8e3b..d1511b4b2 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java @@ -231,11 +231,6 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { return new PageInfo<>(wxCouponChannelMapper.findVoList(record)); } - @Override - public List findCouponChannelVo(WxCouponChannel record) { - return wxCouponChannelMapper.findVoList(record); - } - @Override public WxCouponCVo findDetailVo(Long id) { return wxCouponChannelMapper.findVoDetail(id); diff --git a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml index 0eba24596..901bddede 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml @@ -56,11 +56,6 @@ and cc.`create_date` between #{startdate} and #{enddate} - - and cc.`begin_time` < now() - and cc.`end_time` > now() - - and cc.`status` = #{status}