diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/PostUserVO.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/PostUserVO.java new file mode 100644 index 0000000..51e1bcd --- /dev/null +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/PostUserVO.java @@ -0,0 +1,26 @@ +package cn.fw.valhalla.domain.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author kurisu + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class PostUserVO implements Serializable { + private static final long serialVersionUID = -6108591548534160179L; + /** + * 用户id + */ + private Long userId; + + /** + * 用户姓名 + */ + private String userName; +} diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/setting/SettingVO.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/setting/SettingVO.java index 2c79185..9faf445 100644 --- a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/setting/SettingVO.java +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/setting/SettingVO.java @@ -1,6 +1,7 @@ package cn.fw.valhalla.domain.vo.setting; import cn.fw.valhalla.domain.db.setting.FollowSettingDetail; +import cn.fw.valhalla.domain.enums.SettingTypeEnum; import lombok.Data; import lombok.ToString; @@ -40,6 +41,9 @@ public class SettingVO { SettingVO vo = new SettingVO(); vo.setId(detail.getId()); vo.setDetailValue(detail.getDetailValue()); + if (SettingTypeEnum.REVISE_RATIO.equals(detail.getType())) { + vo.setDetailValue(detail.getDetailValue() / 100); + } vo.setSettingId(detail.getSettingId()); vo.setType(detail.getType().getValue()); vo.setUnit(detail.getUnit().getValue()); diff --git a/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/app/CommonController.java b/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/app/CommonController.java new file mode 100644 index 0000000..8fd44a8 --- /dev/null +++ b/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/app/CommonController.java @@ -0,0 +1,57 @@ +package cn.fw.valhalla.controller.app; + +import cn.fw.data.base.domain.common.Message; +import cn.fw.security.auth.client.annotation.Authorization; +import cn.fw.security.auth.client.annotation.IgnoreAuth; +import cn.fw.security.auth.client.enums.AuthType; +import cn.fw.valhalla.domain.vo.PostUserVO; +import cn.fw.valhalla.service.bus.CommonService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.constraints.NotNull; +import java.util.List; + +import static cn.fw.common.web.util.ExceptionHandler.handleException; +import static cn.fw.common.web.util.ResultBuilder.failureWithMessage; +import static cn.fw.common.web.util.ResultBuilder.success; +import static cn.fw.valhalla.common.constant.MessageStr.SAVE_FAILURE; + +/** + * @author : kurisu + * @className : CommonController + * @description : 公共接口 + * @date: 2020-10-22 11:06 + */ +@Slf4j +@RestController +@Authorization(AuthType.APP) +@Validated +@IgnoreAuth +@RequestMapping("/app/common") +public class CommonController { + private final CommonService commonService; + + @Autowired + public CommonController(final CommonService commonService) { + this.commonService = commonService; + } + + @GetMapping("/staff/list") + public Message> save(@NotNull(message = "服务站ID不能为空") final Long shopId, + @NotNull(message = "跟进类型ID不能为空") final Integer type) { + final String msg = "查询跟进人员[app/common/staff/list]"; + try { + log.info("{}: param[shopId: {} type: {}]", msg, shopId, type); + List list = commonService.getUsers(shopId, type); + return success(list, data -> log.info("{}", data)); + } catch (Exception ex) { + handleException(ex, e -> log.error("{}失败:param[shopId: {} type: {}]", msg, shopId, type, e)); + return failureWithMessage(SAVE_FAILURE); + } + } +} diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/CommonService.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/CommonService.java new file mode 100644 index 0000000..2367dd3 --- /dev/null +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/CommonService.java @@ -0,0 +1,52 @@ +package cn.fw.valhalla.service.bus; + +import cn.fw.valhalla.common.constant.RoleCode; +import cn.fw.valhalla.domain.enums.FollowTypeEnum; +import cn.fw.valhalla.domain.vo.PostUserVO; +import cn.fw.valhalla.rpc.erp.UserService; +import cn.fw.valhalla.rpc.erp.dto.PostUserDTO; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +import static cn.fw.common.businessvalidator.Validator.BV; + +/** + * @author : kurisu + * @className : CommonService + * @description : 公共服务 + * @date: 2020-10-22 11:07 + */ +@Service +@Slf4j +public class CommonService { + private final UserService userService; + + @Autowired + public CommonService(final UserService userService) { + this.userService = userService; + } + + public List getUsers(final Long shopId, final Integer type) { + FollowTypeEnum typeEnum = FollowTypeEnum.ofValue(type); + BV.notNull(typeEnum, () -> "跟进类型错误"); + List userByRole = userService.getUserByRole(shopId, getRoleCode(typeEnum)); + return userByRole.stream().map(user -> new PostUserVO(user.getUserId(), user.getUserName())).collect(Collectors.toList()); + } + + private String getRoleCode(FollowTypeEnum followTypeEnum) { + switch (followTypeEnum) { + case AC: + return RoleCode.SGCGJ; + case IR: + return RoleCode.XBGJ; + case FM: + case RM: + default: + return RoleCode.FWGW; + } + } +} diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/setting/strategy/AbstractSettingStrategy.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/setting/strategy/AbstractSettingStrategy.java index 0297a6c..b2fa292 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/setting/strategy/AbstractSettingStrategy.java +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/setting/strategy/AbstractSettingStrategy.java @@ -148,6 +148,9 @@ public abstract class AbstractSettingStrategy implements SettingStrategy { detail.setSettingId(setting.getId()); detail.setId(settingDTO.getId()); detail.setDetailValue(settingDTO.getDetailValue()); + if (SettingTypeEnum.REVISE_RATIO.getValue().equals(settingDTO.getType())) { + detail.setDetailValue(settingDTO.getDetailValue() * 100); + } detail.setType(SettingTypeEnum.ofValue(settingDTO.getType())); detail.setUnit(SettingUnitEnum.ofValue(settingDTO.getUnit())); detail.setYn(Boolean.TRUE); @@ -263,6 +266,7 @@ public abstract class AbstractSettingStrategy implements SettingStrategy { /** * 防重锁 + * * @param groupId * @param type * @return