diff --git a/fw-valhalla-common/src/main/java/cn/fw/valhalla/common/enums/DefeatTypeEnum.java b/fw-valhalla-common/src/main/java/cn/fw/valhalla/common/enums/DefeatTypeEnum.java new file mode 100644 index 0000000..6689b1c --- /dev/null +++ b/fw-valhalla-common/src/main/java/cn/fw/valhalla/common/enums/DefeatTypeEnum.java @@ -0,0 +1,53 @@ +package cn.fw.valhalla.common.enums; + +import com.fasterxml.jackson.annotation.JsonCreator; +import lombok.Getter; + +/** + * @author : kurisu + * @className : DefeatTypeEnum + * @description : 战败类型 + * @date: 2020-10-16 17:56 + */ +public enum DefeatTypeEnum { + /** + * 主动战败 + */ + A(1, "主动战败"), + /** + * 到期划走 + */ + B(2, "到期划走"), + /** + * 到期战败 + */ + C(3, "到期战败"); + + /** + * 值 + */ + private final Integer value; + /** + * 名称 + */ + @Getter + private final String name; + + DefeatTypeEnum(final Integer value, final String name) { + this.value = value; + this.name = name; + } + + /** + * 根据枚举值获取枚举对象 + */ + @JsonCreator + public static DefeatTypeEnum ofValue(final Integer value) { + for (final DefeatTypeEnum typeEnum : DefeatTypeEnum.values()) { + if (typeEnum.value.equals(value)) { + return typeEnum; + } + } + return null; + } +} diff --git a/fw-valhalla-dao/src/main/resources/mapper/FollowTaskMapper.xml b/fw-valhalla-dao/src/main/resources/mapper/FollowTaskMapper.xml index 9af2458..9de2f05 100644 --- a/fw-valhalla-dao/src/main/resources/mapper/FollowTaskMapper.xml +++ b/fw-valhalla-dao/src/main/resources/mapper/FollowTaskMapper.xml @@ -24,7 +24,8 @@ end state, t1.finish_time finish_time, case t1.finished when 1 then null when 0 then t1.deadline end defeat_time, - (select count(1) from approve_record t5 where t5.data_id = t1.id and t5.passed = 1)!= 0 initiative, + if((select count(1) from approve_record t5 + where t5.data_id = t1.id and t5.passed = 1) != 0, 1, 3) initiative, t1.group_id group_id, t2.id customer_id, t1.origin_shop, @@ -44,7 +45,7 @@ SELECT t1.id, ifnull(t2.plate_no, t3.plate_no) plate_no, t1.type type, - t1.changed redistribution, + 0 redistribution, t1.origin_user user_id, t1.origin_shop shop_id, (select count(1) from follow_record t4 @@ -58,7 +59,8 @@ end state, t1.finish_time finish_time, t1.change_user_time defeat_time, - (select count(1) from approve_record t5 where t5.data_id = t1.id and t5.passed = 1)!= 0 initiative, + if((select count(1) from approve_record t5 + where t5.data_id = t1.id and t5.passed = 1) != 0, 1, 2) initiative, t1.group_id group_id, t2.id customer_id, t1.origin_shop, @@ -84,13 +86,13 @@ t1.follow_shop shop_id, (select count(1) from follow_record t4 where t4.task_id = t1.id - and t4.user_id = t1.finish_user + and t4.user_id = t1.follow_user and t4.follow_time is not null) times, TIMESTAMPDIFF(HOUR, now(), t1.deadline) remaining, 1 state, t1.finish_time finish_time, null defeat_time, - false initiative, + null initiative, t1.group_id group_id, t2.id customer_id, t1.origin_shop, diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/FollowPoolDTO.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/FollowPoolDTO.java index 765d733..971d7b4 100644 --- a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/FollowPoolDTO.java +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/FollowPoolDTO.java @@ -57,9 +57,9 @@ public class FollowPoolDTO { */ private Date defeatTime; /** - * 主动放弃 + * 战败类型 */ - private Boolean initiative; + private Integer initiative; /** * 集团id */ diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/FollowPoolBizService.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/FollowPoolBizService.java index a497346..70a2e14 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/FollowPoolBizService.java +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/FollowPoolBizService.java @@ -2,6 +2,7 @@ package cn.fw.valhalla.service.bus.follow; import cn.fw.common.page.AppPage; import cn.fw.common.web.auth.LoginAuthBean; +import cn.fw.valhalla.common.enums.DefeatTypeEnum; import cn.fw.valhalla.common.utils.DateUtil; import cn.fw.valhalla.common.utils.StringUtils; import cn.fw.valhalla.domain.db.PublicPool; @@ -116,18 +117,18 @@ public class FollowPoolBizService { if (Objects.nonNull(shop)) { vo.setShopName(shop.getShopName()); } - if (Boolean.TRUE.equals(poolDTO.getInitiative())) { - vo.setDefeatType("主动战败"); - } - if (poolDTO.getState() == 3 && Boolean.FALSE.equals(poolDTO.getInitiative())) { - vo.setDefeatType("到期划走"); + DefeatTypeEnum defeatTypeEnum = DefeatTypeEnum.ofValue(poolDTO.getInitiative()); + if (Objects.nonNull(defeatTypeEnum) && poolDTO.getState() == 3) { + vo.setDefeatType(defeatTypeEnum.getName()); } + if (Boolean.TRUE.equals(poolDTO.getFinished()) && !poolDTO.getOriginShop().equals(poolDTO.getFinishShop())) { vo.setDefeatDesc("集团内战败"); } - if (TaskStateEnum.END.getValue().equals(poolDTO.getOriginState()) && Boolean.FALSE.equals(poolDTO.getFinished())) { - vo.setDefeatDesc("集团外战败"); + if (poolDTO.getState() == 3 && DefeatTypeEnum.B.equals(defeatTypeEnum)) { + vo.setDefeatDesc("系统划走"); } + return vo; }