admin
2022-05-10 2922e51a7a8e657a8467c818ae16700e41ddac77
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,10 +70,14 @@
    @Resource
    private UserExtractMoneyLimitService userExtractMoneyLimitService;
    @Resource
    private UserMsgNotifyService userMsgNotifyService;
    @Override
    public List<Extract> list(ExtractQuery extractQuery, int page, int pageSize) {
        DaoQuery daoQuery = new DaoQuery();
        daoQuery.uid = extractQuery.getUid();
        daoQuery.state = extractQuery.getState();
        daoQuery.minCreateTime = extractQuery.toStartTime();
        daoQuery.maxCreateTime = extractQuery.toEndTime();
        daoQuery.sortList = Arrays.asList(new String[]{"create_time desc"});
@@ -84,6 +90,7 @@
    public long count(ExtractQuery extractQuery) {
        DaoQuery daoQuery = new DaoQuery();
        daoQuery.uid = extractQuery.getUid();
        daoQuery.state = extractQuery.getState();
        daoQuery.minCreateTime = extractQuery.toStartTime();
        daoQuery.maxCreateTime = extractQuery.toEndTime();
        return extractMapper.count(daoQuery);
@@ -159,7 +166,7 @@
    @Override
    public boolean canExtractLittleMoney(Long uid, int maxNewerCount, Date date) {
        //判断新人
        long count = countByMaxMoney(uid,Constant.EXTRACT_LITTLE_MONEY_LIMIT, 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;
        }
@@ -230,7 +237,7 @@
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void passExtract(Long id, Long adminId) throws ExtractException {
    public void passExtract(Long id, String adminId) throws ExtractException {
        Extract extract = extractMapper.selectByPrimaryKeyForUpdate(id);
        if (extract == null) {
            throw new ExtractException(ExtractException.CODE_NOT_EXIST, "提现记录不存在");
@@ -262,7 +269,7 @@
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void rejectExtract(Long id, Long adminId, String reason) throws ExtractException, UserMoneyBalanceException, ParamsException {
    public void rejectExtract(Long id, String adminId, String reason) throws ExtractException, UserMoneyBalanceException, ParamsException {
        Extract extract = extractMapper.selectByPrimaryKeyForUpdate(id);
        if (extract == null) {
            throw new ExtractException(ExtractException.CODE_NOT_EXIST, "提现记录不存在");
@@ -281,7 +288,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
@@ -336,7 +348,7 @@
     * @param extract
     * @param adminId
     */
    private void transferByAlipay(Extract extract, Long adminId) {
    private void transferByAlipay(Extract extract, String adminId) {
        //获取用户的系统
        UserInfo user = userInfoService.get(extract.getUser().getId());
        String appName = user.getSystem().getName();
@@ -360,7 +372,7 @@
        }
    }
    private void transferByWX(Extract extract, Long adminId, String wxAPPId) {
    private void transferByWX(Extract extract, String adminId, String wxAPPId) {
        //获取用户的系统
        UserInfo user = userInfoService.get(extract.getUser().getId());
        String appName = user.getSystem().getName();
@@ -407,7 +419,12 @@
                userMoneyRecordService.update(update);
            }
        }
        // TODO 通知转账成功
        //添加消息通知
        try {
            userMsgNotifyService.notify(UserMsgFactory.createExtractSuccess(extract.getUser().getId(), extract.getMoney()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
@@ -435,8 +452,12 @@
            } catch (Exception e) {
                e.printStackTrace();
            }
            // 新版提现
            //TODO 通知转账被拒绝
            //添加消息通知
            try {
                userMsgNotifyService.notify(UserMsgFactory.createExtractFail(extract.getUser().getId(), extract.getMoney(), null));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }