Merge branch 'dev/feat/partner1.6_20231226' into pre

This commit is contained in:
苏竹红
2023-12-19 14:39:53 +08:00
14 changed files with 204 additions and 12 deletions

View File

@@ -1,5 +1,6 @@
package com.cool.store.dao; package com.cool.store.dao;
import cn.hutool.core.collection.CollectionUtil;
import com.cool.store.dto.exhibition.ExhibitionDTO; import com.cool.store.dto.exhibition.ExhibitionDTO;
import com.cool.store.dto.exhibition.ExhibitionStatisticsDTO; import com.cool.store.dto.exhibition.ExhibitionStatisticsDTO;
import com.cool.store.entity.HyExhibitionDO; import com.cool.store.entity.HyExhibitionDO;
@@ -11,10 +12,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -132,4 +130,18 @@ public class HyExhibitionDAO {
} }
return hyExhibitionMapper.getPartnerExhibitionInfo(exhibitionId, partnerLineId); return hyExhibitionMapper.getPartnerExhibitionInfo(exhibitionId, partnerLineId);
} }
public List<HyExhibitionDO> querySelective(HyExhibitionDO hyExhibitionDO) {
if (hyExhibitionDO == null) {
return new ArrayList<>();
}
return hyExhibitionMapper.querySelective(hyExhibitionDO);
}
public int batchCloseExhibition(List<Integer> hyExhibitionIds) {
if (CollectionUtil.isEmpty(hyExhibitionIds)) {
return 0;
}
return hyExhibitionMapper.batchCloseExhibition(hyExhibitionIds);
}
} }

View File

@@ -72,4 +72,7 @@ public class HyExhibitionGroupDAO {
} }
public int batchCloseExhibitionGroup() {
return hyExhibitionGroupMapper.batchCloseExhibitionGroup();
}
} }

View File

@@ -143,4 +143,11 @@ public class HyPartnerExhibitionDAO {
} }
return hyPartnerExhibitionMapper.partnerSignUpCount(lineIds); return hyPartnerExhibitionMapper.partnerSignUpCount(lineIds);
} }
public List<Long> getCloseExhibitionLineIds(List<Integer> exhibitionIds) {
if (CollectionUtils.isEmpty(exhibitionIds)){
return new ArrayList<>();
}
return hyPartnerExhibitionMapper.getCloseExhibitionLineIds(exhibitionIds);
}
} }

View File

@@ -2,8 +2,6 @@ package com.cool.store.mapper;
import com.cool.store.dto.exhibition.MyExhibitionGroupDTO; import com.cool.store.dto.exhibition.MyExhibitionGroupDTO;
import com.cool.store.entity.HyExhibitionGroupDO; import com.cool.store.entity.HyExhibitionGroupDO;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List; import java.util.List;
@@ -42,4 +40,10 @@ public interface HyExhibitionGroupMapper {
int deleteByPrimaryKey(Integer id); int deleteByPrimaryKey(Integer id);
List<MyExhibitionGroupDTO> listByCreator(String userId); List<MyExhibitionGroupDTO> listByCreator(String userId);
/**
* 批量关闭需要关闭的会销组
* @return
*/
int batchCloseExhibitionGroup();
} }

View File

@@ -81,4 +81,13 @@ public interface HyExhibitionMapper {
* @return * @return
*/ */
PartnerExhibitionInfoVO getPartnerExhibitionInfo(@Param("exhibitionId") Integer exhibitionId, @Param("partnerLineId") Long partnerLineId); PartnerExhibitionInfoVO getPartnerExhibitionInfo(@Param("exhibitionId") Integer exhibitionId, @Param("partnerLineId") Long partnerLineId);
/**
* 查询符合条件的会销列表
* @param hyExhibitionDO
* @return
*/
List<HyExhibitionDO> querySelective(HyExhibitionDO hyExhibitionDO);
int batchCloseExhibition(@Param("hyExhibitionIds") List<Integer> hyExhibitionIds);
} }

View File

@@ -3,9 +3,7 @@ package com.cool.store.mapper;
import com.cool.store.dto.exhibition.ExhibitionLineBaseDTO; import com.cool.store.dto.exhibition.ExhibitionLineBaseDTO;
import com.cool.store.dto.exhibition.ExhibitionLineDTO; import com.cool.store.dto.exhibition.ExhibitionLineDTO;
import com.cool.store.dto.exhibition.PartnerSignUpDTO; import com.cool.store.dto.exhibition.PartnerSignUpDTO;
import com.cool.store.entity.HyExhibitionDO;
import com.cool.store.entity.HyPartnerExhibitionDO; import com.cool.store.entity.HyPartnerExhibitionDO;
import io.swagger.models.auth.In;
import com.cool.store.entity.HyPartnerExhibitionInterviewDO; import com.cool.store.entity.HyPartnerExhibitionInterviewDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@@ -104,4 +102,11 @@ public interface HyPartnerExhibitionMapper {
* @return * @return
*/ */
List<PartnerSignUpDTO> partnerSignUpCount(@Param("lineIds") List<Long> lineIds ); List<PartnerSignUpDTO> partnerSignUpCount(@Param("lineIds") List<Long> lineIds );
/**
* 获取待修改会销中状态的线索 ids
* @param exhibitionIds
* @return
*/
List<Long> getCloseExhibitionLineIds(@Param("exhibitionIds") List<Integer> exhibitionIds);
} }

