package com.propertyManagement.pay.support.pay;

import com.propertyManagement.pay.domain.CmsPayBiz;
import com.siashan.unipay4j.biz.PayBiz;
import org.springframework.beans.BeanUtils;

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

public class CmsPayUtil {


    /**
     * 将应用列表转换成Map格式
     *
     * @param payBizList 应用列表
     * @return 应用map
     */
    public static Map<String, PayBiz> transBizMap(List<CmsPayBiz> payBizList) {
        Map<String, PayBiz> tmplMap = new HashMap<>();
        if (null != payBizList && !payBizList.isEmpty()) {
            for (CmsPayBiz cmsPayBiz : payBizList) {
                PayBiz payBiz = new PayBiz();
                BeanUtils.copyProperties(cmsPayBiz, payBiz);
                payBiz.setPayNotifyUrl(cmsPayBiz.getPayNotifyUrlTmpl());
                payBiz.setRefundNotifyUrl(cmsPayBiz.getRefundNotifyUrlTmpl());
                tmplMap.put(payBiz.getBizCode(), payBiz);
            }
        }
        return tmplMap;
    }
}
