| | |
| | | import com.hx.mybatisTool.SqlSentence; |
| | | import com.hx.phiappt.common.OrderItemConstants; |
| | | import com.hx.phiappt.common.OrderTotalConstants; |
| | | import com.hx.phiappt.common.UserProjectConstants; |
| | | import com.hx.phiappt.constants.enums.GroupTypeEnum; |
| | | import com.hx.phiappt.constants.enums.ProjectRelationTypeEnum; |
| | | import com.hx.phiappt.dao.mapper.ProjectTypeRelationMapper; |
| | |
| | | import com.hx.phiappt.model.order.OrderItemSon; |
| | | import com.hx.phiappt.model.order.OrdersTotal; |
| | | import com.hx.phiappt.model.project.ProjectTypeRelation; |
| | | import com.hx.phiappt.model.user.UserCard; |
| | | import com.hx.phiappt.model.user.UserCardUsed; |
| | | import com.hx.phiappt.model.user.club.UserClubMember; |
| | | import com.hx.phip.dao.mapper.*; |
| | | import com.hx.phip.vo.club.ChekCureVo; |
| | | import com.hx.util.DateUtil; |
| | | |
| | | import java.util.*; |
| | |
| | | skuNoSet.add(projectTypeRelation.getSkuNo()); |
| | | } |
| | | } |
| | | |
| | | //---获取购买的子单 |
| | | values.clear(); |
| | | values.put("orderId",ordersTotal.getId()); |
| | | sqlSentence.sqlSentence("SELECT id,type,commonId,goodsNo,goodsName,usedTotal,hasReNum FROM order_item WHERE isDel = 0 AND orderId = #{m.orderId}",values); |
| | | List<OrderItem> orderItemList = commonService.selectList(OrderItemMapper.class,sqlSentence); |
| | | |
| | | //总疗程数,所有的项目疗程数总和 |
| | | int cureNum = 0; |
| | | ChekCureVo chekCureVo = orderHandle(ordersTotal,skuNoSet,commonService); |
| | | if(!chekCureVo.isCureProject()){ |
| | | return; |
| | | } |
| | | int cureNum = chekCureVo.getCureNum(); |
| | | //判断是否符合规则 |
| | | if(cureNum >= marketSystem.getCureNum()){ |
| | | //生成俱乐部会员 |
| | | createClubMember(UserClubMember.TYPE_REGENERATION,ordersTotal,marketSystem,commonService); |
| | | }else { |
| | | //时间段内的订单算法 |
| | | values.clear(); |
| | | |
| | | //存储卡项所有的子项,k值:权益标识 |
| | | Map<String,List<CardItemInfo>> cardItemInfoMapList; |
| | | List<OrderItemSon> orderItemSonList; |
| | | List<CardEquity> cardEquityList; |
| | | List<CardItemInfo> cardItemInfoList; |
| | | int cureItemNum; |
| | | int deductionSurp; |
| | | int deductionNum; |
| | | for(OrderItem orderItem:orderItemList){ |
| | | if(OrderItemConstants.TYPE_PROJECT.equals(orderItem.getType())){ |
| | | //项目,没有包含 |
| | | if(skuNoSet.contains(orderItem.getGoodsNo())){ |
| | | //疗程次数叠加,退款的也需要减去 |
| | | cureNum = cureNum+orderItem.getUsedTotal()-orderItem.getHasReNum(); |
| | | } |
| | | }else if(OrderItemConstants.TYPE_PROMOTION.equals(orderItem.getType())){ |
| | | //促销 |
| | | orderItemSonList = getOrderItemSonList(orderItem.getId(),OrderItemConstants.TYPE_PROJECT,commonService); |
| | | for(OrderItemSon orderItemSon:orderItemSonList){ |
| | | if(skuNoSet.contains(orderItemSon.getGoodsNo())){ |
| | | //疗程次数叠加,退款的也需要减去 |
| | | cureNum = cureNum+orderItem.getUsedTotal()-orderItem.getHasReNum(); |
| | | } |
| | | } |
| | | }else if(OrderItemConstants.TYPE_CARD.equals(orderItem.getType())){ |
| | | //卡项,注意,不是卡包 |
| | | //TODO 退款没有减去 |
| | | cardEquityList = getCardEquityList(orderItem.getCommonId(),commonService); |
| | | cardItemInfoMapList = getCardItemInfoList(orderItem.getCommonId(),commonService); |
| | | for(CardEquity cardEquity:cardEquityList){ |
| | | cardItemInfoList = cardItemInfoMapList.get(cardEquity.getId()); |
| | | if(cardItemInfoList == null || cardItemInfoList.size()==0){ |
| | | continue; |
| | | } |
| | | //判断权益类型 |
| | | if(cardEquity.getEquityType().equals(CardEquity.EQUITY_TYPE_PROJECT)){ |
| | | for(CardItemInfo cardItemInfo:cardItemInfoList){ |
| | | if(skuNoSet.contains(cardItemInfo.getCommonCode())){ |
| | | //固定项目类型 |
| | | if(cardItemInfo.getUserNum() != null){ |
| | | cureNum = cureNum+cardItemInfo.getUserNum()*cardItemInfo.getMaxNum()*orderItem.getBuyNum(); |
| | | } |
| | | } |
| | | } |
| | | }else if(cardEquity.getEquityType().equals(CardEquity.EQUITY_TYPE_TIME_CARD)){ |
| | | //只存储最大的一个疗程数 |
| | | //---次卡 |
| | | //剩余抵扣次数 |
| | | deductionSurp = cardEquity.getValue(); |
| | | //最小公倍数算法 |
| | | minCommonMultiple(cardItemInfoList); |
| | | //排序,降序 |
| | | cardItemInfoList = cardItemInfoList.stream().sorted(Comparator.comparing(CardItemInfo::getCommonMultiple).reversed()) |
| | | .collect(Collectors.toList()); |
| | | for(CardItemInfo cardItemInfo:cardItemInfoList){ |
| | | if(deductionSurp <= 0){ |
| | | break; |
| | | } |
| | | if(skuNoSet.contains(cardItemInfo.getCommonCode())){ |
| | | if(cardItemInfo.getUserNum() != null){ |
| | | //计算可购买数量,注意,这不是折扣数量 |
| | | if(cardItemInfo.getEveryDrawNum() > 0){ |
| | | deductionNum = cardEquity.getValue()/cardItemInfo.getEveryDrawNum(); |
| | | }else{ |
| | | deductionNum = 0; |
| | | } |
| | | //算出总疗程,并叠加到总规则总疗程里面 |
| | | cureNum = cureNum+cardItemInfo.getUserNum()*deductionNum*orderItem.getBuyNum(); |
| | | //剩下划扣次数 |
| | | deductionSurp = deductionSurp - deductionNum*cardItemInfo.getEveryDrawNum(); |
| | | } |
| | | } |
| | | } |
| | | }else if(cardEquity.getEquityType().equals(CardEquity.EQUITY_TYPE_N_M)){ |
| | | //已算的条目数量 |
| | | cureItemNum = 0; |
| | | //---N选M |
| | | //先算各疗程总数 |
| | | for(CardItemInfo cardItemInfo:cardItemInfoList){ |
| | | if(cardItemInfo.getUserNum() != null){ |
| | | cardItemInfo.setCommonMultiple(cardItemInfo.getMaxNum()*cardItemInfo.getUserNum()); |
| | | }else{ |
| | | cardItemInfo.setCommonMultiple(0); |
| | | } |
| | | } |
| | | //排序,降序 |
| | | cardItemInfoList = cardItemInfoList.stream().sorted(Comparator.comparing(CardItemInfo::getCommonMultiple).reversed()) |
| | | .collect(Collectors.toList()); |
| | | for(CardItemInfo cardItemInfo:cardItemInfoList){ |
| | | if(cureItemNum >= cardEquity.getValue()){ |
| | | break; |
| | | } |
| | | if(skuNoSet.contains(cardItemInfo.getCommonCode())){ |
| | | cureNum = cureNum+cardItemInfo.getCommonMultiple(); |
| | | cureItemNum++; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | Date startTime = null; |
| | | Date endTime = null; |
| | | if(marketSystem.getTimeType() == MarketSystem.TIME_TYPE_HOUR){ |
| | | endTime = ordersTotal.getPayTime(); |
| | | startTime = DateUtil.addhour(endTime,marketSystem.getTimeNum()); |
| | | } |
| | | itemNameSql = new StringBuilder(); |
| | | values.put("userId",ordersTotal.getUserId()); |
| | | values.put("newId",ordersTotal.getId()); |
| | | itemNameSql.append("SELECT * FROM orders_total WHERE isDel = 0 AND status IN(2,3,9) AND payStatus = 3 AND userId = #{m.userId}"); |
| | | itemNameSql.append(" AND id != #{m.newId}"); |
| | | if(startTime != null){ |
| | | itemNameSql.append(" AND payTime >= #{m.startTime}"); |
| | | values.put("startTime",startTime); |
| | | } |
| | | if(endTime != null){ |
| | | itemNameSql.append(" AND payTime <= #{m.endTime}"); |
| | | values.put("endTime",endTime); |
| | | } |
| | | |
| | | sqlSentence.sqlSentence(itemNameSql.toString(),values); |
| | | List<OrdersTotal> ordersTotalList = commonService.selectList(OrdersTotalMapper.class,sqlSentence); |
| | | for(OrdersTotal ordersTotal1:ordersTotalList){ |
| | | chekCureVo = orderHandle(ordersTotal1,skuNoSet,commonService); |
| | | cureNum =cureNum + chekCureVo.getCureNum(); |
| | | } |
| | | } |
| | | |
| | | //判断是否符合规则 |
| | | //查找符合的订单 |
| | | if(cureNum >= marketSystem.getCureNum()){ |
| | | //生成俱乐部会员 |
| | | createClubMember(UserClubMember.TYPE_REGENERATION,ordersTotal,marketSystem,commonService); |
| | | } |
| | | |
| | | } |
| | | |
| | | /**单订单处理*/ |
| | | public static ChekCureVo orderHandle(OrdersTotal ordersTotal, Set<String> skuNoSet, CommonService commonService){ |
| | | SqlSentence sqlSentence = new SqlSentence(); |
| | | Map<String,Object> values = new HashMap<>(); |
| | | //---获取购买的子单 |
| | | values.put("orderId",ordersTotal.getId()); |
| | | sqlSentence.sqlSentence("SELECT id,type,commonId,goodsNo,goodsName,usedTotal,hasReNum FROM order_item WHERE isDel = 0 AND orderId = #{m.orderId}",values); |
| | | List<OrderItem> orderItemList = commonService.selectList(OrderItemMapper.class,sqlSentence); |
| | | |
| | | //总疗程数,所有的项目疗程数总和 |
| | | ChekCureVo chekCureVo = new ChekCureVo(); |
| | | |
| | | List<OrderItemSon> orderItemSonList; |
| | | for(OrderItem orderItem:orderItemList){ |
| | | if(OrderItemConstants.TYPE_PROJECT.equals(orderItem.getType())){ |
| | | //---项目,没有包含 |
| | | if(skuNoSet.contains(orderItem.getGoodsNo())){ |
| | | //疗程次数叠加,退款的也需要减去 |
| | | chekCureVo.setCureNum(chekCureVo.getCureNum()+orderItem.getUsedTotal()-orderItem.getHasReNum()); |
| | | chekCureVo.setCureProject(true); |
| | | } |
| | | }else if(OrderItemConstants.TYPE_PROMOTION.equals(orderItem.getType())){ |
| | | //---促销 |
| | | orderItemSonList = getOrderItemSonList(orderItem.getId(),OrderItemConstants.TYPE_PROJECT,commonService); |
| | | for(OrderItemSon orderItemSon:orderItemSonList){ |
| | | if(skuNoSet.contains(orderItemSon.getGoodsNo())){ |
| | | //疗程次数叠加,退款的也需要减去 |
| | | chekCureVo.setCureNum(chekCureVo.getCureNum()+orderItem.getUsedTotal()-orderItem.getHasReNum()); |
| | | chekCureVo.setCureProject(true); |
| | | } |
| | | } |
| | | }else if(OrderItemConstants.TYPE_CARD.equals(orderItem.getType())){ |
| | | //---卡项,注意,不是卡包 |
| | | chekCureVo = handleCard(chekCureVo,orderItem,skuNoSet,commonService); |
| | | } |
| | | } |
| | | return chekCureVo; |
| | | } |
| | | |
| | | |
| | | /**获取二级子订单*/ |
| | | public static List<OrderItemSon> getOrderItemSonList(String orderItemId,String goodsType,CommonService commonService){ |
| | |
| | | return commonService.selectList(OrderItemSonMapper.class,sqlSentence); |
| | | } |
| | | |
| | | /**获取所有的权益*/ |
| | | public static List<CardEquity> getCardEquityList(String cardItemId, CommonService commonService){ |
| | | /**处理卡数据-计算疗程数*/ |
| | | public static ChekCureVo handleCard(ChekCureVo chekCureVo,OrderItem orderItem,Set<String> skuNoSet,CommonService commonService){ |
| | | |
| | | SqlSentence sqlSentence = new SqlSentence(); |
| | | Map<String,Object> values = new HashMap<>(); |
| | | |
| | | values.put("cardItemId",cardItemId); |
| | | 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); |
| | | List<UserCard> userCardList = commonService.selectList(UserCardMapper.class,sqlSentence); |
| | | |
| | | //获取还有的权益 |
| | | values.put("cardItemId",orderItem.getCommonId()); |
| | | sqlSentence.sqlSentence("SELECT cii.id,cii.equityType,cii.value,cii.shareMoney" + |
| | | " FROM card_equity cii WHERE cii.isDel = 0 AND cii.cardItemId = #{m.cardItemId}",values); |
| | | List<CardEquity> cardEquityList = commonService.selectList(CardEquityMapper.class,sqlSentence); |
| | | |
| | | return commonService.selectList(CardEquityMapper.class,sqlSentence); |
| | | } |
| | | |
| | | /**获取卡项所有的项目*/ |
| | | public static Map<String,List<CardItemInfo>> getCardItemInfoList(String cardItemId, CommonService commonService){ |
| | | SqlSentence sqlSentence = new SqlSentence(); |
| | | Map<String,Object> values = new HashMap<>(); |
| | | |
| | | values.put("cardItemId",cardItemId); |
| | | //获取所有条目 |
| | | values.clear(); |
| | | values.put("cardItemId",orderItem.getCommonId()); |
| | | sqlSentence.sqlSentence("SELECT cii.id,cii.cardEquityId,cii.commonCode,cii.commonId,cii.commonName,cii.commonType,cii.maxNum,cii.everyDrawNum,p.treatmentItemsNum AS userNum" + |
| | | " LEFT JOIN project p ON p.id = cii.commonId AND p.isExecutable = 1" + |
| | | " FROM card_item_info cii WHERE cii.isDel = 0 AND cii.cardItemId = #{m.cardItemId} AND cii.commonType IN('project')",values); |
| | | List<CardItemInfo> cardItemInfoList = commonService.selectList(CardItemInfoMapper.class,sqlSentence); |
| | | |
| | | List<CardItemInfo> cardItemInfoListAll = commonService.selectList(CardItemInfoMapper.class,sqlSentence); |
| | | //存储卡项所有的子项,k值:权益标识 |
| | | Map<String,List<CardItemInfo>> cardItemInfoMapList = new HashMap<>(); |
| | | List<CardItemInfo> cardItemInfoList1; |
| | | for(CardItemInfo cardItemInfo:cardItemInfoList){ |
| | | cardItemInfoList1 = cardItemInfoMapList.computeIfAbsent(cardItemInfo.getCardEquityId(),k->new ArrayList<>()); |
| | | cardItemInfoList1.add(cardItemInfo); |
| | | List<CardItemInfo> cardItemInfoList; |
| | | for(CardItemInfo cardItemInfo:cardItemInfoListAll){ |
| | | cardItemInfoList = cardItemInfoMapList.computeIfAbsent(cardItemInfo.getCardEquityId(),k->new ArrayList<>()); |
| | | cardItemInfoList.add(cardItemInfo); |
| | | } |
| | | |
| | | return cardItemInfoMapList; |
| | | //已退款的条目,key值,卡项权益标识 |
| | | Map<String,List<UserCardUsed>> refundItemMapList; |
| | | List<UserCardUsed> userCardUsedList; |
| | | List<UserCardUsed> userCardUsedList2; |
| | | //已退款的条目,key值,卡项条目标识 |
| | | Map<String,UserCardUsed> userCardUsedMap; |
| | | //cureItemNum是N选M已选择的项目个数 |
| | | int cureItemNum; |
| | | int deductionSurp; |
| | | int deductionNum; |
| | | int cureRefundNum; |
| | | UserCardUsed userCardUsedTotal; |
| | | //存储已经算过的条目 |
| | | Set<String> NMSet; |
| | | for(UserCard userCard:userCardList){ |
| | | |
| | | //获取已退款的项目数量 |
| | | values.clear(); |
| | | values.put("sourceType", UserCardUsed.SOURCE_TYPE_USER_CARD_REFUND); |
| | | values.put("userCardId", userCard.getId()); |
| | | sqlSentence.sqlSentence("SELECT cardEquityId,cardItemInfoId,usedNum FROM user_card_used uc WHERE uc.isDel = 0 AND uc.userCardId #{m.userCardId} AND uc.sourceType = #{m.sourceType}",values); |
| | | userCardUsedList = commonService.selectList(UserCardUsedMapper.class,sqlSentence); |
| | | |
| | | refundItemMapList = new HashMap<>(); |
| | | for(UserCardUsed userCardUsed:userCardUsedList){ |
| | | userCardUsedList2 = refundItemMapList.computeIfAbsent(userCardUsed.getCardEquityId(),k->new ArrayList<>()); |
| | | userCardUsedList2.add(userCardUsed); |
| | | } |
| | | |
| | | for(CardEquity cardEquity:cardEquityList){ |
| | | //获取权益子项 |
| | | cardItemInfoList = cardItemInfoMapList.get(cardEquity.getId()); |
| | | if(cardItemInfoList == null || cardItemInfoList.size()==0){ |
| | | continue; |
| | | } |
| | | |
| | | //---分卡项条目装载已退款的 |
| | | userCardUsedMap = new HashMap<>(); |
| | | userCardUsedList = refundItemMapList.get(cardEquity.getId()); |
| | | //计算已退款次数总和 |
| | | cureRefundNum = 0; |
| | | if(userCardUsedList != null){ |
| | | for(UserCardUsed userCardUsed:userCardUsedList){ |
| | | userCardUsedTotal = userCardUsedMap.computeIfAbsent(userCardUsed.getCardItemInfoId(),k->new UserCardUsed()); |
| | | if(userCardUsedTotal.getUsedNum() == null){ |
| | | userCardUsedTotal.setUsedNum(0); |
| | | } |
| | | userCardUsedTotal.setUsedNum(userCardUsedTotal.getUsedNum()+userCardUsed.getUsedNum()); |
| | | cureRefundNum = cureRefundNum + userCardUsed.getUsedNum(); |
| | | } |
| | | } |
| | | |
| | | //判断权益类型 |
| | | if(cardEquity.getEquityType().equals(CardEquity.EQUITY_TYPE_PROJECT)){ |
| | | for(CardItemInfo cardItemInfo:cardItemInfoList){ |
| | | if(skuNoSet.contains(cardItemInfo.getCommonCode())){ |
| | | //固定项目类型 |
| | | 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()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }else if(cardEquity.getEquityType().equals(CardEquity.EQUITY_TYPE_TIME_CARD)){ |
| | | //只存储最大的一个疗程数 |
| | | //---次卡 |
| | | //剩余抵扣次数,这里减去已经退款的次数了 |
| | | deductionSurp = cardEquity.getValue()-cureRefundNum; |
| | | //最小公倍数算法 |
| | | minCommonMultiple(cardItemInfoList); |
| | | //排序,降序 |
| | | cardItemInfoList = cardItemInfoList.stream().sorted(Comparator.comparing(CardItemInfo::getCommonMultiple).reversed()) |
| | | .collect(Collectors.toList()); |
| | | for(CardItemInfo cardItemInfo:cardItemInfoList){ |
| | | if(deductionSurp <= 0){ |
| | | break; |
| | | } |
| | | if(skuNoSet.contains(cardItemInfo.getCommonCode())){ |
| | | if(cardItemInfo.getUserNum() != null){ |
| | | //计算可购买数量,注意,这不是抵扣次数,是可购买的项目数量 |
| | | if(cardItemInfo.getEveryDrawNum() > 0){ |
| | | deductionNum = cardEquity.getValue()/cardItemInfo.getEveryDrawNum(); |
| | | }else{ |
| | | deductionNum = 0; |
| | | } |
| | | //算出总疗程,并叠加到总规则总疗程里面 |
| | | chekCureVo.setCureNum(chekCureVo.getCureNum()+cardItemInfo.getUserNum()*deductionNum); |
| | | chekCureVo.setCureProject(true); |
| | | //剩下划扣次数 |
| | | deductionSurp = deductionSurp - deductionNum*cardItemInfo.getEveryDrawNum(); |
| | | } |
| | | } |
| | | } |
| | | }else if(cardEquity.getEquityType().equals(CardEquity.EQUITY_TYPE_N_M)){ |
| | | //已算的条目数量 |
| | | cureItemNum = 0; |
| | | //---N选M |
| | | //先算各疗程总数 |
| | | for(CardItemInfo cardItemInfo:cardItemInfoList){ |
| | | if(cardItemInfo.getUserNum() != null){ |
| | | cardItemInfo.setCommonMultiple(cardItemInfo.getMaxNum()*cardItemInfo.getUserNum()); |
| | | }else{ |
| | | cardItemInfo.setCommonMultiple(0); |
| | | } |
| | | } |
| | | //排序,降序,最大的在前面 |
| | | cardItemInfoList = cardItemInfoList.stream().sorted(Comparator.comparing(CardItemInfo::getCommonMultiple).reversed()).collect(Collectors.toList()); |
| | | |
| | | NMSet = new HashSet<>(); |
| | | //已经退款的先算 |
| | | for (Map.Entry <String, UserCardUsed> entry : userCardUsedMap.entrySet()) { |
| | | 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()); |
| | | chekCureVo.setCureProject(true); |
| | | //总的 |
| | | chekCureVo.setCureNum(chekCureVo.getCureNum()+cardItemInfo.getCommonMultiple()); |
| | | |
| | | } |
| | | cureItemNum++; |
| | | NMSet.add(cardItemInfo.getId()); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | for(CardItemInfo cardItemInfo:cardItemInfoList){ |
| | | //选了多少个项目排序 |
| | | if(cureItemNum >= cardEquity.getValue()){ |
| | | break; |
| | | } |
| | | //已经算过就跳出去 |
| | | if(NMSet.contains(cardItemInfo.getId())){ |
| | | continue; |
| | | } |
| | | if(skuNoSet.contains(cardItemInfo.getCommonCode())){ |
| | | chekCureVo.setCureNum(chekCureVo.getCureNum()+cardItemInfo.getCommonMultiple()); |
| | | chekCureVo.setCureProject(true); |
| | | NMSet.add(cardItemInfo.getId()); |
| | | cureItemNum++; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return chekCureVo; |
| | | } |
| | | |
| | | /**获取最小公倍数*/ |
| | | public static void minCommonMultiple(List<CardItemInfo> cardItemInfoList){ |
| | | //先获取最大的一个数字 |
| | | int max = 0; |
| | | for(CardItemInfo cardItemInfo:cardItemInfoList){ |
| | | if(max<cardItemInfo.getEveryDrawNum()){ |
| | | max = cardItemInfo.getEveryDrawNum(); |
| | | } |
| | | } |
| | | |
| | | //求最小的公倍数 |
| | | boolean b; |
| | | while (true){ |
| | | b = true; |
| | | for(CardItemInfo cardItemInfo:cardItemInfoList){ |
| | | if(max%cardItemInfo.getEveryDrawNum()!=0){ |
| | | b = false; |
| | | break; |
| | | } |
| | | } |
| | | if(b){ |
| | | break; |
| | | }else{ |
| | | max++; |
| | | } |
| | | } |
| | | |
| | | //求出他们之间,谁的疗程数最多 |
| | | for(CardItemInfo cardItemInfo:cardItemInfoList){ |
| | | if(cardItemInfo.getUserNum() != null){ |
| | | cardItemInfo.setCommonMultiple(cardItemInfo.getUserNum()*max/cardItemInfo.getEveryDrawNum()); |
| | | }else{ |
| | | cardItemInfo.setCommonMultiple(0); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /**订单生成再生俱乐部会员*/ |
| | |
| | | userClubMember.setUserId(userId); |
| | | commonService.insert(UserClubMemberMapper.class,userClubMember); |
| | | } |
| | | |
| | | /**获取最小公倍数*/ |
| | | public static void minCommonMultiple(List<CardItemInfo> cardItemInfoList){ |
| | | //先获取最大的一个数字 |
| | | int max = 0; |
| | | for(CardItemInfo cardItemInfo:cardItemInfoList){ |
| | | if(max<cardItemInfo.getEveryDrawNum()){ |
| | | max = cardItemInfo.getEveryDrawNum(); |
| | | } |
| | | } |
| | | |
| | | //求最小的公倍数 |
| | | boolean b; |
| | | while (true){ |
| | | b = true; |
| | | for(CardItemInfo cardItemInfo:cardItemInfoList){ |
| | | if(max%cardItemInfo.getEveryDrawNum()!=0){ |
| | | b = false; |
| | | break; |
| | | } |
| | | } |
| | | if(b){ |
| | | break; |
| | | }else{ |
| | | max++; |
| | | } |
| | | } |
| | | |
| | | //求出他们之间,谁的疗程数最多 |
| | | for(CardItemInfo cardItemInfo:cardItemInfoList){ |
| | | if(cardItemInfo.getUserNum() != null){ |
| | | cardItemInfo.setCommonMultiple(cardItemInfo.getUserNum()*max/cardItemInfo.getEveryDrawNum()); |
| | | }else{ |
| | | cardItemInfo.setCommonMultiple(0); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |