| @@ -37,20 +37,15 @@ public class WxCouponChannelController extends BaseController | |||
| @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) | |||
| public ResultData list(@ModelAttribute WxCouponChannel wxCouponChannel,Integer pageNum, Integer pageSize) { | |||
| if (null == wxCouponChannel) wxCouponChannel = new WxCouponChannel(); | |||
| if(wxCouponChannel.getStatus()==-1){ | |||
| wxCouponChannel.setStatus(null); | |||
| } | |||
| wxCouponChannel.setTenantId(getUser().getTenantId()); | |||
| final PageInfo<WxCouponChannel> page = wxCouponChannelService.listAsPage(wxCouponChannel, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxCouponChannel wxCouponChannel) { | |||
| //Assert.notNull(wxCouponChannel.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxCouponChannel.setTenantId(getUser().getTenantId()); | |||
| wxCouponChannelService.saveOrUpdate(wxCouponChannel); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @@ -77,11 +72,11 @@ public class WxCouponChannelController extends BaseController | |||
| @ApiOperation("批量新增") | |||
| @PostMapping("/addbatch") | |||
| public ResultData findById(@RequestBody WxCouponChannelDto wxCouponChannelDto) { | |||
| public ResultData addbatch(@RequestBody WxCouponChannelDto wxCouponChannelDto) { | |||
| String[] ids = wxCouponChannelDto.getCouponIds().split(","); | |||
| String[] channelId = wxCouponChannelDto.getChannelId().split(","); | |||
| MallUserInfo user = getUser(); | |||
| wxCouponChannelService.addBatch(ids,channelId,user.getTenantId()); | |||
| wxCouponChannelService.addBatch(ids,channelId,user.getTenantId(),wxCouponChannelDto.getBeginTime(),wxCouponChannelDto.getEndTime()); | |||
| return new ResultData(); | |||
| } | |||
| @@ -1,5 +1,7 @@ | |||
| package com.simple.controller; | |||
| import com.simple.domain.po.WxCouponChannel; | |||
| import com.simple.service.WxCouponChannelService; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.apache.log4j.Logger; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -25,6 +27,12 @@ import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import java.util.ArrayList; | |||
| import java.util.Collections; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.stream.Collectors; | |||
| @RestController | |||
| @RequestMapping("wxCoupon") | |||
| @Api(description="优惠券接口") | |||
| @@ -35,6 +43,8 @@ public class WxCouponController extends BaseController | |||
| @Autowired | |||
| private WxMerchantService wxMerchantService; | |||
| @Autowired | |||
| private WxCouponChannelService wxCouponChannelService; | |||
| private Logger logger = Logger.getLogger(WxCouponController.class); | |||
| @@ -45,12 +55,31 @@ public class WxCouponController extends BaseController | |||
| @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) | |||
| public ResultData list(@ModelAttribute WxCoupon wxCoupon,Integer pageNum, Integer pageSize) { | |||
| if (null == wxCoupon) wxCoupon = new WxCoupon(); | |||
| wxCoupon.setTenantId(getTenantId()); | |||
| PageInfo<WxCoupon> page = null; | |||
| if (wxCoupon.getStatus() != null && wxCoupon.getStatus() == -1) { | |||
| page = wxCouponService.findEnableList(wxCoupon, pageNum, pageSize); | |||
| }else { | |||
| page = wxCouponService.listAsPage(wxCoupon, pageNum, pageSize); | |||
| } | |||
| List<WxCoupon> wxCouponList = page.getList(); | |||
| List<Long> ids = wxCouponList.stream().map(p->p.getId()).collect(Collectors.toList()); | |||
| WxCouponChannel wxCouponChannel = new WxCouponChannel(); | |||
| wxCouponChannel.setTenantId(getTenantId()); | |||
| wxCouponChannel.setIds(ids); | |||
| //上架状态 | |||
| List<WxCouponChannel> list = wxCouponChannelService.listAsPage(wxCouponChannel,1,5).getList(); | |||
| if(!list.isEmpty()){ | |||
| Map<Long, List<WxCouponChannel>> groupBy = list.stream().collect(Collectors.groupingBy(WxCouponChannel::getCouponId)); | |||
| for (WxCoupon temp:wxCouponList) { | |||
| List<String> channels=new ArrayList<>(); | |||
| if(groupBy.get(temp.getId())!=null){ | |||
| String sss = JSON.toJSONString(groupBy.get(temp.getId())); | |||
| temp.setChannels(sss); | |||
| } | |||
| } | |||
| } | |||
| return new ResultData(page); | |||
| } | |||
| @@ -51,16 +51,12 @@ public class WxCouponSendController extends BaseController | |||
| return new ResultData(Result.ERROR,"已经添加过该券"); | |||
| } | |||
| WxCoupon wxCoupon = wxCouponService.getById(wxCouponSend.getCouponId()); | |||
| if(wxCoupon.getSendEndDate().before(new Date())){ | |||
| return new ResultData(Result.ERROR,"发放日期异常"); | |||
| } | |||
| wxCouponSend.setMerchantId(wxCoupon.getMerchantId()); | |||
| wxCouponSend.setType(wxCoupon.getType()); | |||
| wxCouponSend.setTenantId(wxCoupon.getTenantId()); | |||
| wxCouponSend.setTitle(wxCoupon.getTitle()); | |||
| wxCouponSend.setSendStartTime(wxCoupon.getSendStartDate()); | |||
| wxCouponSend.setSendEndTime(wxCoupon.getSendEndDate()); | |||
| //Assert.notNull(wxCouponSend.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxCouponSendService.saveOrUpdate(wxCouponSend); | |||
| @@ -1,6 +1,7 @@ | |||
| package com.simple.domain.dto; | |||
| import java.io.Serializable; | |||
| import java.util.Date; | |||
| public class WxCouponChannelDto implements Serializable { | |||
| @@ -8,8 +9,16 @@ public class WxCouponChannelDto implements Serializable { | |||
| private Long couponId; | |||
| private String couponIds; | |||
| private String channelId; | |||
| private Date beginTime; | |||
| private Date endTime; | |||
| public Date getEndTime() { | |||
| return endTime; | |||
| } | |||
| public void setEndTime(Date endTime) { | |||
| this.endTime = endTime; | |||
| } | |||
| public String getChannelId() { | |||
| return channelId; | |||
| @@ -34,4 +43,11 @@ public class WxCouponChannelDto implements Serializable { | |||
| public void setCouponIds(String couponIds) { | |||
| this.couponIds = couponIds; | |||
| } | |||
| public Date getBeginTime() { | |||
| return beginTime; | |||
| } | |||
| public void setBeginTime(Date beginTime) { | |||
| this.beginTime = beginTime; | |||
| } | |||
| } | |||
| @@ -20,6 +20,9 @@ public class WxCoupon implements Serializable { | |||
| protected List<Long> ids; | |||
| @Transient | |||
| protected String sortColumns; | |||
| @Transient | |||
| protected String channels; | |||
| public Long getId() { | |||
| return id; | |||
| @@ -84,12 +87,6 @@ public class WxCoupon implements Serializable { | |||
| /*1.主动领取2.定向投放**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="1.主动领取2.定向投放",name="sendType") | |||
| private Integer sendType; | |||
| /*发放开始时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="发放开始时间",name="sendStartDate") | |||
| private Date sendStartDate; | |||
| /*发放结束时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="发放结束时间",name="sendEndDate") | |||
| private Date sendEndDate; | |||
| /*有效时间类型1.时间范围(valid_start_date,valid_end_date). 2领取后几日有效(valid_days)**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="有效时间类型1.时间范围(valid_start_date,valid_end_date). 2领取后几日有效(valid_days)",name="validType") | |||
| private Integer validType; | |||
| @@ -195,18 +192,6 @@ public class WxCoupon implements Serializable { | |||
| public void setSendType(Integer _sendType) { | |||
| sendType = _sendType; | |||
| } | |||
| public Date getSendStartDate() { | |||
| return sendStartDate; | |||
| } | |||
| public void setSendStartDate(Date _sendStartDate) { | |||
| sendStartDate = _sendStartDate; | |||
| } | |||
| public Date getSendEndDate() { | |||
| return sendEndDate; | |||
| } | |||
| public void setSendEndDate(Date _sendEndDate) { | |||
| sendEndDate = _sendEndDate; | |||
| } | |||
| public Integer getValidType() { | |||
| return validType; | |||
| } | |||
| @@ -321,6 +306,13 @@ public class WxCoupon implements Serializable { | |||
| this.priceStr = priceStr; | |||
| } | |||
| public String getChannels() { | |||
| return channels; | |||
| } | |||
| public void setChannels(String channels) { | |||
| this.channels = channels; | |||
| } | |||
| public static enum Field | |||
| @@ -11,16 +11,15 @@ import java.io.Serializable; | |||
| @Table(name = "wx_coupon_channel") | |||
| public class WxCouponChannel implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| @Id | |||
| protected Long id; | |||
| @Transient | |||
| protected List<String> ids; | |||
| @Transient | |||
| protected String sortColumns; | |||
| protected Long id; | |||
| @Transient | |||
| protected List<Long> ids; | |||
| @Transient | |||
| protected String sortColumns; | |||
| public Long getId() { | |||
| return id; | |||
| } | |||
| @@ -28,30 +27,20 @@ public class WxCouponChannel implements Serializable { | |||
| public void setId(Long id) { | |||
| this.id = id; | |||
| } | |||
| public String getSortColumns() { | |||
| return sortColumns; | |||
| } | |||
| public List<String> getIds() { | |||
| public List<Long> getIds() { | |||
| return ids; | |||
| } | |||
| public void setIds(List<String> ids) { | |||
| public void setIds(List<Long> ids) { | |||
| this.ids = ids; | |||
| } | |||
| /***/ | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="business") | |||
| private String business; | |||
| public String getBusiness() { | |||
| return business; | |||
| } | |||
| public void setBusiness(String business) { | |||
| this.business = business; | |||
| } | |||
| /*租户ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||
| @@ -62,9 +51,7 @@ public class WxCouponChannel implements Serializable { | |||
| /*卡券id**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="卡券id",name="couponId") | |||
| private Long couponId; | |||
| /*券状态,判断是否在前端展示**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="券状态,判断是否在前端展示",name="couponStatus") | |||
| private Integer couponStatus; | |||
| /*券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券)**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券)",name="type") | |||
| private Integer type; | |||
| @@ -74,6 +61,18 @@ public class WxCouponChannel implements Serializable { | |||
| /*投放频道位置(1.列表, 2.限时抢购)**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="投放频道位置(1.列表, 2.限时抢购)",name="targetAd") | |||
| private Integer targetAd; | |||
| /***/ | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="business") | |||
| private String business; | |||
| /*开始时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="开始时间",name="beginTime") | |||
| private Date beginTime; | |||
| /*结束时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="结束时间",name="endTime") | |||
| private Date endTime; | |||
| /*0:上架 1:下架**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="0:上架 1:下架",name="status") | |||
| private Integer status; | |||
| /*创建时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| @@ -98,12 +97,6 @@ public class WxCouponChannel implements Serializable { | |||
| public void setCouponId(Long _couponId) { | |||
| couponId = _couponId; | |||
| } | |||
| public Integer getCouponStatus() { | |||
| return couponStatus; | |||
| } | |||
| public void setCouponStatus(Integer _couponStatus) { | |||
| couponStatus = _couponStatus; | |||
| } | |||
| public Integer getType() { | |||
| return type; | |||
| } | |||
| @@ -122,6 +115,30 @@ public class WxCouponChannel implements Serializable { | |||
| public void setTargetAd(Integer _targetAd) { | |||
| targetAd = _targetAd; | |||
| } | |||
| public String getBusiness() { | |||
| return business; | |||
| } | |||
| public void setBusiness(String _business) { | |||
| business = _business; | |||
| } | |||
| public Date getBeginTime() { | |||
| return beginTime; | |||
| } | |||
| public void setBeginTime(Date _beginTime) { | |||
| beginTime = _beginTime; | |||
| } | |||
| public Date getEndTime() { | |||
| return endTime; | |||
| } | |||
| public void setEndTime(Date _endTime) { | |||
| endTime = _endTime; | |||
| } | |||
| public Integer getStatus() { | |||
| return status; | |||
| } | |||
| public void setStatus(Integer _status) { | |||
| status = _status; | |||
| } | |||
| public Date getCreateDate() { | |||
| return createDate; | |||
| } | |||
| @@ -136,19 +153,24 @@ public class WxCouponChannel implements Serializable { | |||
| } | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||
| ,MerchantId_ASC("`merchantId` ASC"),MerchantId_DESC("`merchantId` DESC") | |||
| ,CouponId_ASC("`couponId` ASC"),CouponId_DESC("`couponId` DESC") | |||
| ,CouponStatus_ASC("`couponStatus` ASC"),CouponStatus_DESC("`couponStatus` DESC") | |||
| ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") | |||
| ,Title_ASC("`title` ASC"),Title_DESC("`title` DESC") | |||
| ,TargetAd_ASC("`targetAd` ASC"),TargetAd_DESC("`targetAd` DESC") | |||
| ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") | |||
| ,UpdateDate_ASC("`updateDate` ASC"),UpdateDate_DESC("`updateDate` DESC") | |||
| ; | |||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||
| ,MerchantId_ASC("`merchantId` ASC"),MerchantId_DESC("`merchantId` DESC") | |||
| ,CouponId_ASC("`couponId` ASC"),CouponId_DESC("`couponId` DESC") | |||
| ,CouponStatus_ASC("`couponStatus` ASC"),CouponStatus_DESC("`couponStatus` DESC") | |||
| ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") | |||
| ,Title_ASC("`title` ASC"),Title_DESC("`title` DESC") | |||
| ,TargetAd_ASC("`targetAd` ASC"),TargetAd_DESC("`targetAd` DESC") | |||
| ,Business_ASC("`business` ASC"),Business_DESC("`business` DESC") | |||
| ,BeginTime_ASC("`beginTime` ASC"),BeginTime_DESC("`beginTime` DESC") | |||
| ,EndTime_ASC("`endTime` ASC"),EndTime_DESC("`endTime` DESC") | |||
| ,Status_ASC("`status` ASC"),Status_DESC("`status` DESC") | |||
| ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") | |||
| ,UpdateDate_ASC("`updateDate` ASC"),UpdateDate_DESC("`updateDate` DESC") | |||
| ; | |||
| private String value; | |||
| Field(String value){ | |||
| this.value = value; | |||
| @@ -164,8 +186,8 @@ public class WxCouponChannel implements Serializable { | |||
| return this.getValue(); | |||
| } | |||
| } | |||
| public void setSortColumns(Field... fields) | |||
| public void setSortColumns(WxCouponChannel.Field... fields) | |||
| { | |||
| if (fields == null || fields.length == 0) { | |||
| return; | |||
| @@ -180,9 +202,9 @@ public class WxCouponChannel implements Serializable { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| } | |||
| public void setSortColumns(String sortColumns) | |||
| { | |||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||
| @@ -190,7 +212,7 @@ public class WxCouponChannel implements Serializable { | |||
| } | |||
| if (sortColumns.contains(",")) { | |||
| String[] cols = sortColumns.split(","); | |||
| List<Field> fList = new ArrayList(); | |||
| java.util.List<Field> fList = new java.util.ArrayList(); | |||
| for (int k = 0; k < cols.length; k++) { | |||
| fList.add(Field.valueOf(cols[k])); | |||
| } | |||
| @@ -178,8 +178,6 @@ public class WxCouponChannelVo extends WxCouponChannel implements Serializable { | |||
| this.remainInventory=wxCoupon.getRemainInventory(); | |||
| this.price=wxCoupon.getPrice(); | |||
| this.salePrice=wxCoupon.getSalePrice(); | |||
| this.sendStartDate=wxCoupon.getSendStartDate(); | |||
| this.sendEndDate=wxCoupon.getSendEndDate(); | |||
| this.sendType=wxCoupon.getSendType(); | |||
| this.useLimitQuantity=wxCoupon.getUseLimitQuantity(); | |||
| this.usePrice=wxCoupon.getUsePrice(); | |||
| @@ -4,6 +4,8 @@ import com.github.pagehelper.PageInfo; | |||
| import com.simple.domain.po.WxCouponChannel; | |||
| import com.simple.domain.vo.WxCouponChannelVo; | |||
| import java.util.Date; | |||
| public interface WxCouponChannelService { | |||
| /** | |||
| @@ -40,7 +42,7 @@ public interface WxCouponChannelService { | |||
| */ | |||
| void deleteById(Long id); | |||
| void addBatch(String[] ids,String[] channelId,String tanantId); | |||
| void addBatch(String[] ids, String[] channelId, String tanantId, Date beginTime,Date endTime); | |||
| @@ -37,6 +37,14 @@ public interface WxCouponSendService { | |||
| * @param id | |||
| */ | |||
| void deleteById(Long id); | |||
| /** | |||
| *停车或核销给用户注入卡券 | |||
| * @param tenantId | |||
| * @param cUserId | |||
| * @param type 2:停车发券 3:核销发券 | |||
| */ | |||
| void sendCouponToUser(String tenantId,Long cUserId,int type); | |||
| @@ -61,13 +61,13 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||
| @Override | |||
| @Transactional | |||
| public void addBatch(String[] ids,String[] channelId,String tanantId) { | |||
| public void addBatch(String[] ids,String[] channelId,String tanantId,Date beginTime,Date endTime) { | |||
| for (String targetIdstr:channelId) { | |||
| Integer targetId = Integer.parseInt(targetIdstr); | |||
| for (String couponidstr:ids) { | |||
| Long couponid = Long.parseLong(couponidstr); | |||
| addCuponChannel(couponid,targetId,tanantId); | |||
| addCuponChannel(couponid,targetId,tanantId,beginTime,endTime); | |||
| } | |||
| } | |||
| @@ -75,17 +75,22 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||
| } | |||
| @Transactional | |||
| public void addCuponChannel(Long couponid,Integer channelId,String tanantId){ | |||
| public void addCuponChannel(Long couponid,Integer channelId,String tanantId,Date beginTime,Date endTime){ | |||
| WxCoupon wxCoupon = wxCouponService.getById(couponid); | |||
| if(wxCoupon.getStatus()!=1) { | |||
| wxCoupon.setStatus(1); | |||
| wxCouponService.saveOrUpdate(wxCoupon); | |||
| } | |||
| WxCouponChannel wxCouponChannel = new WxCouponChannel(); | |||
| wxCouponChannel.setBeginTime(beginTime); | |||
| wxCouponChannel.setEndTime(endTime); | |||
| wxCouponChannel.setCouponId(couponid); | |||
| wxCouponChannel.setCouponStatus(1); | |||
| wxCouponChannel.setMerchantId(wxCoupon.getMerchantId()); | |||
| wxCouponChannel.setType(wxCoupon.getType()); | |||
| wxCouponChannel.setTargetAd(channelId); | |||
| wxCouponChannel.setTenantId(tanantId); | |||
| wxCouponChannel.setBusiness(wxCoupon.getBusiness()); | |||
| wxCouponChannel.setTitle(wxCoupon.getTitle()); | |||
| saveOrUpdate(wxCouponChannel); | |||
| } | |||
| @@ -3,9 +3,15 @@ package com.simple.service.impl; | |||
| import java.util.*; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.domain.po.WxCoupon; | |||
| import com.simple.domain.po.WxCouponOrder; | |||
| import com.simple.domain.po.WxCouponSend; | |||
| import com.simple.mapper.WxCouponSendMapper; | |||
| import com.simple.service.WxCouponActionLogService; | |||
| import com.simple.service.WxCouponOrderService; | |||
| import com.simple.service.WxCouponSendService; | |||
| import com.simple.service.WxCouponService; | |||
| import org.apache.commons.lang.time.DateUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import com.simple.common.IdWorker; | |||
| @@ -15,6 +21,12 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||
| @Autowired | |||
| WxCouponSendMapper wxCouponSendMapper; | |||
| @Autowired | |||
| WxCouponOrderService wxCouponOrderService; | |||
| @Autowired | |||
| WxCouponService wxCouponService; | |||
| @Autowired | |||
| WxCouponActionLogService wxCouponActionLogService; | |||
| @Override | |||
| @@ -43,12 +55,49 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||
| public void deleteById(Long id) { | |||
| wxCouponSendMapper.deleteByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| public void sendCouponToUser(String tenantId, Long cUserId, int type) { | |||
| //查询开关是否打开 | |||
| //查询停车或者核销的券 | |||
| WxCouponSend wxCouponSendQuery = new WxCouponSend(); | |||
| wxCouponSendQuery.setTenantId(tenantId); | |||
| int actionLogType=0; | |||
| if(type==2){ | |||
| //停车 | |||
| wxCouponSendQuery.setSendType(2); | |||
| actionLogType=3; | |||
| } | |||
| if(type==3){ | |||
| //核销 | |||
| wxCouponSendQuery.setSendType(3); | |||
| actionLogType=4; | |||
| }else{ | |||
| return; | |||
| } | |||
| List<WxCouponSend> wxCouponSends = wxCouponSendMapper.findList(wxCouponSendQuery); | |||
| for (WxCouponSend send:wxCouponSends) { | |||
| WxCoupon wxCoupon= wxCouponService.getById(send.getCouponId()); | |||
| WxCouponOrder wxCouponOrder = new WxCouponOrder(); | |||
| wxCouponOrder.setCouponId(wxCoupon.getId()); | |||
| wxCouponOrder.setCouponOrderStatus(0); | |||
| wxCouponOrder.setCUserId(cUserId); | |||
| wxCouponOrder.setCouponPrice(0); | |||
| wxCouponOrder.setCreateDate(new Date()); | |||
| if (wxCoupon.getValidType() == 1) { //时间范围区间 | |||
| wxCouponOrder.setExpiredTime(wxCoupon.getValidEndDate()); | |||
| } else { | |||
| Date date = DateUtils.addDays(new Date(), wxCoupon.getValidDays()); | |||
| wxCouponOrder.setExpiredTime(date); | |||
| } | |||
| wxCouponOrder.setTenantId(wxCoupon.getTenantId()); | |||
| Long couponOrderId = wxCouponOrderService.insertOne(wxCouponOrder); | |||
| wxCouponActionLogService.addOne(tenantId, wxCoupon.getId(), couponOrderId, actionLogType, send.getId()); | |||
| } | |||
| } | |||
| } | |||
| @@ -6,85 +6,104 @@ | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||
| <result column="merchant_id" jdbcType="BIGINT" property="merchantId" /> | |||
| <result column="coupon_id" jdbcType="BIGINT" property="couponId" /> | |||
| <result column="coupon_status" jdbcType="INTEGER" property="couponStatus" /> | |||
| <result column="type" jdbcType="INTEGER" property="type" /> | |||
| <result column="title" jdbcType="VARCHAR" property="title" /> | |||
| <result column="target_ad" jdbcType="INTEGER" property="targetAd" /> | |||
| <result column="business" jdbcType="VARCHAR" property="business" /> | |||
| <result column="begin_time" jdbcType="TIMESTAMP" property="beginTime" /> | |||
| <result column="end_time" jdbcType="TIMESTAMP" property="endTime" /> | |||
| <result column="status" jdbcType="INTEGER" property="status" /> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`merchant_id`,`coupon_id`,`coupon_status`,`type`,`title`,`target_ad`,`business`,`create_date`,`update_date` | |||
| `id`,`tenant_id`,`merchant_id`,`coupon_id`,`coupon_status`,`type`,`title`,`target_ad`,`business`,`begin_time`,`end_time`,`status`,`create_date`,`update_date` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != tenantId "> | |||
| and `tenant_id` like concat('%', #{tenantId},'%') | |||
| </if> | |||
| <if test=" null != merchantId "> | |||
| and `merchant_id` = #{merchantId} | |||
| </if> | |||
| <if test=" null != couponId "> | |||
| and `coupon_id` = #{couponId} | |||
| </if> | |||
| <if test=" null != couponStatus "> | |||
| and `coupon_status` = #{couponStatus} | |||
| </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 != createDate "> | |||
| and `create_date` = #{createDate} | |||
| </if> | |||
| <if test=" null != updateDate "> | |||
| and `update_date` = #{updateDate} | |||
| </if> | |||
| where 1 = 1 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != tenantId "> | |||
| and `tenant_id` like concat('%', #{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 `business` like concat('%', #{business},'%') | |||
| </if> | |||
| <if test=" null != beginTime "> | |||
| and `begin_time` = #{beginTime} | |||
| </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 != ids "> | |||
| and id in | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| </if> | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.simple.domain.po.WxCouponChannel" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_coupon_channel | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="findVoList" parameterType="com.simple.domain.po.WxCouponChannel" resultMap="CouponChannelVoMap"> | |||
| select <include refid="allColumns" /> from wx_coupon_channel | |||
| <include refid="dynamicWhereConditions" /> | |||
| @@ -95,7 +114,6 @@ | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||
| <result column="merchant_id" jdbcType="BIGINT" property="merchantId" /> | |||
| <result column="coupon_id" jdbcType="BIGINT" property="couponId" /> | |||
| <result column="coupon_status" jdbcType="INTEGER" property="couponStatus" /> | |||
| <result column="type" jdbcType="INTEGER" property="type" /> | |||
| <result column="title" jdbcType="VARCHAR" property="title" /> | |||
| <result column="target_ad" jdbcType="INTEGER" property="targetAd" /> | |||
| @@ -103,10 +121,10 @@ | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||
| </resultMap> | |||
| </mapper> | |||
| @@ -14,8 +14,6 @@ | |||
| <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity" /> | |||
| <result column="target_ad" jdbcType="INTEGER" property="targetAd" /> | |||
| <result column="send_type" jdbcType="INTEGER" property="sendType" /> | |||
| <result column="send_start_date" jdbcType="TIMESTAMP" property="sendStartDate" /> | |||
| <result column="send_end_date" jdbcType="TIMESTAMP" property="sendEndDate" /> | |||
| <result column="valid_type" jdbcType="INTEGER" property="validType" /> | |||
| <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate" /> | |||
| <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate" /> | |||
| @@ -32,7 +30,7 @@ | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`merchant_id`,`type`,`cover_img`,`title`,`sub_title`,`sale_price`,`use_price`,`use_limit_quantity`,`target_ad`,`send_type`,`send_start_date`,`send_end_date`,`valid_type`,`valid_start_date`,`valid_end_date`,`valid_days`,`detail`,`price`,`remain_inventory`,`inventory`,`remark`,`status`,`create_date`,`update_date`,`business` | |||
| `id`,`tenant_id`,`merchant_id`,`type`,`cover_img`,`title`,`sub_title`,`sale_price`,`use_price`,`use_limit_quantity`,`target_ad`,`send_type`,`valid_type`,`valid_start_date`,`valid_end_date`,`valid_days`,`detail`,`price`,`remain_inventory`,`inventory`,`remark`,`status`,`create_date`,`update_date`,`business` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -98,15 +96,7 @@ | |||
| </if> | |||
| <if test=" null != sendStartDate "> | |||
| and `send_start_date` = #{sendStartDate} | |||
| </if> | |||
| <if test=" null != sendEndDate "> | |||
| and `send_end_date` = #{sendEndDate} | |||
| </if> | |||
| <if test=" null != validType "> | |||
| and `valid_type` = #{validType} | |||
| @@ -244,15 +234,7 @@ | |||
| </if> | |||
| <if test=" null != sendStartDate "> | |||
| and `send_start_date` = #{sendStartDate} | |||
| </if> | |||
| <if test=" null != sendEndDate "> | |||
| and `send_end_date` = #{sendEndDate} | |||
| </if> | |||
| <if test=" null != validType "> | |||
| and `valid_type` = #{validType} | |||
| @@ -300,7 +282,7 @@ | |||
| </if> | |||
| <if test=" null != status "> | |||
| and `status` in (0,1,2) | |||
| and `status` =0 | |||
| </if> | |||
| @@ -390,8 +372,6 @@ | |||
| </if> | |||
| and `send_end_date` >= NOW() | |||
| and `send_start_date` <= NOW() | |||
| <if test=" null != validType "> | |||
| and `valid_type` = #{validType} | |||
| @@ -439,7 +419,7 @@ | |||
| </if> | |||
| <if test=" null != status "> | |||
| and `status` in (0,1,2) | |||
| and `status` =0 | |||
| </if> | |||