package org.jebot.service.impl;

import org.jebot.repository.xxpay.MchAccountRepository;
import org.jebot.repository.xxpay.MchInfoRepository;
import org.jebot.service.IMchService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
public class MchServiceImpl implements IMchService {

    @Resource
    private MchAccountRepository mchAccountRepository;

    @Resource
    private MchInfoRepository mchInfoRepository;

    @Override
    @Transactional
    public int updateMchStatus(Long mchId, int status) {
        if (mchInfoRepository.updateStatusByMchId(mchId, status) < 1) {
            return -1;
        }
        if (mchAccountRepository.updateStatusByMchId(mchId, status) < 1) {
            throw new RuntimeException("更新商户账户状态失败");
        }
        return 1;
    }
}
