fwq
2023-12-14 80fecc709867475518eec90c132c4770366929b2
诉求分类填充
2个文件已修改
86 ■■■■ 已修改文件
phi_platform_common/src/main/java/com/hx/phip/tool/AppealTypeTool.java 59 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/util/api/OrderCreateUtil.java 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_common/src/main/java/com/hx/phip/tool/AppealTypeTool.java
@@ -2,7 +2,6 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hx.common.service.CommonService;
import com.hx.mybatisTool.SqlSentence;
import com.hx.phiappt.model.appeal.AppealType;
@@ -22,14 +21,10 @@
 */
public class AppealTypeTool {
    public static void orderProjectInsert(String orderId, String orderItemId, List<String> appealTypeIdList, CommonService commonService){
        if(appealTypeIdList == null || appealTypeIdList.size() < 1){
    public static void orderProjectInsert(String orderId, String orderItemId, List<AppealTypeVo> appealTypeVoList, CommonService commonService){
        if(appealTypeVoList == null || appealTypeVoList.size() < 1){
            return;
        }
        List<AppealTypeVo> appealTypeVoList = getAppealTypeListByIdList(appealTypeIdList, commonService);
        OrderAppealType orderAppeelType;
        for(AppealTypeVo appealTypeVo : appealTypeVoList){
            orderAppeelType = new OrderAppealType();
@@ -99,6 +94,56 @@
        return arr;
    }
    /**
     * 拼接诉求分类名称
     * 此方法只支持一二三级都只是一个的
     * */
    public static String getStr(List<AppealTypeVo> appealTypeVoList) {
        //父级标识
        String parenId = "";
        //二级名称拼接
        StringBuilder towName = new StringBuilder();
        //三级名称拼接
        StringBuilder threeName = new StringBuilder();
        //父级标识,当前数据
        Map<String,AppealTypeVo> parentMap = new HashMap<>();
        //循环
        for (AppealTypeVo appealTypeVo : appealTypeVoList) {
            if (StringUtils.isEmpty(appealTypeVo.getParentId())){
                parenId = appealTypeVo.getId();
                towName.append(appealTypeVo.getName());
                threeName.append(appealTypeVo.getName());
            }else {
                parentMap.put(appealTypeVo.getParentId(),appealTypeVo);
            }
        }
        //二级
        AppealTypeVo secondVo = parentMap.get(parenId);
        if (secondVo != null){
            if (towName.length() > 0){
                towName.append("/").append(secondVo.getName());
            }
            if (threeName.length() > 0){
                threeName.append("/").append(secondVo.getName());
            }
            //三级
            AppealTypeVo thirdVo = parentMap.get(secondVo.getId());
            if (thirdVo != null){
                if (towName.length() > 0){
                    towName.append("/").append(thirdVo.getName());
                }
                if (threeName.length() > 0){
                    threeName.append("/").append(thirdVo.getName());
                }
            }
        }
        return towName.append("-").append(threeName).toString();
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////
phi_platform_user/src/main/java/com/hx/phip/util/api/OrderCreateUtil.java
@@ -71,6 +71,7 @@
import com.hx.phip.tool.AppealTypeTool;
import com.hx.phip.tool.CreateNo;
import com.hx.phip.tool.user.UserCardTool;
import com.hx.phip.vo.AppealTypeVo;
import com.hx.phip.vo.user.UserCardItemInfoVo;
import com.hx.resultTool.Result;
import com.hx.util.DateUtil;
@@ -1769,11 +1770,31 @@
            //计算折扣金额
            vo.setDiscountOrderPrice(vo.getProPrice().multiply(BigDecimal.valueOf(vo.getBuyNum()).setScale(2,RoundingMode.HALF_UP)).subtract(vo.getTotal()));
            vo.setOrderId(ordersTotal.getId());
            commonService.insert(OrderItemMapper.class, vo);
            //述求分类生成,目前项目
            //诉求分类
            List<AppealTypeVo> appealTypeVoList = null;
            if (OrderItemConstants.TYPE_PROJECT.equals(vo.getType())) {
                AppealTypeTool.orderProjectInsert(ordersTotal.getId(), vo.getId(), vo.getAppealTypeIdList() ,commonService);
                //获取诉求分类列表
                appealTypeVoList = AppealTypeTool.getAppealTypeListByIdList(vo.getAppealTypeIdList(), commonService);
            }
            if (appealTypeVoList != null && appealTypeVoList.size() > 0) {
                String str = AppealTypeTool.getStr(appealTypeVoList);
                if (StringUtils.noNull(str)) {
                    String[] split = str.split("-");
                    for (int i = 0; i < split.length; i++) {
                        if (i == 0) {
                            vo.setAppealSecond(split[i]);
                        } else if (i == 1) {
                            vo.setAppealThird(split[i]);
                        }
                    }
                }
            }
            commonService.insert(OrderItemMapper.class, vo);
            //述求分类生成,目前项目
            if (appealTypeVoList != null && appealTypeVoList.size() > 0){
                //生成关联关系
                AppealTypeTool.orderProjectInsert(ordersTotal.getId(), vo.getId(), appealTypeVoList, commonService);
            }
            map.put("commonId", vo.getCommonId());