|
|
|
@@ -9,14 +9,14 @@ import com.iformall.common.Result; |
|
|
|
import com.iformall.domain.po.WxCoupon; |
|
|
|
import com.iformall.domain.po.WxCouponChannel; |
|
|
|
import com.iformall.domain.po.WxTopic; |
|
|
|
import com.iformall.enums.EnumCouponChannelType; |
|
|
|
import com.iformall.enums.EnumPayWay; |
|
|
|
import com.iformall.enums.EnumWxTopicStatus; |
|
|
|
import com.iformall.enums.EnumWxTopicType; |
|
|
|
import com.iformall.domain.po.base.BaseEntity; |
|
|
|
import com.iformall.domain.vo.WxCouponChannelVo; |
|
|
|
import com.iformall.enums.*; |
|
|
|
import com.iformall.mapper.WxCouponChannelMapper; |
|
|
|
import com.iformall.mapper.WxCouponMapper; |
|
|
|
import com.iformall.mapper.WxTopicMapper; |
|
|
|
import com.iformall.service.QrCodeService; |
|
|
|
import com.iformall.service.WxCouponChannelService; |
|
|
|
import com.iformall.service.WxTopicService; |
|
|
|
import com.iformall.utils.Constant; |
|
|
|
import com.iformall.utils.DateUtils; |
|
|
|
@@ -36,15 +36,22 @@ import java.util.Map; |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class WxTopicServiceImpl implements WxTopicService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxTopicMapper wxTopicMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxCouponMapper wxCouponMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxCouponChannelMapper wxCouponChannelMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private QrCodeService qrCodeService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxCouponChannelService wxCouponChannelService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageInfo<WxTopic> listAsPage(WxTopic record, Integer pageIndex, Integer pageSize) { |
|
|
|
wxTopicMapper.updateStatus(record); |
|
|
|
@@ -64,7 +71,7 @@ public class WxTopicServiceImpl implements WxTopicService { |
|
|
|
public WxTopic show(WxTopic record) { |
|
|
|
WxTopic wxTopic = wxTopicMapper.show(record); |
|
|
|
if(wxTopic != null) { |
|
|
|
wxTopic.setCouponList(wxCouponMapper.findCouponByTopic(record)); |
|
|
|
addCouponList(wxTopic); |
|
|
|
} |
|
|
|
return wxTopic; |
|
|
|
} |
|
|
|
@@ -73,7 +80,7 @@ public class WxTopicServiceImpl implements WxTopicService { |
|
|
|
public List<WxTopic> showList(WxTopic record) { |
|
|
|
List<WxTopic> topicList = wxTopicMapper.showList(record); |
|
|
|
for (WxTopic topic:topicList) { |
|
|
|
topic.setCouponList(wxCouponMapper.findCouponByTopic(record)); |
|
|
|
addCouponList(topic); |
|
|
|
} |
|
|
|
return topicList; |
|
|
|
} |
|
|
|
@@ -130,7 +137,7 @@ public class WxTopicServiceImpl implements WxTopicService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void addCouponTopic(WxTopic record){ |
|
|
|
private void addCouponTopic(WxTopic record){ |
|
|
|
for (String couponId:JSONArray.parseArray(record.getCouponIds(), String.class)) { |
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
String[] couponArray = couponId.split("-"); |
|
|
|
@@ -167,20 +174,63 @@ public class WxTopicServiceImpl implements WxTopicService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void addCouponList(WxTopic record){ |
|
|
|
|
|
|
|
WxCouponChannel wxCouponChannel = new WxCouponChannel(); |
|
|
|
wxCouponChannel.updateTenantInfo(record); |
|
|
|
wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); |
|
|
|
wxCouponChannel.setCouponStatus(EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()); |
|
|
|
wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC, BaseEntity.SortField.CCId_DESC); |
|
|
|
wxCouponChannel.setShowBeginTime(new Date()); |
|
|
|
|
|
|
|
Integer pageSize = 6; |
|
|
|
|
|
|
|
if(EnumWxTopicType.SPECIAL_TOPIC.getCode().equals(record.getTopicType())){ |
|
|
|
wxCouponChannel.setSubTargetId(record.getId()); |
|
|
|
pageSize = 1000;//默认专题查全部 |
|
|
|
// wxCouponChannelVoPageInfo = wxCouponChannelService.listPageCVo(wxCouponChannel, 1, 100); |
|
|
|
// record.setCouponList(wxCouponMapper.findCouponByTopic(record)); |
|
|
|
}else if(EnumWxTopicType.FLASH_SALE.getCode().equals(record.getTopicType())){ |
|
|
|
wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_TIMED.getCode()); |
|
|
|
|
|
|
|
}else if(EnumWxTopicType.PRESS.getCode().equals(record.getTopicType())){ |
|
|
|
wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_PRESS.getCode()); |
|
|
|
|
|
|
|
}else if(EnumWxTopicType.GROUP.getCode().equals(record.getTopicType())){ |
|
|
|
wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_ORDER_GROUP.getCode()); |
|
|
|
|
|
|
|
}else if(EnumWxTopicType.CARD_MULTIMCH.getCode().equals(record.getTopicType())){ |
|
|
|
wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_CARD.getCode()); |
|
|
|
|
|
|
|
}else if(EnumWxTopicType.CREDIT.getCode().equals(record.getTopicType())){ |
|
|
|
wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_CREDIT.getCode()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
PageInfo<WxCouponChannelVo> wxCouponChannelVoPageInfo = wxCouponChannelService.listPageCVo(wxCouponChannel, 1, pageSize); |
|
|
|
if(wxCouponChannelVoPageInfo != null && wxCouponChannelVoPageInfo.getList() != null |
|
|
|
&& wxCouponChannelVoPageInfo.getList().size() > 0){ |
|
|
|
record.setCouponList(wxCouponChannelVoPageInfo.getList()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public WxTopic findById(WxTopic record) { |
|
|
|
WxTopic wxTopic = wxTopicMapper.selectById(record.getId()); |
|
|
|
if(EnumWxTopicType.SPECIAL_TOPIC.getCode().equals(record.getTopicType())){ |
|
|
|
List<WxCoupon> wxCouponList = wxCouponMapper.findCouponByTopic(record); |
|
|
|
wxTopic.setCouponList(wxCouponList); |
|
|
|
addCouponList(wxTopic); |
|
|
|
// List<WxCoupon> wxCouponList = wxCouponMapper.findCouponByTopic(record); |
|
|
|
// wxTopic.setCouponList(wxCouponList); |
|
|
|
List<WxCouponChannelVo> couponList = wxTopic.getCouponList(); |
|
|
|
String couponIds = ""; |
|
|
|
if(CollectionUtils.isNotEmpty(wxCouponList)) { |
|
|
|
for (int i = 0; i < wxCouponList.size(); i++) { |
|
|
|
WxCoupon wxCoupon = wxCouponList.get(i); |
|
|
|
if (i == wxCouponList.size() - 1) { |
|
|
|
couponIds += wxCoupon.getType() +"-"+ wxCoupon.getId().toString(); |
|
|
|
if(CollectionUtils.isNotEmpty(couponList)) { |
|
|
|
for (int i = 0; i < couponList.size(); i++) { |
|
|
|
WxCouponChannelVo couponChannel = couponList.get(i); |
|
|
|
if (i == couponList.size() - 1) { |
|
|
|
couponIds += couponChannel.getType() +"-"+ couponChannel.getCouponId().toString(); |
|
|
|
} else { |
|
|
|
couponIds += wxCoupon.getType() +"-"+ wxCoupon.getId().toString() + ","; |
|
|
|
couponIds += couponChannel.getType() +"-"+ couponChannel.getCouponId().toString() + ","; |
|
|
|
} |
|
|
|
} |
|
|
|
wxTopic.setCouponIds(couponIds); |
|
|
|
|