Просмотр исходного кода

/、topic

release_toaliyun_real
xhxu 4 лет назад
Родитель
Сommit
672f0744e4
4 измененных файлов: 79 добавлений и 19 удалений
  1. +8
    -1
      mallinkCApi/src/main/java/com/iformall/controller/WxTopicController.java
  2. +2
    -1
      mallinkService/src/main/java/com/iformall/domain/po/WxTopic.java
  3. +65
    -15
      mallinkService/src/main/java/com/iformall/service/impl/WxTopicServiceImpl.java
  4. +4
    -2
      mallinkService/src/main/resources/mapper/WxTopicMapper.xml

+ 8
- 1
mallinkCApi/src/main/java/com/iformall/controller/WxTopicController.java Просмотреть файл

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

import com.iformall.common.ResultData;
import com.iformall.domain.po.WxTopic;
import com.iformall.enums.EnumWxTopicType;
import com.iformall.service.WxTopicService;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
@@ -14,15 +15,21 @@ import org.springframework.web.bind.annotation.*;
@RequestMapping("/api/topic")
@Api(description = "专题相关接口")
public class WxTopicController extends BaseController {

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

@Autowired
private WxTopicService wxTopicService;

@GetMapping("show")
public ResultData show() {
public ResultData show(Integer topicType) {
logger.debug("[" + getIpAddr() + "] WxTopicController::show");
if(topicType == null){
topicType = EnumWxTopicType.SPECIAL_TOPIC.getCode();
}
WxTopic wxTopic = new WxTopic();
wxTopic.updateTenantInfo(getTenantInfo());
wxTopic.setTopicType(topicType);
return new ResultData(wxTopicService.show(wxTopic));
}



+ 2
- 1
mallinkService/src/main/java/com/iformall/domain/po/WxTopic.java Просмотреть файл

@@ -3,6 +3,7 @@ package com.iformall.domain.po;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.WxCouponChannelVo;
import com.iformall.enums.EnumWxTopicType;
import com.iformall.utils.Constant;
import lombok.Data;
@@ -55,7 +56,7 @@ public class WxTopic extends TenantEntity {

@TableField(exist = false)
@io.swagger.annotations.ApiModelProperty(value="商品列表",name="couponList")
private List<WxCoupon> couponList;
private List<WxCouponChannelVo> couponList;

@TableField(exist = false)
@io.swagger.annotations.ApiModelProperty(value="状态,一个或者多个",name="statusStr")


+ 65
- 15
mallinkService/src/main/java/com/iformall/service/impl/WxTopicServiceImpl.java Просмотреть файл

@@ -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);


+ 4
- 2
mallinkService/src/main/resources/mapper/WxTopicMapper.xml Просмотреть файл

@@ -88,8 +88,10 @@

<select id="show" parameterType="com.iformall.domain.po.WxTopic" resultMap="BaseResultMap">
select t.* from wx_topic t
where t.status = 1 and t.`topic_type` = 1
and now() >= t.begin_time and now() &lt;= t.end_time
where t.status = 1 and t.`topic_type` = #{topicType}
<if test="topicType == 1">
and now() >= t.begin_time and now() &lt;= t.end_time
</if>
and t.tenant_id = #{tenantId}
order by t.begin_time desc limit 1
</select>


Загрузка…
Отмена
Сохранить