chenjiahe
2024-01-29 4452e145316d3eb27cff26475a8e146e240cc789
再生俱乐部提交
4个文件已修改
191 ■■■■■ 已修改文件
phi_platform_common/src/main/java/com/hx/phip/AutoDomeUtil.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_common/src/main/java/com/hx/phip/service/tool/club/UserCluebMemberServiceTool.java 177 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_common/src/main/resources/mapper/platform/MarketSystemMapper.xml 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/order/impl/OrderRefundServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_common/src/main/java/com/hx/phip/AutoDomeUtil.java
@@ -46,7 +46,7 @@
        urlData.serviceImplUrlData(controllerPackRoot,packageName + ".service.impl");
        urlData.mapperUrlData(commonPackRootResourse, "mapper.platform");
        Class<?> clas = UserClubMember.class;
        Class<?> clas = MarketSystem.class;
        //dao
         GeneratorUtil.generatorDao(clas,urlData);
        //mapper
phi_platform_common/src/main/java/com/hx/phip/service/tool/club/UserCluebMemberServiceTool.java
@@ -42,10 +42,12 @@
    /**校验结果-不参与规则*/
    public static final int RESULT_NOT_JOIN = 1;
    /**校验结果-有参与但没有疗程数*/
    public static final int RESULT_JOIN_NO_QUANTITY = 2;
    /**校验结果-符合规则*/
    public static final int RESULT_CONFORM = 2;
    public static final int RESULT_CONFORM = 3;
    /**校验结果-不符合规则*/
    public static final int RESULT_NON_CONFORM = 3;
    public static final int RESULT_NON_CONFORM = 4;
    /**订单下单结账校验是否符合会员条件
     * @param orderId 订单标识,与ordersTotal选一个,两个都有默认ordersTotal
@@ -99,7 +101,7 @@
            }
        }
        //开始校验是否符合规则
        if(commonChekMember(null,null,ordersTotal,marketSystem) == RESULT_CONFORM){
        if(commonChekMember(null,null,ordersTotal,marketSystem,null) == RESULT_CONFORM){
            //生成俱乐部会员
            createClubMember(UserClubMember.TYPE_REGENERATION,ordersTotal,marketSystem,userClubMemberService);
            return true;
@@ -174,52 +176,69 @@
            }
        }
        //当前退款的订单是在逻辑内的,但不符合规则
        if(commonChekMember(startTime,endTime,ordersTotal,marketSystem) == RESULT_NON_CONFORM){
        //校验结果结果
        int resultValue = commonChekMember(startTime,endTime,ordersTotal,marketSystem,userClubMember.getSourceId());
        if(resultValue == RESULT_CONFORM){
            //符合规则,那么就不用变更
            return;
        }else if(resultValue == RESULT_NOT_JOIN){
            //没有参与,那么就不用变更
            return;
        }else if(resultValue == RESULT_JOIN_NO_QUANTITY){
            //有参与但没有疗程数
            if(ordersTotal.getId().equals(userClubMember.getSourceId())){
                //当前的订单是当时生成该会员的订单
                //没有参与或者没有疗程数
                //不符合就作废会员信息
                userClubMemberService.cancelClubMember(UserClubMember.DISCARD_SOURCE_REFUND,refundId,ordersTotal.getId(),"订单退款",userClubMember);
            }
        }else if(resultValue == RESULT_NON_CONFORM){
            //不符合就作废会员信息
            userClubMemberService.cancelClubMember(UserClubMember.DISCARD_SOURCE_REFUND,refundId,ordersTotal.getId(),"订单退款",userClubMember);
            //重新算出符合的出来
            SqlSentence sqlSentence = new SqlSentence();
            Map<String,Object> values = new HashMap<>();
            StringBuilder sql = new StringBuilder();
        }
            int pageNum = 0;
            int pageSize = 10;
        //-----重新计算
        //重新算出符合的出来
        SqlSentence sqlSentence = new SqlSentence();
        Map<String,Object> values = new HashMap<>();
        StringBuilder sql = new StringBuilder();
            values.put("userId",ordersTotal.getId());
            sql.append("SELECT * FROM orders_total WHERE isDel = 0 AND userId = #{m.userId} AND status IN(2,3,9) AND payStatus = 3");
            if(startTime != null){
                values.put("startTime",startTime);
                sql.append(" AND payTime >= #{m.startTime}");
            }
            if(endTime != null){
                values.put("endTime",endTime);
                sql.append(" AND payTime <= #{m.endTime}");
            }
            sql.append(" ORDER BY payTime DESC LIMIT #{m.pageNum},#{m.pageSize}");
            sqlSentence.sqlSentence(sql.toString(),values);
        int pageNum = 0;
        int pageSize = 10;
            List<OrdersTotal> ordersTotalList;
            boolean result = false;
            while (true){
                values.put("pageNum",pageNum);
                values.put("pageSize",pageSize);
                ordersTotalList = commonService.selectList(OrdersTotalMapper.class,sqlSentence);
                for(OrdersTotal ordersTotal1:ordersTotalList){
                    //是否生成了会员,如果是,那么就跳出循环
                    result = orderChekMember(null,ordersTotal1,marketSystem,MarketSystem.TYPE_REGENERATION);
                    if(result){
                        break;
                    }
                }
        values.put("userId",ordersTotal.getUserId());
        sql.append("SELECT * FROM orders_total WHERE isDel = 0 AND userId = #{m.userId} AND status IN(2,3,9) AND payStatus = 3");
        if(startTime != null){
            values.put("startTime",startTime);
            sql.append(" AND payTime >= #{m.startTime}");
        }
        if(endTime != null){
            values.put("endTime",endTime);
            sql.append(" AND payTime <= #{m.endTime}");
        }
        sql.append(" ORDER BY payTime DESC LIMIT #{m.pageNum},#{m.pageSize}");
        sqlSentence.sqlSentence(sql.toString(),values);
        List<OrdersTotal> ordersTotalList;
        boolean result = false;
        while (true){
            values.put("pageNum",pageNum);
            values.put("pageSize",pageSize);
            ordersTotalList = commonService.selectList(OrdersTotalMapper.class,sqlSentence);
            for(OrdersTotal ordersTotal1:ordersTotalList){
                //是否生成了会员,如果是,那么就跳出循环
                result = orderChekMember(null,ordersTotal1,marketSystem,MarketSystem.TYPE_REGENERATION);
                if(result){
                    break;
                }
                if(ordersTotalList.size() < pageSize){
                    break;
                }
                pageNum = pageNum+pageSize;
            }
            if(result){
                break;
            }
            if(ordersTotalList.size() < pageSize){
                break;
            }
            pageNum = pageNum+pageSize;
        }
    }
@@ -253,13 +272,9 @@
            return;
        }else{
            //---已经存在会员了情况下,需要判断成为会员的时间了,可以作废退款这个比这个还要新
            MarketSystem marketSystem = commonService.selectOneByKey(MarketSystemMapper.class,userClubMember.getSourceOtherId());
            if(marketSystem == null){
                return;
            }
            if(userClubMember.getStartTime().getTime() < ordersTotal.getPayTime().getTime()){
                //重新生成会员
                orderChekMember(null,ordersTotal,marketSystem,MarketSystem.TYPE_REGENERATION);
                orderChekMember(null,ordersTotal,null,MarketSystem.TYPE_REGENERATION);
            }
        }
    }
@@ -269,8 +284,9 @@
     * @param endTime 规则内结束时间时间,不传以ordersTotal支付时间重新算
     * @param ordersTotal 当前订单
     * @param marketSystem 当前配置
     * @param memberOrderId 生成会员时候的订单标识,就是这个会员在生成的时候,是什么订单触发的
     */
    public int commonChekMember(Date startTime,Date endTime,OrdersTotal ordersTotal,MarketSystem marketSystem){
    public int commonChekMember(Date startTime,Date endTime,OrdersTotal ordersTotal,MarketSystem marketSystem,String memberOrderId){
        SqlSentence sqlSentence = new SqlSentence();
        Map<String,Object> values  = new HashMap<>();
@@ -307,8 +323,16 @@
        ChekCureVo chekCureVo = orderHandle(ordersTotal,skuNoSet,commonService);
        System.out.println("chekCureVo:"+JSON.toJSONString(chekCureVo));
        if(!chekCureVo.isCureProject()){
            //订单没有参与规则
            return RESULT_NOT_JOIN;
        }else{
            //订单是有参与订单规则的
            if(chekCureVo.getCureNum() <= 0 && ordersTotal.getId().equals(memberOrderId)){
                //有参与疗程数为0的时候且当前的订单是触发当时生成会员的订单
                return RESULT_JOIN_NO_QUANTITY;
            }
        }
        int cureNum = chekCureVo.getCureNum();
        //判断是否符合规则
        if(cureNum < marketSystem.getCureNum()){
@@ -391,6 +415,7 @@
                    chekCureVo.setCureNum(chekCureVo.getCureNum()+orderItem.getUsedTotal()-orderItem.getHasReNum());
                    chekCureVo.setCureProject(true);
                }
                System.out.println("项目:"+chekCureVo.getCureNum());
            }else if(OrderItemConstants.TYPE_PROMOTION.equals(orderItem.getType())){
                //---促销
                orderItemSonList = getOrderItemSonList(orderItem.getId(),OrderItemConstants.TYPE_PROJECT,commonService);
@@ -401,9 +426,11 @@
                        chekCureVo.setCureProject(true);
                    }
                }
                System.out.println("促销:"+chekCureVo.getCureNum());
            }else if(OrderItemConstants.TYPE_CARD.equals(orderItem.getType())){
                //---卡项,注意,不是卡包
                chekCureVo = handleCard(chekCureVo,orderItem,skuNoSet,commonService);
                System.out.println("卡项:"+chekCureVo.getCureNum());
            }
        }
        return chekCureVo;
