Browse Source

/、topic

release_toaliyun_real
xhxu 4 years ago
parent
commit
d4ece8b668
7 changed files with 130 additions and 25 deletions
  1. +36
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/market/WxTopicController.java
  2. +2
    -0
      mallinkAdmin/src/main/resources/db/migration/V2021120900001__add_topic_type.sql
  3. +9
    -2
      mallinkService/src/main/java/com/iformall/domain/po/WxTopic.java
  4. +40
    -0
      mallinkService/src/main/java/com/iformall/enums/EnumWxTopicType.java
  5. +1
    -1
      mallinkService/src/main/java/com/iformall/service/WxTopicService.java
  6. +32
    -17
      mallinkService/src/main/java/com/iformall/service/impl/WxTopicServiceImpl.java
  7. +10
    -5
      mallinkService/src/main/resources/mapper/WxTopicMapper.xml

+ 36
- 0
mallinkAdmin/src/main/java/com/iformall/controller/market/WxTopicController.java View File

@@ -2,14 +2,17 @@ package com.iformall.controller.market;

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.*;
import com.iformall.enums.EnumWxTopicStatus;
import com.iformall.enums.EnumWxTopicType;
import com.iformall.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -32,6 +35,7 @@ public class WxTopicController extends BaseController {
public ResultData list(WxTopic wxTopic, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxTopicController::list");
wxTopic.updateTenantInfo(getTenantInfo());
wxTopic.setTopicType(EnumWxTopicType.SPECIAL_TOPIC.getCode());
PageInfo<WxTopic> page = wxTopicService.listAsPage(wxTopic, pageNum, pageSize);

//可投放、已上线,时间区间查的是活动开始时间
@@ -59,13 +63,45 @@ public class WxTopicController extends BaseController {
return new ResultData(queryTopic);
}


@PostMapping("saveOrUpdate")
@SystemControllerLog(description = "专题-保存更新")
public ResultData saveOrUpdate(@RequestBody WxTopic wxTopic) {
logger.debug("[" + getIpAddr() + "] WxTopicController::saveOrUpdate");
wxTopic.updateTenantInfo(getTenantInfo());
if(wxTopic.getTopicType() == null){
wxTopic.setTopicType(EnumWxTopicType.SPECIAL_TOPIC.getCode());
}
return wxTopicService.saveOrUpdate(wxTopic);
}

@GetMapping("findByType")
@SystemControllerLog(description = "专题-获取详情")
public ResultData findByType(Integer topicType) {
logger.debug("[" + getIpAddr() + "] WxTopicController::findByType");
if(topicType == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
WxTopic wxTopic = new WxTopic();
wxTopic.updateTenantInfo(getTenantInfo());
wxTopic.setTopicType(topicType);
WxTopic queryTopic = wxTopicService.findByType(wxTopic);
return new ResultData(queryTopic);
}

@PostMapping("updateByType")
@SystemControllerLog(description = "专题-保存更新")
public ResultData updateByType(@RequestBody WxTopic wxTopic) {
logger.debug("[" + getIpAddr() + "] WxTopicController::updateByType");
wxTopic.updateTenantInfo(getTenantInfo());
if(wxTopic.getTopicType() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
wxTopic.setName(EnumWxTopicType.getEnum(wxTopic.getTopicType()).getMessage());
if(StringUtils.isBlank(wxTopic.getName())){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR);
}
return wxTopicService.saveOrUpdate(wxTopic);
}

}

+ 2
- 0
mallinkAdmin/src/main/resources/db/migration/V2021120900001__add_topic_type.sql View File

@@ -0,0 +1,2 @@
ALTER TABLE `mallink`.`wx_topic`
ADD COLUMN `topic_type` smallint(3) NOT NULL DEFAULT 1 COMMENT 'EnumWxTopicType' AFTER `parent_tenant_id`;

+ 9
- 2
mallinkService/src/main/java/com/iformall/domain/po/WxTopic.java View File

@@ -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.enums.EnumWxTopicType;
import com.iformall.utils.Constant;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -19,6 +20,8 @@ public class WxTopic extends TenantEntity {

protected Long id;

@io.swagger.annotations.ApiModelProperty(value="专题类型",name="topicType")
private Integer topicType;
@io.swagger.annotations.ApiModelProperty(value="名称",name="name")
private String name;
@io.swagger.annotations.ApiModelProperty(value="标题",name="title")
@@ -81,12 +84,16 @@ public class WxTopic extends TenantEntity {
public String getWeappPath() {
if(id == null)
return Constant.mainPageUrl;
return Constant.mainPageUrl + "?type=td&id="+id;
if(EnumWxTopicType.SPECIAL_TOPIC.getCode().equals(topicType))
return Constant.mainPageUrl + "?type=td&id="+id;
return Constant.mainPageUrl;
}

public String getWeappScene() {
if(id == null)
return "";
return "t:td:" + id;
if(EnumWxTopicType.SPECIAL_TOPIC.getCode().equals(topicType))
return "t:td:" + id;
return "";
}
}

+ 40
- 0
mallinkService/src/main/java/com/iformall/enums/EnumWxTopicType.java View File

@@ -0,0 +1,40 @@
package com.iformall.enums;

/**
* Created by
*/
public enum EnumWxTopicType {
SPECIAL_TOPIC(1, "默认专题"),
FLASH_SALE(2, "限时抢购"),
PRESS(3, "砍价专区"),
GROUP(4, "拼团专区"),
CARD_MULTIMCH(5, "消费卡"),
CREDIT(6, "积分商城"),
;


public static EnumWxTopicType getEnum(Integer code) {
for (EnumWxTopicType value : values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}

private Integer code;
private String message;

EnumWxTopicType(Integer code, String message) {
this.code = code;
this.message = message;
}

public Integer getCode() {
return code;
}

public String getMessage() {
return message;
}
}

+ 1
- 1
mallinkService/src/main/java/com/iformall/service/WxTopicService.java View File

@@ -26,5 +26,5 @@ public interface WxTopicService {

WxTopic findById(WxTopic record);

WxTopic findByType(WxTopic wxTopic);
}

+ 32
- 17
mallinkService/src/main/java/com/iformall/service/impl/WxTopicServiceImpl.java View File

@@ -12,6 +12,7 @@ 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.mapper.WxCouponChannelMapper;
import com.iformall.mapper.WxCouponMapper;
import com.iformall.mapper.WxTopicMapper;
@@ -109,19 +110,22 @@ public class WxTopicServiceImpl implements WxTopicService {
record.setId(idWorker.nextId());
wxTopicMapper.insert(record);

if(StringUtils.isNotBlank(record.getCouponIds())) {
if(EnumWxTopicType.SPECIAL_TOPIC.getCode().equals(record.getTopicType())
&& StringUtils.isNotBlank(record.getCouponIds())) {
addCouponTopic(record);
}
return new ResultData(Result.SUCCESS,"添加成功");
} else {
record.setUpdatetime(new Date());
wxTopicMapper.updateById(record);
if(StringUtils.isNotBlank(record.getCouponIds())) {
//优化:区分添加的和删除的
wxCouponChannelMapper.delByTopic(record);
addCouponTopic(record);
if(EnumWxTopicType.SPECIAL_TOPIC.getCode().equals(record.getTopicType())){
if(StringUtils.isNotBlank(record.getCouponIds())) {
//优化:区分添加的和删除的
wxCouponChannelMapper.delByTopic(record);
addCouponTopic(record);
}
wxTopicMapper.couponDownLine(record);
}
wxTopicMapper.couponDownLine(record);
return new ResultData(Result.SUCCESS,"更新成功");
}
}
@@ -166,20 +170,31 @@ public class WxTopicServiceImpl implements WxTopicService {
@Override
public WxTopic findById(WxTopic record) {
WxTopic wxTopic = wxTopicMapper.selectById(record.getId());
List<WxCoupon> wxCouponList = wxCouponMapper.findCouponByTopic(record);
wxTopic.setCouponList(wxCouponList);
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();
} else {
couponIds += wxCoupon.getType() +"-"+ wxCoupon.getId().toString() + ",";
if(EnumWxTopicType.SPECIAL_TOPIC.getCode().equals(record.getTopicType())){
List<WxCoupon> wxCouponList = wxCouponMapper.findCouponByTopic(record);
wxTopic.setCouponList(wxCouponList);
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();
} else {
couponIds += wxCoupon.getType() +"-"+ wxCoupon.getId().toString() + ",";
}
}
wxTopic.setCouponIds(couponIds);
}
wxTopic.setCouponIds(couponIds);
}
return wxTopic;
}

@Override
public WxTopic findByType(WxTopic wxTopic) {
List<WxTopic> list = wxTopicMapper.findList(wxTopic);
if(list != null && list.size() > 0){
return list.get(0);
}
return null;
}
}

+ 10
- 5
mallinkService/src/main/resources/mapper/WxTopicMapper.xml View File

@@ -5,6 +5,7 @@
<id column="id" property="id"/>
<result column="tenant_id" property="tenantId"/>
<result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
<result column="topic_type" jdbcType="INTEGER" property="topicType"/>
<result column="name" property="name"/>
<result column="title" property="title"/>
<result column="content" property="content"/>
@@ -22,7 +23,7 @@
</resultMap>

<sql id="allColumns">
`id`,`tenant_id`,`parent_tenant_id`,`name`,`title`,`content`,`cover`,`cover_picture`,`detail_picture`,`advert`,`begin_time`,`end_time`,`createtime`,`updatetime`,`bg_color`
`id`,`tenant_id`,`parent_tenant_id`,`topic_type`,`name`,`title`,`content`,`cover`,`cover_picture`,`detail_picture`,`advert`,`begin_time`,`end_time`,`createtime`,`updatetime`,`bg_color`
</sql>

<sql id="dynamicWhereConditions">
@@ -37,6 +38,10 @@
and `parent_tenant_id` = #{parentTenantId}
</if>

<if test=" null != topicType">
and `topic_type` = #{topicType}
</if>

<if test='statusStr =="0,2" or status==1'>
<if test=" null != beginTime ">
and `begin_time` >= #{beginTime}
@@ -83,7 +88,7 @@

<select id="show" parameterType="com.iformall.domain.po.WxTopic" resultMap="BaseResultMap">
select t.* from wx_topic t
where t.status = 1
where t.status = 1 and t.`topic_type` = 1
and now() >= t.begin_time and now() &lt;= t.end_time
and t.tenant_id = #{tenantId}
order by t.begin_time desc limit 1
@@ -91,7 +96,7 @@

<select id="showList" parameterType="com.iformall.domain.po.WxTopic" resultMap="BaseResultMap">
select t.* from wx_topic t
where t.status = 1
where t.status = 1 and t.`topic_type` = 1
and now() >= t.begin_time and now() &lt;= t.end_time
and t.tenant_id = #{tenantId}
order by t.begin_time desc
@@ -100,14 +105,14 @@
<update id="updateStatus" parameterType="com.iformall.domain.po.WxTopic">
update wx_topic set status = 3 where id in(
select t.id from (
select id from wx_topic where status !=3 and now() >= end_time and tenant_id = #{tenantId}
select id from wx_topic where `topic_type` = 1 and status !=3 and now() >= end_time and tenant_id = #{tenantId}
) t
)
</update>

<update id="couponDownLine" parameterType="com.iformall.domain.po.WxTopic">
update wx_coupon_channel set status = 1 where status = 0 and target_ad = 8 and sub_target_id in(
select id from wx_topic where status in(2,3) and tenant_id = #{tenantId}
select id from wx_topic where `topic_type` = 1 and status in(2,3) and tenant_id = #{tenantId}
)
</update>



Loading…
Cancel
Save