分发员分发修改(合代码,未测)

master
yqy 10 months ago
parent ed8571b535
commit 131ecaed5d

@ -0,0 +1,7 @@
package com.baiye.validation.group;
/**
* Validation Group
*/
public interface SubmitGroup {
}

@ -21,6 +21,7 @@ import com.baiye.security.util.SecurityUtils;
import com.baiye.system.checker.AdminUserChecker;
import com.baiye.system.service.SysUserService;
import com.baiye.validation.group.CreateGroup;
import com.baiye.validation.group.SubmitGroup;
import com.baiye.validation.group.UpdateGroup;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -73,20 +74,12 @@ public class CustomController {
return customService.update(customDTO) ? R.ok() : R.failed(BaseResultCode.UPDATE_DATABASE_ERROR, "修改失败");
}
@GetMapping("/details")
@Operation(summary = "ID查询详情")
public R<CustomVO> getClueDetails(@RequestParam("id") Long id) {
return R.ok(customService.details(id));
}
/**
*
*
* @param id id
* @return
*/
@DeleteMapping("/{id}")
@DeleteOperationLogging(msg = "删除表单信息")
@Operation(summary = "通过id删除系统角色", description = "通过id删除系统角色")
@ -95,16 +88,10 @@ public class CustomController {
return Boolean.TRUE.equals(result) ? R.ok() : R.failed(BaseResultCode.UPDATE_DATABASE_ERROR, "删除表单失败");
}
/**
*
*
* @param dto
* @return
*/
@PostMapping("/audit")
@Operation(summary = "审核表单")
public R<String> audit(@Validated({UpdateGroup.class}) @RequestBody ChangeCustomDTO dto) {
Boolean result = customService.auditFormById(dto);
public R<String> audit(@Validated({SubmitGroup.class}) @RequestBody CustomDTO customDTO) {
Boolean result = customService.auditFormById(customDTO);
return Boolean.TRUE.equals(result) ? R.ok() : R.failed(BaseResultCode.UPDATE_DATABASE_ERROR, "审核失败");
}
@ -123,15 +110,8 @@ public class CustomController {
/**
*
*
* @param dto
* @return
*/
@PostMapping("/reAudit")
@Operation(summary = "审核表单")
@Operation(summary = "表单重审")
public R<Boolean> reAudit(@Validated({UpdateGroup.class}) @RequestBody ChangeCustomDTO dto) {
Boolean result = customService.reAuditFormById(dto);
return Boolean.TRUE.equals(result) ? R.ok() : R.failed(BaseResultCode.UPDATE_DATABASE_ERROR, "审核失败");

@ -3,6 +3,8 @@ package com.baiye.modules.distribute.dto;
import lombok.Builder;
import lombok.Data;
import java.util.List;
/**
* @author Enzo
* @date : 2023/12/7
@ -27,6 +29,6 @@ public class CallbackCustomDTO {
private Long distributeId;
private String identifying;
private List<String> identifying;
}

@ -1,19 +1,33 @@
package com.baiye.modules.distribute.dto;
import com.baiye.validation.group.SubmitGroup;
import lombok.Data;
/**
* @author Enzo
* @date
*/
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
public class ChangeCustomDTO {
/**
* ID
*/
@NotNull(message = "ID不能为空", groups = { SubmitGroup.class })
private Long customId;
/**
* : 0- 1- 2-
*/
@NotNull(message = "状态不能为空", groups = { SubmitGroup.class })
private Integer status;
/**
* ID
*/
private Long reviewUserId;
/**
* ID
*/
private List<Long> salesmanUserIdList;
}

@ -1,7 +1,9 @@
package com.baiye.modules.distribute.dto;
import com.baiye.extend.mybatis.plus.converter.JsonStringArrayTypeHandler;
import com.baiye.modules.distribute.entity.LabelEntity;
import com.baiye.validation.group.UpdateGroup;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
@ -11,10 +13,6 @@ import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @Author YQY
* @Date 2023/8/10
*/
@Data
@Builder
@AllArgsConstructor
@ -60,16 +58,45 @@ public class ClueDTO {
@Schema(title = "资源线索名称")
private String clueStageName;
@Schema(title = "创建者")
private Long createBy;
@Schema(title = "资源线索ID")
private Boolean isNewClue;
@Schema(title = "资源标签集合")
private List<LabelEntity> clueLabelList;
@Schema(title = "公司管理员用户ID")
private Long companyId;
@Schema(title = "性别(0-男1-女)")
private Integer sex;
@Schema(title = "客户资料")
private String customInformation;
@TableField(value = "channel_identifying", typeHandler = JsonStringArrayTypeHandler.class)
@Schema(title = "渠道标识")
private List<String> channelIdentifying;
@Schema(title = "渠道类型渠道类型(1 手动创建 2文件上传 3飞鱼回传 4话单回传 5 api回传)")
private Integer channelType;
public ClueDTO(Long clueId, String originName, String nid, String remark, String otherClue, Long assignedBy, String assignedName, Long createBy, Boolean isNewClue, Long companyId, Integer sex, String customInformation, List<String> channelIdentifying, Integer channelType) {
this.clueId = clueId;
this.originName = originName;
this.nid = nid;
this.remark = remark;
this.otherClue = otherClue;
this.assignedBy = assignedBy;
this.assignedName = assignedName;
this.createBy = createBy;
this.isNewClue = isNewClue;
this.companyId = companyId;
this.sex = sex;
this.customInformation = customInformation;
this.channelIdentifying = channelIdentifying;
this.channelType = channelType;
}
}

@ -2,6 +2,7 @@ package com.baiye.modules.distribute.dto;
import com.baiye.modules.distribute.entity.CustomStoreEntity;
import com.baiye.validation.group.CreateGroup;
import com.baiye.validation.group.SubmitGroup;
import com.baiye.validation.group.UpdateGroup;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@ -14,7 +15,7 @@ import java.util.List;
public class CustomDTO {
@Schema(title = "ID")
@NotNull(message = "ID不能为空", groups = { UpdateGroup.class })
@NotNull(message = "ID不能为空", groups = { UpdateGroup.class, SubmitGroup.class })
private Long customId;
@Schema(title = "客户名称")
@ -60,12 +61,28 @@ public class CustomDTO {
@Schema(title = "创建人")
private Long createBy;
@Schema(title = "客户资料")
private String customInformation;
@Schema(title = "渠道类型(1 手动创建 2文件上传 3飞鱼回传 4话单回传 5 api回传)")
private Integer channelType;
@Schema(title = "渠道名称")
private String channelName;
@Schema(title = "复审员id")
private Long reviewUserId;
@Schema(title = "分发员id")
private Long distributorId;
@Schema(title = "性别(0-男1-女)")
private Integer sex;
@Schema(title = "业务员用户ID")
private List<Long> salesmanUserIdList;
@Schema(title = "分发员分发时状态:0-地理分发 1-基础分发 2-复审")
@NotNull(message = "状态不能为空", groups = { SubmitGroup.class })
private Integer status;
}

@ -2,14 +2,17 @@ package com.baiye.modules.distribute.entity;
import com.baiye.entity.LogicDeletedBaseEntity;
import com.baiye.extend.mybatis.plus.alias.TableAlias;
import com.baiye.extend.mybatis.plus.converter.JsonStringArrayTypeHandler;
import com.baiye.validation.group.UpdateGroup;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.validation.constraints.NotNull;
import java.util.List;
@Getter
@Setter
@ -41,33 +44,46 @@ public class ClueEntity extends LogicDeletedBaseEntity {
@Schema(title = "记录ID")
private Long clueRecordId;
@Schema(title = "其它线索(jsonStr格式)")
private String otherClue;
@Schema(title = "分配人用户ID")
private Long assignedBy;
@Schema(title = "资源标签")
private String clueLabel;
@Schema(title = "资源标签名称")
private String clueLabelName;
@Schema(title = "分配人用户名")
private String assignedName;
@Schema(title = "分发员id")
private Long distributorId;
@Schema(title = "资源标签关联ID")
private String clueLabel;
@Schema(title = "资源线索ID")
@Schema(title = "资源所打标签信息(jsonStr格式)")
private String clueLabelName;
@Schema(title = "资源阶段关联ID")
private Long clueStageId;
@Schema(title = "资源所打的阶段名称")
private String clueStageName;
@Schema(title = "资源线索ID")
private Boolean isNewClue;
@Schema(title = "资源线索名称")
private String clueStageName;
@Schema(title = "太空猫传递的线索ID")
private Long variable;
@Schema(title = "公司管理员用户ID")
private Long companyId;
@Schema(title = "性别(0-男1-女)")
private Integer sex;
@Schema(title = "客户资料")
private String customInformation;
@TableField(value = "channel_identifying", typeHandler = JsonStringArrayTypeHandler.class)
@Schema(title = "渠道标识")
private List<String> channelIdentifying;
@Schema(title = "渠道类型渠道类型(1 手动创建 2文件上传 3飞鱼回传 4话单回传 5 api回传)")
private Integer channelType;
}

@ -2,8 +2,10 @@ package com.baiye.modules.distribute.entity;
import com.baiye.entity.BaseEntity;
import com.baiye.extend.mybatis.plus.alias.TableAlias;
import com.baiye.extend.mybatis.plus.converter.JsonStringArrayTypeHandler;
import com.baiye.validation.group.CreateGroup;
import com.baiye.validation.group.UpdateGroup;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
@ -13,6 +15,7 @@ import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
/**
* @author Enzo
@ -105,6 +108,11 @@ public class CustomEntity extends BaseEntity {
@Schema(title = "渠道名称")
private String channelName;
@TableField(value = "channel_identifying", typeHandler = JsonStringArrayTypeHandler.class)
@Schema(title = "渠道标识")
private String channelIdentifying;
private List<String> channelIdentifying;
@TableField(value = "salesman_user_id", typeHandler = JsonStringArrayTypeHandler.class)
@Schema(title = "业务员ID集合")
private List<String> salesmanUserId;
}

@ -17,23 +17,16 @@ public interface CustomService extends ExtendService<CustomEntity> {
/**
*
* @param pageParam
* @param qo
* @return
*/
PageResult<CustomVO> queryPage(PageParam pageParam, CustomQo qo);
/**
*
* @param customDTO
* @return
*/
boolean add(CustomDTO customDTO);
/**
*
* @param customDTO
* @return
*/
boolean update(CustomDTO customDTO);
@ -45,23 +38,17 @@ public interface CustomService extends ExtendService<CustomEntity> {
/**
*
* @param id
* @return
*/
Boolean deleteApprovalFormById(Long id);
/**
*
* @param dto
* @return
*/
Boolean auditFormById(ChangeCustomDTO dto);
Boolean auditFormById(CustomDTO customDTO);
/**
*
* @param dto
* @return
*/
Boolean reAuditFormById(ChangeCustomDTO dto);

@ -30,6 +30,7 @@ import com.baiye.system.constant.LetterConst;
import com.baiye.system.enums.RoleCodeEnum;
import com.baiye.system.model.entity.SysUser;
import com.baiye.system.service.SysUserRoleService;
import com.baiye.system.model.entity.SysUser;
import com.baiye.system.service.SysUserService;
import com.baiye.util.AESUtils;
import com.baiye.utils.SerialCode;
@ -158,50 +159,71 @@ public class CustomServiceImpl extends ExtendServiceImpl<CustomMapper, CustomEnt
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean auditFormById(ChangeCustomDTO dto) {
Long id = dto.getCustomId();
Integer status = dto.getStatus();
CustomEntity customEntity = baseMapper.selectById(id);
public Boolean auditFormById(CustomDTO customDTO) {
Long customId = customDTO.getCustomId();
Integer status = customDTO.getStatus();
List<Long> salesmanUserIdList = customDTO.getSalesmanUserIdList();
Long reviewUserId = customDTO.getReviewUserId();
Long currentUserId = SecurityUtils.getCurrentUserId();
CustomEntity updateCustomEntity = CustomConverter.INSTANCE.dtoToPo(customDTO);
List<ClueDTO> list = Lists.newArrayList();
CustomEntity customEntity = baseMapper.selectById(customId);
if (ObjectUtil.isNotNull(customEntity)) {
if (ObjectUtil.isNotNull(status) && status == 0) {
if (ObjectUtil.isNull(dto.getReviewUserId())) {
throw new BadRequestException("复审员不能为空!");
}
customEntity.setType(3);
customEntity.setReviewUserId(dto.getReviewUserId());
return SqlHelper.retBool(baseMapper.updateById(customEntity));
}
Gson gson = new Gson();
AddressDTO address = new AddressDTO();
List<ClueDTO> list = Lists.newArrayList();
BeanUtils.copyProperties(customEntity, address);
address.setCustomerName(customEntity.getCustomName());
String otherClue = gson.toJson(address);
List<CustomStoreEntity> customStores = customStoreService.selectListByCustomId(id);
if (CollUtil.isNotEmpty(customStores)) {
for (CustomStoreEntity store : customStores) {
// 雪花算法id
Long clueId = IdUtil.getSnowflake(workerId, datacenterId).nextId();
StoreUserDTO entity = storeUserService.findUserIdByStoreId(store.getStoreId());
if (ObjectUtil.isNotNull(entity) && ObjectUtil.isNotNull(entity.getUserId())) {
// 扣减余额
Boolean result = sysUserService.deductionQuantity(entity.getUserId(), entity.getStoreName());
if (Boolean.TRUE.equals(result)) {
ClueDTO clueDTO = ClueDTO.builder().originName(ClueSourceEnum.STORE_DISTRIBUTION.getDescription()).clueId(clueId).remark
(customEntity.getRemark()).nid(AESUtils.encrypt(customEntity.getCustomNid(), securityProperties.getPasswordSecretKey())).assignedBy
(entity.getUserId()).createBy(customEntity.getCompanyId()).assignedName(store.getStoreName()).otherClue(otherClue).isNewClue(Boolean.TRUE).build();
list.add(clueDTO);
String phone = AESUtils.encrypt(customEntity.getCustomNid(), securityProperties.getPasswordSecretKey());
Long companyId = customEntity.getCompanyId();
if (status == 0) {
Gson gson = new Gson();
AddressDTO address = new AddressDTO();
BeanUtils.copyProperties(customEntity, address);
address.setCustomerName(customEntity.getCustomName());
String otherClue = gson.toJson(address);
List<CustomStoreEntity> customStores = customStoreService.selectListByCustomId(customId);
if (CollUtil.isNotEmpty(customStores)) {
for (CustomStoreEntity store : customStores) {
Long clueId = IdUtil.getSnowflake(workerId, datacenterId).nextId();
StoreUserDTO entity = storeUserService.findUserIdByStoreId(store.getStoreId());
if (ObjectUtil.isNotNull(entity) && ObjectUtil.isNotNull(entity.getUserId())) {
String username = sysUserService.findById(entity.getUserId()).getUsername();
// 扣减余额
Boolean result = sysUserService.deductionQuantity(entity.getUserId(), entity.getStoreName());
if (Boolean.TRUE.equals(result)) {
ClueDTO clueDTO = new ClueDTO(clueId, ClueSourceEnum.STORE_DISTRIBUTION.getDescription(), phone, updateCustomEntity.getRemark(),
otherClue, entity.getUserId(), username, currentUserId, Boolean.TRUE, companyId, updateCustomEntity.getSex(),
customEntity.getCustomInformation(), customEntity.getChannelIdentifying(), customEntity.getChannelType());
list.add(clueDTO);
}
}
}
}
if (CollUtil.isNotEmpty(list)) {
// 扣减数量
customEntity.setEnrollStatus(2);
clueService.saveClueListByStoreInfo(list);
customEntity.setDistributeTime(DateUtil.date());
customEntity.setUpdateTime(LocalDateTime.now());
return SqlHelper.retBool(baseMapper.updateById(customEntity));
} else if (status == 1) {
if (CollUtil.isEmpty(salesmanUserIdList)) throw new BadRequestException("下发人员不能为空!");
Map<Long, List<SysUser>> listMap = sysUserService.listByUserIds(salesmanUserIdList).stream().collect(Collectors.groupingBy(SysUser::getUserId));
for (Long userId : salesmanUserIdList) {
String username = listMap.get(userId).get(0).getUsername();
// 扣减余额
Boolean result = sysUserService.deductionQuantity(userId, null);
if (Boolean.TRUE.equals(result)) {
Long clueId = IdUtil.getSnowflake(workerId, datacenterId).nextId();
ClueDTO clueDTO = new ClueDTO(clueId, customEntity.getChannelName(), phone, updateCustomEntity.getRemark(), null, userId,
username, currentUserId, Boolean.TRUE, companyId, updateCustomEntity.getSex(), customEntity.getCustomInformation(),
customEntity.getChannelIdentifying(), customEntity.getChannelType());
list.add(clueDTO);
}
}
} else {
if (reviewUserId != null) throw new BadRequestException("复审员不能为空!");
updateCustomEntity.setType(3);
updateCustomEntity.setReviewUserId(customDTO.getReviewUserId());
return SqlHelper.retBool(baseMapper.updateById(updateCustomEntity));
}
// 扣减数量,插入资源
if (CollUtil.isNotEmpty(list)) {
updateCustomEntity.setEnrollStatus(2);
clueService.saveClueListByStoreInfo(list);
updateCustomEntity.setDistributeTime(DateUtil.date());
updateCustomEntity.setUpdateTime(LocalDateTime.now());
return SqlHelper.retBool(baseMapper.updateById(updateCustomEntity));
}
}
return Boolean.FALSE;
@ -279,7 +301,6 @@ public class CustomServiceImpl extends ExtendServiceImpl<CustomMapper, CustomEnt
}
/**
*
*/

@ -217,7 +217,7 @@ public class OceanEngineClueServiceImpl extends ExtendServiceImpl<OceanEngineSou
QueueBalance<Long> balance = new QueueBalance<>();
Long distributeId = balance.chooseOne(userList);
CallbackCustomDTO customDTO = CallbackCustomDTO.builder().channelType(DefaultNumberConstants.THREE_NUMBER).customNid
(phone).customName(name).distributeId(distributeId).identifying(JSONUtil.toJsonStr(pushLinkEntity.getChannelIdentifying())).reportUserId(userId).remark
(phone).customName(name).distributeId(distributeId).identifying(pushLinkEntity.getChannelIdentifying()).reportUserId(userId).remark
(jsonStr).companyId(byId.getWhichUserId()).enterName(byId.getUsername()).build();
dtoList.add(customDTO);
}

@ -114,7 +114,7 @@ public class TripartiteServiceImpl implements TripartiteService {
}
SysUser byId = sysUserService.findById(reportUserId);
CallbackCustomDTO customDTO = CallbackCustomDTO.builder().channelType(DefaultNumberConstants.FOUR_NUMBER).customNid
(phone).distributeId(distributeId).identifying(JSONUtil.toJsonStr(channelIdentifying)).reportUserId(reportUserId).remark(remark).companyId
(phone).distributeId(distributeId).identifying(channelIdentifying).reportUserId(reportUserId).remark(remark).companyId
(byId.getWhichUserId()).enterName(byId.getUsername()).build();
// 插入资源表

Loading…
Cancel
Save