/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  org.apache.commons.beanutils.BeanUtils
 *  org.springframework.beans.factory.annotation.Autowired
 *  org.springframework.stereotype.Repository
 */
package com.hst.taxService.dao.imp;

import com.hst.framework.common.HstSqlMapClientTemplate;
import com.hst.framework.constants.WebConstants;
import com.hst.framework.util.HstDateUtil;
import com.hst.taxService.dao.TaxWxGzzListAppDao;
import com.hst.taxService.domain.GzzXxDomain;
import com.hst.taxService.domain.WxYhxxDomain;
import com.hst.taxService.domain.WxZhgxLogDomain;
import com.hst.taxService.domain.WxZhxxDomain;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class TaxWxGzzListAppDaoImp
implements TaxWxGzzListAppDao {
    @Autowired
    private HstSqlMapClientTemplate sqlMapClientTemplate;

    @Override
    public List<WxZhxxDomain> queryWxZhxxList() throws Exception {
        HashMap<String, String> map = new HashMap<String, String>();
        String databaseUsername = WebConstants.HST_PROP_MAP.get("hst.SCHEMA_TM");
        map.put("databaseUsername", databaseUsername);
        return this.sqlMapClientTemplate.queryForList("queryWxZhxxList", map);
    }

    @Override
    public void saveWxYhxx(String appid) throws Exception {
        String databaseUsername = WebConstants.HST_PROP_MAP.get("hst.SCHEMA_TM");
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("appid", appid);
        map.put("databaseUsername", databaseUsername);
        this.sqlMapClientTemplate.update("updateWxYhxxSubscribe", map);
        this.sqlMapClientTemplate.delete("deleteWxYhxxWgz", map);
        this.sqlMapClientTemplate.insert("insertWxYhxxFromLsb", map);
    }

    public WxYhxxDomain getWxYhxxByKey(String appid, String openid) {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("appid", appid);
        map.put("openid", openid);
        String databaseUsername = WebConstants.HST_PROP_MAP.get("hst.SCHEMA_TM");
        map.put("databaseUsername", databaseUsername);
        return (WxYhxxDomain)this.sqlMapClientTemplate.queryForObject("selectWxYhxxByKey", map);
    }

    @Override
    public void saveWxZhgxLog(WxZhgxLogDomain domain) throws Exception {
        domain.setDatabaseUsername(WebConstants.HST_PROP_MAP.get("hst.SCHEMA_TM"));
        this.sqlMapClientTemplate.insert("insertWxZhgxLog", domain);
    }

    @Override
    public void doWxYhdygxCl() throws Exception {
        HashMap<String, String> map = new HashMap<String, String>();
        String databaseUsername = WebConstants.HST_PROP_MAP.get("hst.SCHEMA_TM");
        map.put("databaseUsername", databaseUsername);
        this.sqlMapClientTemplate.queryForObject("pTmSjclWxYHdygx", map);
    }

    @Override
    public void saveLsbWxYhxx(List<GzzXxDomain> gzzList, String appid) throws Exception {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String databaseUsername = WebConstants.HST_PROP_MAP.get("hst.SCHEMA_TM");
        for (GzzXxDomain gzzXxDom : gzzList) {
            WxYhxxDomain dom = new WxYhxxDomain();
            Long dataTimenew = new Long(String.valueOf(gzzXxDom.getSubscribe_time()) + "000");
            BeanUtils.copyProperties((Object)dom, (Object)gzzXxDom);
            dom.setAppid(appid);
            dom.setSubscribe_time(sdf.format(dataTimenew));
            dom.setSubscribe_day(HstDateUtil.getYyyyMmdd(dom.getSubscribe_time()));
            dom.setDatabaseUsername(databaseUsername);
            dom.setNickname(dom.getNickname().replaceAll("%", "%25"));
            this.sqlMapClientTemplate.insert("insertLsbWxYhxx", dom);
        }
    }
}