View File

@@ -150,4 +150,23 @@
</if> </if>
</trim> </trim>
</sql> </sql>
<update id="batchCloseExhibitionGroup">
UPDATE `hy_exhibition_group` t1
INNER JOIN (
-- 所有关联的会销都结束的会销组(不包含未关联会销的会销组)
SELECT eg.id
FROM `hy_exhibition_group` eg
LEFT JOIN `hy_exhibition` e ON eg.id = e.exhibition_group_id
WHERE eg.deleted = 0
AND e.deleted = 0
AND eg.closed = 0
GROUP BY eg.id
HAVING COUNT(e.id) = COUNT(CASE WHEN e.closed_type != 0 THEN 1 END)
) AS t2 ON t1.id = t2.id
SET closed = 1
WHERE t1.deleted = 0
AND t1.closed = 0
</update>
</mapper> </mapper>

View File

@@ -34,6 +34,59 @@
from hy_exhibition from hy_exhibition
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</select> </select>
<select id="querySelective" resultType="com.cool.store.entity.HyExhibitionDO">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from hy_exhibition
<where>
<if test="exhibitionGroupId != null">
and exhibition_group_id = #{exhibitionGroupId,jdbcType=INTEGER}
</if>
<if test="exhibitionCode != null">
and exhibition_code = #{exhibitionCode,jdbcType=VARCHAR}
</if>
<if test="exhibitionName != null">
and exhibition_name = #{exhibitionName,jdbcType=VARCHAR}
</if>
<if test="startDate != null">
and start_date = #{startDate,jdbcType=DATE}
</if>
<if test="startDateStr != null">
and start_date = #{startDateStr,jdbcType=DATE}
</if>
<if test="location != null">
and location = #{location,jdbcType=VARCHAR}
</if>
<if test="closedType != null">
and closed_type = #{closedType,jdbcType=TINYINT}
</if>
<if test="createTime != null">
and create_time = #{createTime,jdbcType=TIMESTAMP}
</if>
<if test="updateTime != null">
and update_time = #{updateTime,jdbcType=TIMESTAMP}
</if>
<if test="creator != null">
and creator = #{creator,jdbcType=VARCHAR}
</if>
<if test="updater != null">
and updater = #{updater,jdbcType=VARCHAR}
</if>
<if test="deleted != null">
and deleted = #{deleted,jdbcType=BIT}
</if>
<if test="closeTime != null">
and close_time = #{closeTime,jdbcType=TIMESTAMP}
</if>
<if test="collaborators != null">
and collaborators = #{collaborators,jdbcType=LONGVARCHAR}
</if>
</where>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from hy_exhibition delete from hy_exhibition
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
@@ -405,4 +458,14 @@
AND t1.id = #{exhibitionId} AND t1.id = #{exhibitionId}
</select> </select>
<update id="batchCloseExhibition">
update hy_exhibition
set closed_type = 2, close_time = now()
where id in (
<foreach collection="hyExhibitionIds" item="hyExhibitionId" separator=",">
#{hyExhibitionId}
</foreach>
)
</update>
</mapper> </mapper>

View File

@@ -460,4 +460,16 @@
</foreach> </foreach>
group by a.partner_line_id group by a.partner_line_id
</select> </select>
<select id="getCloseExhibitionLineIds" resultType="java.lang.Long">
SELECT DISTINCT partner_line_id
FROM hy_partner_exhibition
WHERE deleted = 0
AND exhibition_id IN (
<foreach collection="exhibitionIds" item="exhibitionId" separator=",">
#{exhibitionId}
</foreach>
)
AND participation_status != 7
</select>
</mapper> </mapper>

View File

