package com.sifang.modules.rechargewallet.service;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.sifang.modules.rechargewallet.dao.RechargeWalletDao;
import com.sifang.modules.sunshine.financialManagement.dao.SiteAssetDao;
import com.sifang.modules.sunshine.financialManagement.entity.CrmSiteAsset;
import com.sifang.modules.sys.common.UserUtils;
import com.sifang.modules.sys.common.persistence.Page;
import com.sifang.modules.sys.common.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
public class RechargeWalletService extends BaseService {
    //public static String type;
    @Autowired
    private RechargeWalletDao reChargeDao;

    @Autowired
    private SiteAssetDao assetDao;


    public CrmSiteAsset getSiteId(String id) {

        return assetDao.getSiteId(id);
    }

    //账户总额
    public Record getRechargeList() {
        String id = UserUtils.getUser().getId();
        StringBuffer sb = new StringBuffer();
        sb.append(" select a.* from crm_site_asset a");
        sb.append(" left join crm_site b on a.site_id=b.id");
        sb.append(" left join sys_user c on b.user_id=c.id");
        sb.append(" where c.id=? and b.status='0' and c.status='0'");
        return Db.findFirst(sb.toString(), id);
    }

    //充值记录
    public Page<Record> getRecordList(Page<Record> page, Map<String, String> map) {
        List<Record> list = reChargeDao.getRecordList(page, map);
        Long count = reChargeDao.getCount();
        page.setList(list);
        page.setCount(count);
        return page;
    }


    /**
     * 冻结金额列表
     *
     * @param page
     * @return
     */
    public Page<Record> getfrozenDateList(Page<Record> page, Map<String, String> map) {
        return page;
    }

    /**
     * 冻结金额汇总
     */
    public Record getTotalfrozenCount(Map<String, String> map) {
        return null;
    }
}
