package com.jeequan.jeepay.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jeequan.jeepay.db.entity.MchSubInfoEntity;
import com.jeequan.jeepay.service.mapper.MchSubInfoMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.List;

@Service
public class MchSubInfoService extends ServiceImpl<MchSubInfoMapper, MchSubInfoEntity> {

    /**
     * 获取主要显示的子商户信息
     * @param applyId
     * @return
     */
    public JSONObject getMainSubMchInfo(String applyId) {
        JSONObject result = new JSONObject();
        result.put("WX","暂无");
        result.put("ZFB","暂无");
        List<MchSubInfoEntity> list = baseMapper.selectList(MchSubInfoEntity.gw().eq(MchSubInfoEntity::getMchApplyId, applyId).eq(MchSubInfoEntity::getMainUse,1));
        if(list.isEmpty()){
            return result;
        }
        for (MchSubInfoEntity item:list) {
            result.put(item.getSubMchType(),item.getSubMchId());
        }
        return result;
    }
}
