Explorar el Código

feat: 兑付通知逻辑更新

shc hace 7 meses
padre
commit
4f1e40c240

+ 3 - 0
doc/db/24wm_pkg_rdp.sql

@@ -19,6 +19,9 @@ CREATE TABLE `wm_pkg_rdp`
     `cur_rdp_rate`   VARCHAR(32)                                                    NOT NULL COMMENT '本次兑付比例',
     `cur_rdp_weight` VARCHAR(32)                                                    NOT NULL COMMENT '本次兑付权重',
     `notice_state`   VARCHAR(32)                                                    NOT NULL COMMENT '通知状态',
+    `check_state`    VARCHAR(32)                                                    NOT NULL COMMENT '审核状态(阶段)',
+    `check_result`   TINYINT(1)                                                     NULL COMMENT '审核结果',
+    `check_remarks`  VARCHAR(512)                                                   NULL COMMENT '审核结果信息',
     `accept`         TINYINT(1)                                                     NULL COMMENT '接受结果',
     `accept_remarks` VARCHAR(512)                                                   NULL COMMENT '接受说明',
     `accept_time`    DATETIME                                                       NULL COMMENT '接受时间',

+ 18 - 0
hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/dto/WmPkgDTO.java

@@ -49,6 +49,24 @@ public final class WmPkgDTO {
 
     }
 
