package com.yihu.jw.order.pay.utils;

import com.yihu.jw.entity.order.PayLog;
import com.yihu.jw.order.dao.PayLogDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * Created by Reece on 2017/9/20.
 * 日志服务
 */
@Service
public class PayLogService {

    @Autowired
    private PayLogDao payLogDao;


    public String onepayType = "0"; //诊断支付
    public String pushType = "3"; //推送
    public String onepayRecipeType = "1";     //1续方支付
    public String shoppatType="2";//商城支付

    /**
     * 保存http调用日志  type 1续方支付
     */
    public void saveHttpLog(Boolean isSuccess,String url,String content,String method,String header,String params,String response,String error,String type)
    {
        try {
                //新增日志
                PayLog log = new PayLog();
                log.setType(type);
                log.setApi(url);
                log.setContent(content);
                log.setMethod(method);
                log.setHeader(header);
                log.setParams(params);
                log.setCreateTime(new Date());
                log.setResponse(response);
                log.setError(error);
                log.setStatus(isSuccess?"1":"0");
                payLogDao.save(log);
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
    }


}