@@ -35,6 +35,9 @@ public class HyExhibitionDO implements Serializable {
@ApiModelProperty("举办日期") @ApiModelProperty("举办日期")
private Date startDate; private Date startDate;
@ApiModelProperty("举办日期str")
private String startDateStr;
@ApiModelProperty("举办地点") @ApiModelProperty("举办地点")
private String location; private String location;

View File

@@ -1,8 +1,10 @@
package com.cool.store.job; package com.cool.store.job;
import com.cool.store.service.ExhibitionService;
import com.xxl.job.core.context.XxlJobHelper; import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
@@ -13,11 +15,16 @@ import org.springframework.stereotype.Component;
@Component @Component
public class ExhibitionJob { public class ExhibitionJob {
@XxlJob("finishExhibition") @Autowired
private ExhibitionService exhibitionService;
@XxlJob("autoCloseExhibition")
public void syncUserSourceJob() { public void syncUserSourceJob() {
XxlJobHelper.log("-------------------------------自动结束会销任务开始-------------------------------"); XxlJobHelper.log("-------------------------------自动结束会销任务开始-------------------------------");
log.info("-------------------------------自动结束会销任务开始-------------------------------");
XxlJobHelper.log("-------------------------------自动结束会销任务结束-------------------------------"); int res = exhibitionService.autoCloseExhibition();
log.info("-------------------------------自动结束会销任务结束,共结束" + res + "个会销-------------------------------");
XxlJobHelper.log("-------------------------------自动结束会销任务结束,共结束" + res + "个会销-------------------------------");
XxlJobHelper.handleSuccess(); XxlJobHelper.handleSuccess();
} }

View File

@@ -153,4 +153,10 @@ public interface ExhibitionService {
* @return * @return
*/ */
PartnerExhibitionInfoVO getExhibitionInfo(Integer exhibitionId, Long partnerLineId); PartnerExhibitionInfoVO getExhibitionInfo(Integer exhibitionId, Long partnerLineId);
/**
* 自动结束会销
*/
int autoCloseExhibition();
} }

View File

@@ -181,7 +181,7 @@ public class ExhibitionServiceImpl implements ExhibitionService {
hyExhibitionDO.setCreator(userInfo.getUserId()); hyExhibitionDO.setCreator(userInfo.getUserId());
hyExhibitionDO.setLocation(exhibitionDTO.getLocation()); hyExhibitionDO.setLocation(exhibitionDTO.getLocation());
hyExhibitionDO.setExhibitionGroupId(hyExhibitionGroupDO.getId()); hyExhibitionDO.setExhibitionGroupId(hyExhibitionGroupDO.getId());
hyExhibitionDO.setStartDate(CoolDateUtils.parseDate(exhibitionDTO.getStartDate(),CoolDateUtils.DATE_FORMAT_SEC_2)); hyExhibitionDO.setStartDate(CoolDateUtils.parseDate(exhibitionDTO.getStartDate(),CoolDateUtils.DATE_FORMAT_DAY_2));
insertList.add(hyExhibitionDO); insertList.add(hyExhibitionDO);
} }
//批量新增会销 //批量新增会销
@@ -688,6 +688,42 @@ public class ExhibitionServiceImpl implements ExhibitionService {
return hyExhibitionDAO.getPartnerExhibitionInfo(exhibitionId, partnerLineId); return hyExhibitionDAO.getPartnerExhibitionInfo(exhibitionId, partnerLineId);
} }
@Override
@Transactional
public int autoCloseExhibition() {
//1. 查询需要关闭的会销
HyExhibitionDO hyExhibitionDO = new HyExhibitionDO();
hyExhibitionDO.setClosedType(0);
hyExhibitionDO.setStartDateStr(DateUtil.format(new Date(), CoolDateUtils.DATE_FORMAT_DAY));
hyExhibitionDO.setDeleted(Boolean.FALSE);
List<HyExhibitionDO> hyExhibitionDOS = hyExhibitionDAO.querySelective(hyExhibitionDO);
if (CollectionUtils.isEmpty(hyExhibitionDOS)) {
return 0;
}
List<Integer> exhibitionIds = hyExhibitionDOS.stream().map(HyExhibitionDO::getId).collect(Collectors.toList());
//2. 批量刷新会销为结束状态
hyExhibitionDOS.forEach(x->{
x.setClosedType(1);
x.setCloseTime(new Date());
});
int res = hyExhibitionDAO.batchCloseExhibition(exhibitionIds);
//3. 处理需要关闭的会销组
hyExhibitionGroupDAO.batchCloseExhibitionGroup();
//4. 批量处理报名线索是否会销中状态
//4.1 查询可能需要修改状态的会销线索 lineId
List<Long> lineIds = hyPartnerExhibitionDAO.getCloseExhibitionLineIds(exhibitionIds);
if (CollectionUtils.isEmpty(lineIds)){
return res;
}
//4.2 处理会销线索是否会销中状态
whetherInExhibition(lineIds, Boolean.FALSE);
return res;
}
/** /**
* 计算是否会销中 * 计算是否会销中
* @param lineId * @param lineId

View File

@@ -22,4 +22,10 @@ class ExhibitionServiceTest extends AbstractJUnit4SpringContextTests {
log.debug(""); log.debug("");
} }
@Test
void testAutoCloseExhibition() {
int i = exhibitionService.autoCloseExhibition();
log.info(i + "");
}
} }