@@ -427,9 +454,8 @@
        Map<String,Object> values = new HashMap<>();
        //获取未退款的用户卡包
        values.put("effectiveStatus", UserProjectConstants.EFF_STATUS_CANCEL);
        values.put("sourceId", orderItem.getId());
        sqlSentence.sqlSentence("SELECT id FROM user_card WHERE isDel = 0 AND effectiveStatus != #{m.effectiveStatus} AND sourceId = #{m.sourceId}",values);
        sqlSentence.sqlSentence("SELECT id,status,effectiveStatus FROM user_card WHERE isDel = 0 AND sourceId = #{m.sourceId}",values);
        List<UserCard> userCardList = commonService.selectList(UserCardMapper.class,sqlSentence);
        //获取还有的权益
@@ -469,7 +495,7 @@
        //存储已经算过的条目
        Set<String> NMSet;
        for(UserCard userCard:userCardList){
            System.out.println("userCard.getEffectiveStatus():"+userCard.getEffectiveStatus());
            //获取已退款的卡项条目次数
            values.clear();
            values.put("sourceType", UserCardUsed.SOURCE_TYPE_USER_CARD_REFUND);
@@ -514,13 +540,15 @@
                            //固定项目类型
                            if(cardItemInfo.getUserNum() != null){
                                //算单个条目的疗程总数
                                chekCureVo.setCureNum(chekCureVo.getCureNum()+cardItemInfo.getUserNum()*cardItemInfo.getMaxNum());
                                chekCureVo.setCureProject(true);
                                //退款的疗程总数
                                userCardUsedTotal = userCardUsedMap.get(cardItemInfo.getId());
                                if(userCardUsedTotal!= null){
                                    chekCureVo.setCureNum(chekCureVo.getCureNum() - userCardUsedTotal.getUsedNum()*cardItemInfo.getUserNum());
                                if(userCard.getEffectiveStatus() != UserProjectConstants.EFF_STATUS_CANCEL){
                                    chekCureVo.setCureNum(chekCureVo.getCureNum()+cardItemInfo.getUserNum()*cardItemInfo.getMaxNum());
                                    //退款的疗程总数
                                    userCardUsedTotal = userCardUsedMap.get(cardItemInfo.getId());
                                    if(userCardUsedTotal!= null){
                                        chekCureVo.setCureNum(chekCureVo.getCureNum() - userCardUsedTotal.getUsedNum()*cardItemInfo.getUserNum());
                                    }
                                }
                                chekCureVo.setCureProject(true);
                            }
                        }
                    }
