admin
2022-05-07 15bedcc619b1edb6eb987f9288db7670e5b38c46
app/src/main/java/com/yeshi/makemoney/app/service/impl/money/ExtractServiceImpl.java
@@ -21,10 +21,12 @@
import com.yeshi.makemoney.app.service.inter.money.UserExtractMoneyLimitService;
import com.yeshi.makemoney.app.service.inter.money.UserMoneyRecordService;
import com.yeshi.makemoney.app.service.inter.money.UserMoneyService;
import com.yeshi.makemoney.app.service.inter.msg.UserMsgNotifyService;
import com.yeshi.makemoney.app.service.inter.user.UserInfoService;
import com.yeshi.makemoney.app.service.query.money.ExtractQuery;
import com.yeshi.makemoney.app.utils.Constant;
import com.yeshi.makemoney.app.utils.factory.UserMoneyRecordFactory;
import com.yeshi.makemoney.app.utils.factory.msg.UserMsgFactory;
import com.yeshi.makemoney.app.utils.mq.CMQManager;
import com.yeshi.makemoney.app.utils.pay.AlipayUtil;
import org.slf4j.Logger;
@@ -68,6 +70,9 @@
    @Resource
    private UserExtractMoneyLimitService userExtractMoneyLimitService;
    @Resource
    private UserMsgNotifyService userMsgNotifyService;
    @Override
    public List<Extract> list(ExtractQuery extractQuery, int page, int pageSize) {
        DaoQuery daoQuery = new DaoQuery();
@@ -101,7 +106,8 @@
        return extractMapper.count(daoQuery) < 1L;
    }
    private ExtractConfig getExtractConfig(SystemEnum system) {
    @Override
    public ExtractConfig getExtractConfig(SystemEnum system) {
        String value = systemConfigService.getValueCache(system, SystemConfigKey.extractConfig);
        if (StringUtil.isNullOrEmpty(value)) {
            return null;
@@ -146,7 +152,7 @@
        }
        //小金额提现限制
        if (money.compareTo(new BigDecimal(1)) < 0) {
        if (money.compareTo(Constant.EXTRACT_LITTLE_MONEY_LIMIT) < 0) {
            //是否已经用完新用户额度
            if (!canExtractLittleMoney(user.getId(), config.getNewerLittleMoneyNum(), new Date(currentTime))) {
                throw new ExtractException(ExtractException.CODE_LITTLE_MONEY_LIMIT, "今日小于1元提现次数已用尽");
@@ -158,7 +164,7 @@
    @Override
    public boolean canExtractLittleMoney(Long uid, int maxNewerCount, Date date) {
        //判断新人
        long count = countByMaxMoney(uid, new BigDecimal(1), Arrays.asList(new Integer[]{Extract.STATE_NOT_PROCESS, Extract.STATE_PROCESSING, Extract.STATE_PASS}), null);
        long count = countByMaxMoney(uid, Constant.EXTRACT_LITTLE_MONEY_LIMIT, Arrays.asList(new Integer[]{Extract.STATE_NOT_PROCESS, Extract.STATE_PROCESSING, Extract.STATE_PASS}), null);
        if (maxNewerCount > count) {
            return true;
        }
@@ -168,11 +174,21 @@
        if (limit <= 0) {
            return false;
        }
        count = countByMaxMoney(uid, new BigDecimal(1), Arrays.asList(new Integer[]{Extract.STATE_NOT_PROCESS, Extract.STATE_PROCESSING, Extract.STATE_PASS}), new Date(TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(date.getTime(), "yyyyMMdd"), "yyyyMMdd")));
        count = countByMaxMoney(uid, Constant.EXTRACT_LITTLE_MONEY_LIMIT, Arrays.asList(new Integer[]{Extract.STATE_NOT_PROCESS, Extract.STATE_PROCESSING, Extract.STATE_PASS}), new Date(TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(date.getTime(), "yyyyMMdd"), "yyyyMMdd")));
        if (count < limit) {
            return true;
        }
        return false;
    }
    @Override
    public BigDecimal getExtractingMoney(Long uid) {
        DaoQuery daoQuery = new DaoQuery();
        daoQuery.uid = uid;
        daoQuery.state = Extract.STATE_NOT_PROCESS;
        BigDecimal money = extractMapper.sumMoney(daoQuery);
        return money == null ? new BigDecimal(0) : money;
    }
@@ -270,7 +286,12 @@
        updateExtract.setState(Extract.STATE_REJECT);
        updateExtract.setReason(reason);
        extractMapper.updateByPrimaryKeySelective(updateExtract);
        //TODO 消息
        //添加消息通知
        try {
            userMsgNotifyService.notify(UserMsgFactory.createExtractFail(extract.getUser().getId(), extract.getMoney(), reason));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @Override
@@ -396,7 +417,12 @@
                userMoneyRecordService.update(update);
            }
        }
        // TODO 通知转账成功
        //添加消息通知
        try {
            userMsgNotifyService.notify(UserMsgFactory.createExtractSuccess(extract.getUser().getId(), extract.getMoney()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
@@ -424,8 +450,12 @@
            } catch (Exception e) {
                e.printStackTrace();
            }
            // 新版提现
            //TODO 通知转账被拒绝
            //添加消息通知
            try {
                userMsgNotifyService.notify(UserMsgFactory.createExtractFail(extract.getUser().getId(), extract.getMoney(), null));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }