KKSU
2023-12-13 18aa07a530c6222708ef59a87c32248c15c6f6b7
src/main/java/cc/mrbird/febs/mall/service/impl/AgentServiceImpl.java
@@ -851,7 +851,7 @@
                //偏移时间
                DateTime dateTime = DateUtil.offsetDay(payTime, cycle);
                int compare = DateUtil.compare(now, dateTime);
                if(compare <= 0){
                if(compare >= 0){
                    /**
                     * 更新买单状态
                     * 收益生成一条卖单
@@ -934,7 +934,8 @@
         * 当前时间比结束时间大
         */
        if(nowTime.compareTo(endTime) >= 0){
            List<MallProductSellRecord> mallProductSellRecords = mallProductSellRecordMapper.selectListByState(ProductEnum.PRODUCT_MATE_STATE_PAY.getValue());
            List<MallProductSellRecord> mallProductSellRecords = mallProductSellRecordMapper.selectListByState(
                    ProductEnum.PRODUCT_MATE_STATE_PAY.getValue());
            if(CollUtil.isNotEmpty(mallProductSellRecords)){
                for(MallProductSellRecord mallProductSellRecord : mallProductSellRecords){
                    /**
@@ -961,7 +962,12 @@
        if(CollUtil.isEmpty(mallProductNfts)){
            return;
        }
        DateTime now = DateUtil.date();
        DateTime nowTime = DateUtil.parseTime(DateUtil.formatTime(DateUtil.date()));
        DataDictionaryCustom endTimeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.YU_YUE_END_TIME.getType(),
                DataDictionaryEnum.YU_YUE_END_TIME.getCode()
        );
        DateTime endTime = DateUtil.parseTime(endTimeDic.getValue());
        for(MallProductNft mallProductNft : mallProductNfts){
            Long nftId = mallProductNft.getId();
            List<MallProductBuy> mallProductBuys = mallProductBuyMapper.selectListByStateAndProductNFTId(
@@ -973,35 +979,49 @@
            }
            for(MallProductBuy mallProductBuy : mallProductBuys){
                /**
                 * 返回令牌
                 * 预约记录超时
                 * 当前时间比结束时间大
                 */
                String orderNo = mallProductBuy.getOrderNo();
                mallProductBuy.setState(ProductEnum.PRODUCT_BUY_TIMEOUT.getValue());
                mallProductBuyMapper.updateById(mallProductBuy);
                if(nowTime.compareTo(endTime) >= 0){
                    /**
                     * 返回令牌
                     * 预约记录超时
                     */
                    String orderNo = mallProductBuy.getOrderNo();
                    /**
                     * 只要存在匹配记录,则不退回。
                     */
                    List<MallProductBuyRecord> mallProductBuyRecords = mallProductBuyRecordMapper.selectRecordListByBuyId(mallProductBuy.getId());
                    if(CollUtil.isNotEmpty(mallProductBuyRecords)){
                        continue;
                    }
                    mallProductBuy.setState(ProductEnum.PRODUCT_BUY_TIMEOUT.getValue());
                    mallProductBuyMapper.updateById(mallProductBuy);
                Long memberId = mallProductBuy.getMemberId();
                MallMoneyFlow mallMoneyFlow = mallMoneyFlowMapper.selectByOrderAndType(orderNo,
                        MoneyFlowTypeNewEnum.TOKEN_BUY_FROZEN.getValue(),
                        FlowTypeNewEnum.TOKEN.getValue(),
                        memberId);
                if(ObjectUtil.isEmpty(mallMoneyFlow)){
                    continue;
                    Long memberId = mallProductBuy.getMemberId();
                    MallMoneyFlow mallMoneyFlow = mallMoneyFlowMapper.selectByOrderAndType(orderNo,
                            MoneyFlowTypeNewEnum.TOKEN_BUY_FROZEN.getValue(),
                            FlowTypeNewEnum.TOKEN.getValue(),
                            memberId);
                    if(ObjectUtil.isEmpty(mallMoneyFlow)){
                        continue;
                    }
                    BigDecimal absAmount = mallMoneyFlow.getAmount().abs();
                    MallMemberAmount mallMemberAmount = mallMemberAmountMapper.selectByMemberId(memberId);
                    mallMemberAmount.setTokenAva(mallMemberAmount.getTokenAva().add(absAmount));
                    mallMemberAmount.setTokenFrozen(mallMemberAmount.getTokenFrozen().subtract(absAmount));
                    mallMemberAmountMapper.updateTokenAvaAndTokenFrozenById(mallMemberAmount);
                    mallMoneyFlowService.addMoneyFlow(
                            memberId,
                            absAmount,
                            MoneyFlowTypeNewEnum.TOKEN_BUY_FROZEN_RETURN.getValue(),
                            orderNo,
                            null,
                            FlowTypeNewEnum.TOKEN.getValue(),
                            MoneyFlowTypeNewEnum.TOKEN_BUY_FROZEN_RETURN.getDescrition());
                }
                BigDecimal absAmount = mallMoneyFlow.getAmount().abs();
                MallMemberAmount mallMemberAmount = mallMemberAmountMapper.selectByMemberId(memberId);
                mallMemberAmount.setTokenAva(mallMemberAmount.getTokenAva().add(absAmount));
                mallMemberAmount.setTokenFrozen(mallMemberAmount.getTokenFrozen().subtract(absAmount));
                mallMemberAmountMapper.updateTokenAvaAndTokenFrozenById(mallMemberAmount);
                mallMoneyFlowService.addMoneyFlow(
                        memberId,
                        absAmount,
                        MoneyFlowTypeNewEnum.TOKEN_BUY_FROZEN_RETURN.getValue(),
                        orderNo,
                        null,
                        FlowTypeNewEnum.TOKEN.getValue(),
                        MoneyFlowTypeNewEnum.TOKEN_BUY_FROZEN_RETURN.getDescrition());
            }
        }
    }
@@ -1021,4 +1041,41 @@
        mallProductSellMapper.insert(mallProductSell);
    }
    public static List<Integer> findMissingNumbers(int[] nums) {
        //定义一个标记数组,标记出现过的下表为true
        boolean[] flag = new boolean[nums.length+1];
        for(int temp:nums){
            flag[temp] = true;
        }
        List<Integer> arr = new ArrayList<Integer>();
        //以连续的i作为本应该的下标,查找之前的标记数组,没有被标记过的下标,就是消失的数字
        for(int i = 1;i <= nums.length; i++){
            if(!flag[i]){
                arr.add(i);
            }
        }
        return arr;
    }
    public static List<Integer> findDisappearedNumbers(int[] nums) {
        Set<Integer> set = new HashSet<>(); // 利用Set对象元素不重复的特性
        // 把nums里的每一个数字都添加至set中
        for(int i = 0; i < nums.length; ++i) {
            set.add(nums[i]);
        }
        List<Integer> list = new ArrayList<>();
        // 把1~n的每一个数字都添加至set中,若添加成功则说明原数组不存在该数字,加入list即可
        for(int i = 1; i <= nums.length; ++i) {
            if(set.add(i)) {
                list.add(i);
            }
        }
        return list;
    }
    public static void main(String[] args) {
        int[] nums = {1, 2, 2, 5, 2};
        List<Integer> missingNumbers = findDisappearedNumbers(nums);
        System.out.println("缺失的数字为:" + missingNumbers);
    }
}