@@ -539,17 +567,19 @@
                        }
                        if(skuNoSet.contains(cardItemInfo.getCommonCode())){
                            if(cardItemInfo.getUserNum() != null){
                                //计算可购买数量,注意,这不是抵扣次数,是可购买的项目数量
                                if(cardItemInfo.getEveryDrawNum() > 0){
                                    deductionNum = cardEquity.getValue()/cardItemInfo.getEveryDrawNum();
                                }else{
                                    deductionNum = 0;
                                if(userCard.getEffectiveStatus() != UserProjectConstants.EFF_STATUS_CANCEL){
                                    //计算可购买数量,注意,这不是抵扣次数,是可购买的项目数量
                                    if(cardItemInfo.getEveryDrawNum() > 0){
                                        deductionNum = cardEquity.getValue()/cardItemInfo.getEveryDrawNum();
                                    }else{
                                        deductionNum = 0;
                                    }
                                    //算出总疗程,并叠加到总规则总疗程里面
                                    chekCureVo.setCureNum(chekCureVo.getCureNum()+cardItemInfo.getUserNum()*deductionNum);
                                    //剩下划扣次数
                                    deductionSurp = deductionSurp - deductionNum*cardItemInfo.getEveryDrawNum();
                                }
                                //算出总疗程,并叠加到总规则总疗程里面
                                chekCureVo.setCureNum(chekCureVo.getCureNum()+cardItemInfo.getUserNum()*deductionNum);
                                chekCureVo.setCureProject(true);
                                //剩下划扣次数
                                deductionSurp = deductionSurp - deductionNum*cardItemInfo.getEveryDrawNum();
                            }
                        }
                    }
@@ -574,13 +604,14 @@
                        for(CardItemInfo cardItemInfo:cardItemInfoList){
                            if(cardItemInfo.getId().equals(entry.getValue().getCardItemInfoId())){
                                if(skuNoSet.contains(cardItemInfo.getCommonCode())){
                                    //算出总疗程,并叠加到总规则总疗程里面
                                    //退款的
                                    chekCureVo.setCureNum(chekCureVo.getCureNum()-entry.getValue().getUsedNum()*cardItemInfo.getUserNum());
                                    if(userCard.getEffectiveStatus() != UserProjectConstants.EFF_STATUS_CANCEL){
                                        //算出总疗程,并叠加到总规则总疗程里面
                                        //退款的
                                        chekCureVo.setCureNum(chekCureVo.getCureNum()-entry.getValue().getUsedNum()*cardItemInfo.getUserNum());
                                        //总的
                                        chekCureVo.setCureNum(chekCureVo.getCureNum()+cardItemInfo.getCommonMultiple());
                                    }
                                    chekCureVo.setCureProject(true);
                                    //总的
                                    chekCureVo.setCureNum(chekCureVo.getCureNum()+cardItemInfo.getCommonMultiple());
                                }
                                cureItemNum++;
                                NMSet.add(cardItemInfo.getId());
@@ -599,10 +630,12 @@
                            continue;
                        }
                        if(skuNoSet.contains(cardItemInfo.getCommonCode())){
                            chekCureVo.setCureNum(chekCureVo.getCureNum()+cardItemInfo.getCommonMultiple());
                            chekCureVo.setCureProject(true);
                            if(userCard.getEffectiveStatus() != UserProjectConstants.EFF_STATUS_CANCEL){
                                chekCureVo.setCureNum(chekCureVo.getCureNum()+cardItemInfo.getCommonMultiple());
                            }
                            NMSet.add(cardItemInfo.getId());
                            cureItemNum++;
                            chekCureVo.setCureProject(true);
                        }
                    }
                }
phi_platform_common/src/main/resources/mapper/platform/MarketSystemMapper.xml
@@ -8,7 +8,7 @@
    <!-- 整个实体类修改,表字段=实体类字段-->
    <sql id="Update_Column_All">
        <trim prefixOverrides=",">
            ,title = #{title},type = #{type},isUp = #{isUp},timeType = #{timeType},timeNum = #{timeNum},startTime = #{startTime},endTime = #{endTime},headId = #{headId},headName = #{headName},ruleInfo = #{ruleInfo},isDel = #{isDel},createTime = #{createTime},editTime = #{editTime}
            ,title = #{title},type = #{type},isUp = #{isUp},cureNum = #{cureNum},timeType = #{timeType},timeNum = #{timeNum},durationType = #{durationType},durationYear = #{durationYear},durationMonth = #{durationMonth},durationDay = #{durationDay},durationStart = #{durationStart},durationEnd = #{durationEnd},startTime = #{startTime},endTime = #{endTime},headId = #{headId},headName = #{headName},ruleInfo = #{ruleInfo},isDel = #{isDel},createTime = #{createTime},editTime = #{editTime}
        </trim>
    </sql>
     
