| @@ -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<WxCouponChannelVo> 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(); | |||
| } | |||
| } | |||
| @@ -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(); | |||
| @@ -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, "此用户发此券到达疲劳度限制"), | |||
| @@ -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() { | |||
| @@ -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; | |||
| } | |||
| } | |||
| @@ -31,12 +31,6 @@ public interface WxCouponChannelService { | |||
| */ | |||
| PageInfo<WxCouponChannelVo> listPageCVo(WxCouponChannel record, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * 根据实体查询couponChannelVo列表 | |||
| * @param record | |||
| * @return | |||
| */ | |||
| List<WxCouponChannelVo> findCouponChannelVo(WxCouponChannel record); | |||
| WxCouponCVo findDetailVo(Long id); | |||
| @@ -231,11 +231,6 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||
| return new PageInfo<>(wxCouponChannelMapper.findVoList(record)); | |||
| } | |||
| @Override | |||
| public List<WxCouponChannelVo> findCouponChannelVo(WxCouponChannel record) { | |||
| return wxCouponChannelMapper.findVoList(record); | |||
| } | |||
| @Override | |||
| public WxCouponCVo findDetailVo(Long id) { | |||
| return wxCouponChannelMapper.findVoDetail(id); | |||
| @@ -56,11 +56,6 @@ | |||
| and cc.`create_date` between #{startdate} and #{enddate} | |||
| </if> | |||
| <if test="null !=isCRequest and null != targetAd and 2 == targetAd"> | |||
| and cc.`begin_time` < now() | |||
| and cc.`end_time` > now() | |||
| </if> | |||
| <if test=" null != status "> | |||
| and cc.`status` = #{status} | |||
| </if> | |||