+    @Data
+    public static class OnRedemptionNoticeLaunch {
+        @NotNull(message = "兑付通知ID必填")
+        private Integer redemptionNoticeId;
+    }
+
+    @Data
+    public static class OnRedemptionNoticeCheck {
+        @NotNull(message = "兑付通知ID必填")
+        private Integer redemptionNoticeId;
+
+        @NotNull(message = "审核结果必填")
+        private Boolean checkResult;
+
+        private String checkRemarks;
+    }
+
+
     @Data
     public static class OnRedemptionNoticeCreate {
 

+ 36 - 1
hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/entity/WmPackageRedemptionNotice.java

@@ -1,5 +1,6 @@
 package com.qunzhixinxi.hnqz.admin.api.entity;
 
+import com.baomidou.mybatisplus.annotation.EnumValue;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
@@ -54,8 +55,24 @@ public class WmPackageRedemptionNotice implements Serializable {
      * 通知状态
      */
     @TableField(value = "notice_state")
-    private String state;
+    private String noticeState;
 
+    // ~====== 审核阶段
+
+    /**
+     * 审核状态(阶段)
+     */
+    @TableField(value = "check_state")
+    private String checkState;
+
+    // 审核结果
+    private Boolean checkResult;
+
+    // 结果信息
+    private String checkRemarks;
+
+
+    // ~==== 服务商接受阶段
     private LocalDateTime acceptTime;
 
     private Boolean accept;
@@ -75,6 +92,7 @@ public class WmPackageRedemptionNotice implements Serializable {
     @AllArgsConstructor
     public enum NoticeState {
 
+        PENDING("PENDING", "待发送"),
         SEND("SEND", "发送"),
         READ("READ", "已读"),
         CONFIRM("CONFIRM", "确认"),
@@ -86,4 +104,21 @@ public class WmPackageRedemptionNotice implements Serializable {
         private final String description;
 
     }
+
+    @Getter
+    @AllArgsConstructor
+    public enum CheckState {
+
+        PASSED("PASSED", "审核通过"),
+        REJECTED("REJECTED", "审核拒绝"),
+        INIT("INIT", "待市场组审批"),
+        CKT1("CKT1", "待商务组审批"),
+        CKT2("CKT2", "待事业部分管销售领导审批"),
+        CKT3("CKT3", "待事业部总经理审批"),
+        CKT4("CKT4", "待分管领导审批");
+
+        @EnumValue
+        private final String state;
+        private final String desc;
+    }
 }

+ 12 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/controller/WmScorePackageController.java

@@ -3625,6 +3625,18 @@ public class WmScorePackageController {
         return R.ok(packageManager.createPackageRedemptionNotice(resource, SecurityUtils.getUser()));
     }
 
+    @SysLog(value = "生效兑付通知")
+    @PostMapping(value = "/redemption/notice/launch")
+    public R<Boolean> launchPackageRedemptionNotice(@Validated @RequestBody WmPkgDTO.OnRedemptionNoticeLaunch resource) {
+        return R.ok(packageManager.launchPackageRedemptionNotice(resource, SecurityUtils.getUser()));
+    }
+
+    @SysLog(value = "审核兑付通知")
+    @PostMapping(value = "/redemption/notice/check")
+    public R<Boolean> checkPackageRedemptionNotice(@Validated @RequestBody WmPkgDTO.OnRedemptionNoticeCheck resource) {
+        return R.ok(packageManager.checkPackageRedemptionNotice(resource, SecurityUtils.getUser()));
+    }
+
     @GetMapping(value = "/redemption/notice/page")
     public R<Page<Map<String, Object>>> pageRedemptionNotices(@Validated WmPkgDTO.OnRedemptionNoticePage query) {
         return R.ok(packageManager.pageRedemptionNotices(query, SecurityUtils.getUser()));

+ 84 - 8
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/manager/WmPackageManager.java

@@ -2,6 +2,7 @@ package com.qunzhixinxi.hnqz.admin.manager;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -22,10 +23,13 @@ import com.qunzhixinxi.hnqz.admin.service.WmTaskService;
 import com.qunzhixinxi.hnqz.admin.service.WmTaskTypeService;
 import com.qunzhixinxi.hnqz.common.core.exception.BizException;
 import com.qunzhixinxi.hnqz.common.security.service.HnqzUser;
+import com.qunzhixinxi.hnqz.common.security.util.SecurityUtils;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import java.time.LocalDateTime;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -47,6 +51,7 @@ import java.util.stream.Collectors;
 public class WmPackageManager {
 
 
+    private static final int BIZ_ADMIN_ROLE = 41;
     private static final int SERV_ADMIN_ROLE = 37;
     private static final int DIST_ADMIN_ROLE = 4;
     private static final int OK_CHAIN_TASK_NODE = 6;
@@ -89,23 +94,31 @@ public class WmPackageManager {
         Page<Map<String, Object>> res = new Page<>(query.getCurrent(), query.getSize());
 
         // 获取用户角色
-        Set<Integer> roleIds = userRoleService.list(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getUserId, user.getId()))
-                .stream().mapToInt(SysUserRole::getRoleId).boxed().collect(Collectors.toSet());
+        List<Integer> roles = SecurityUtils.getRoles();
+        // Set<Integer> roleIds = userRoleService.list(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getUserId, user.getId()))
+        //         .stream().mapToInt(SysUserRole::getRoleId).boxed().collect(Collectors.toSet());
 
         Page<WmPackageRedemptionNotice> page = new Page<>(query.getCurrent(), query.getSize());
         LambdaQueryWrapper<WmPackageRedemptionNotice> queryWrapper = Wrappers.lambdaQuery();
 
         // 根据用户角色判断是管理员还是服务商
         // 区域管理员
-        if (roleIds.contains(DIST_ADMIN_ROLE)) {
+        if (roles.contains(DIST_ADMIN_ROLE)) {
             queryWrapper.eq(WmPackageRedemptionNotice::getFromEntId, user.getDeptId()).eq(WmPackageRedemptionNotice::getCreateBy, user.getUsername());
         }
+        // 事业部分管领导
+        else if (roles.contains(BIZ_ADMIN_ROLE)) {
+            // 查询全部
+        }
         // 服务商
-        else if (roleIds.contains(SERV_ADMIN_ROLE)) {
-            queryWrapper.eq(WmPackageRedemptionNotice::getToEntId, user.getDeptId());
+        else if (roles.contains(SERV_ADMIN_ROLE)) {
+            queryWrapper
+                    .eq(WmPackageRedemptionNotice::getCheckState, WmPackageRedemptionNotice.CheckState.PASSED)
+                    .eq(WmPackageRedemptionNotice::getToEntId, user.getDeptId());
         } else {
             throw new BizException("角色不支持该数据查询");
         }
+
         packageRedemptionNoticeService.page(page, queryWrapper);
 
         List<WmPackageRedemptionNotice> records = page.getRecords();
@@ -206,9 +219,9 @@ public class WmPackageManager {
 
         int taskTotalCount = tasks.size();
         result.put("taskTotalCount", taskTotalCount);
-        result.put("servicePlanDeviationRate", "10%");
-        result.put("taskCompleteRate", String.format(".2f%d%%", okTasks.size() * 100 / ((taskTotalCount == 0) ? 1 : taskTotalCount)));
-        result.put("marketCustomerContactRate", "3%");
+        result.put("servicePlanDeviationRate", "10");
+        result.put("taskCompleteRate", String.format("%.2f", okTasks.size() * 100.0 / ((taskTotalCount == 0) ? 1 : taskTotalCount)));
+        result.put("marketCustomerContactRate", "3");
         result.put("fromEntId", scorePackage.getSendPackageDeptId());
         result.put("toEntId", scorePackage.getDeptId());
 
@@ -264,5 +277,68 @@ public class WmPackageManager {
 
 
     }
+
+    /**
+     * 生效兑付同种
+     *
+     * @param resource 生效信息
+     * @param user     操作人
+     * @return 操作结果
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean launchPackageRedemptionNotice(WmPkgDTO.OnRedemptionNoticeLaunch resource, HnqzUser user) {
+
+        WmPackageRedemptionNotice notice = new WmPackageRedemptionNotice();
+        notice.setNoticeId(resource.getRedemptionNoticeId());
+        notice.setCheckState(WmPackageRedemptionNotice.CheckState.CKT2.getState());
+        notice.setUpdateBy(user.getUsername());
+        notice.setUpdateTime(LocalDateTime.now());
+
+        return packageRedemptionNoticeService.updateById(notice);
+    }
+
+    /**
+     * 审核兑付通知
+     *
+     * @param resource 生效信息
+     * @param user     操作人
+     * @return 操作结果
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean checkPackageRedemptionNotice(WmPkgDTO.OnRedemptionNoticeCheck resource, HnqzUser user) {
+
+        Boolean checkResult = resource.getCheckResult();
+
+        WmPackageRedemptionNotice.NoticeState noticeState;
+        WmPackageRedemptionNotice.CheckState checkState;
+        String checkRemarks;
+
+        // 审核通过
+        if (checkResult){
+            noticeState = WmPackageRedemptionNotice.NoticeState.SEND;
+            checkState = WmPackageRedemptionNotice.CheckState.PASSED;
+            checkRemarks = StrUtil.isBlank(resource.getCheckRemarks()) ? "通过(系统追加)" : resource.getCheckRemarks();
+        }
+        // 审核不通过
+        else  {
+            noticeState = WmPackageRedemptionNotice.NoticeState.PENDING;
+            checkState = WmPackageRedemptionNotice.CheckState.REJECTED;
+            checkRemarks = resource.getCheckRemarks();
+        }
+
+
+        WmPackageRedemptionNotice notice = new WmPackageRedemptionNotice();
+        notice.setNoticeId(resource.getRedemptionNoticeId());
+
+        notice.setNoticeState(noticeState.getState());
+        notice.setCheckState(checkState.getState());
+        notice.setCheckResult(checkResult);
+        notice.setCheckRemarks(checkRemarks);
+        notice.setUpdateBy(user.getUsername());
+        notice.setUpdateTime(LocalDateTime.now());
+
+
+        return packageRedemptionNoticeService.updateById(notice);
+    }
 }
 

+ 5 - 4
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/WmPackageRedemptionNoticeServiceImpl.java

@@ -42,7 +42,8 @@ public class WmPackageRedemptionNoticeServiceImpl extends ServiceImpl<WmPackageR
         notice.setCurrentRedemptionScore(resource.getCurrentRedemptionScore());
         notice.setCurrentRedemptionRate(resource.getCurrentRedemptionRate());
         notice.setCurrentRedemptionWeight(resource.getCurrentRedemptionWeight());
-        notice.setState(WmPackageRedemptionNotice.NoticeState.SEND.getState());
+        notice.setNoticeState(WmPackageRedemptionNotice.NoticeState.PENDING.getState());
+        notice.setCheckState(WmPackageRedemptionNotice.CheckState.CKT2.getState());
         notice.setCreateBy(username);
         notice.setCreateTime(now);
         notice.setUpdateBy(username);
@@ -60,7 +61,7 @@ public class WmPackageRedemptionNoticeServiceImpl extends ServiceImpl<WmPackageR
     @Override
     public boolean hasRead(Integer packageId) {
         return this.count(Wrappers.<WmPackageRedemptionNotice>lambdaQuery()
-                .eq(WmPackageRedemptionNotice::getPackageId, packageId).ne(WmPackageRedemptionNotice::getState, WmPackageRedemptionNotice.NoticeState.SEND.getState())) > 0;
+                .eq(WmPackageRedemptionNotice::getPackageId, packageId).ne(WmPackageRedemptionNotice::getNoticeState, WmPackageRedemptionNotice.NoticeState.SEND.getState())) > 0;
     }
 
     @Override
@@ -70,7 +71,7 @@ public class WmPackageRedemptionNoticeServiceImpl extends ServiceImpl<WmPackageR
 
         WmPackageRedemptionNotice notice = new WmPackageRedemptionNotice();
         notice.setNoticeId(resource.getNoticeId());
-        notice.setState(WmPackageRedemptionNotice.NoticeState.READ.getState());
+        notice.setNoticeState(WmPackageRedemptionNotice.NoticeState.READ.getState());
         notice.setUpdateBy(user.getUsername());
         notice.setUpdateTime(LocalDateTime.now());
 
@@ -85,7 +86,7 @@ public class WmPackageRedemptionNoticeServiceImpl extends ServiceImpl<WmPackageR
         WmPackageRedemptionNotice notice = new WmPackageRedemptionNotice();
         notice.setNoticeId(resource.getNoticeId());
         notice.setAccept(accept);
-        notice.setState(accept ? WmPackageRedemptionNotice.NoticeState.CONFIRM.getState() : WmPackageRedemptionNotice.NoticeState.ARGUE.getState());
+        notice.setNoticeState(accept ? WmPackageRedemptionNotice.NoticeState.CONFIRM.getState() : WmPackageRedemptionNotice.NoticeState.ARGUE.getState());
         notice.setAcceptRemarks(resource.getRemarks());
         notice.setAcceptTime(LocalDateTime.now());
         notice.setUpdateBy(user.getUsername());