@@ -19,11 +19,11 @@
        <selectKey keyProperty="id" resultType="String" order="BEFORE">
               select replace(uuid(),'-','') from dual
        </selectKey>
        insert into market_system (id,title,type,isUp,timeType,timeNum,startTime,endTime,headId,headName,ruleInfo,isDel,createTime,editTime)  values (#{id},#{title},#{type},#{isUp},#{timeType},#{timeNum},#{startTime},#{endTime},#{headId},#{headName},#{ruleInfo},#{isDel},#{createTime},#{editTime})
        insert into market_system (id,title,type,isUp,cureNum,timeType,timeNum,durationType,durationYear,durationMonth,durationDay,durationStart,durationEnd,startTime,endTime,headId,headName,ruleInfo,isDel,createTime,editTime)  values (#{id},#{title},#{type},#{isUp},#{cureNum},#{timeType},#{timeNum},#{durationType},#{durationYear},#{durationMonth},#{durationDay},#{durationStart},#{durationEnd},#{startTime},#{endTime},#{headId},#{headName},#{ruleInfo},#{isDel},#{createTime},#{editTime})
    </insert>
    <insert id="insertById" parameterType="com.hx.phiappt.model.market.system.MarketSystem">
        insert into market_system (id,title,type,isUp,timeType,timeNum,startTime,endTime,headId,headName,ruleInfo,isDel,createTime,editTime)  values (#{id},#{title},#{type},#{isUp},#{timeType},#{timeNum},#{startTime},#{endTime},#{headId},#{headName},#{ruleInfo},#{isDel},#{createTime},#{editTime})
        insert into market_system (id,title,type,isUp,cureNum,timeType,timeNum,durationType,durationYear,durationMonth,durationDay,durationStart,durationEnd,startTime,endTime,headId,headName,ruleInfo,isDel,createTime,editTime)  values (#{id},#{title},#{type},#{isUp},#{cureNum},#{timeType},#{timeNum},#{durationType},#{durationYear},#{durationMonth},#{durationDay},#{durationStart},#{durationEnd},#{startTime},#{endTime},#{headId},#{headName},#{ruleInfo},#{isDel},#{createTime},#{editTime})
    </insert>
    <select id="selectList" resultType="com.hx.phiappt.model.market.system.MarketSystem" parameterType="com.hx.mybatisTool.SqlSentence" >
@@ -55,14 +55,14 @@
    <select id="selectOneByKey" resultType="com.hx.phiappt.model.market.system.MarketSystem" parameterType="java.lang.Object" >
        select 
            id,title,type,isUp,timeType,timeNum,startTime,endTime,headId,headName,ruleInfo,isDel,createTime,editTime
            id,title,type,isUp,cureNum,timeType,timeNum,durationType,durationYear,durationMonth,durationDay,durationStart,durationEnd,startTime,endTime,headId,headName,ruleInfo,isDel,createTime,editTime
        from market_system
        WHERE id = #{value}
    </select>
    <select id="selectOneByKeyBlob" resultType="com.hx.phiappt.model.market.system.MarketSystem" parameterType="java.lang.Object" >
        select 
            id,title,type,isUp,timeType,timeNum,startTime,endTime,headId,headName,ruleInfo,isDel,createTime,editTime
            id,title,type,isUp,cureNum,timeType,timeNum,durationType,durationYear,durationMonth,durationDay,durationStart,durationEnd,startTime,endTime,headId,headName,ruleInfo,isDel,createTime,editTime
        from market_system
        WHERE id = #{value}
    </select>
phi_platform_user/src/main/java/com/hx/phip/service/order/impl/OrderRefundServiceImpl.java
@@ -2808,7 +2808,7 @@
                Thread.sleep(5000);
            }catch (Exception ignored){
            }
            userCluebMemberServiceTool.refundCancelChekMember(refundRecord.getOrderId(),null, refundRecord.getId(), MarketSystem.TYPE_REGENERATION);
            userCluebMemberServiceTool.refundCancelChekMember(ordersTotal.getId(),null, refundRecord.getId(), MarketSystem.TYPE_REGENERATION);
        });
    }