package com.saye.hrs.service.impl;

import com.saye.hrs.mapper.WxPayMapper;
import com.saye.hrs.model.WxResult;
import com.saye.hrs.model.WxybResult;
import com.saye.hrs.service.WxPayService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/***
 * @title WxPayServiceImpl
 * @description TODO 请填写注释
 * @author thuang
 * @create 2023/8/15 9:41
 **/
@Service
public class WxPayServiceImpl implements WxPayService {

    @Resource
    private WxPayMapper wxPayMapper;
    @Override
    public void addWxPayInfo(WxResult reqDTO) {
        wxPayMapper.addWxPayInfo(reqDTO);
    }

    @Override
    public WxResult findWxPayInfo(WxResult reqDTO) {

        return wxPayMapper.findWxPayInfo(reqDTO);
    }

    @Override
    public void addWxybPayInfo(WxybResult reqDTO) {
        wxPayMapper.addWxybPayInfo(reqDTO);
    }

    @Override
    public WxybResult findWxybPayInfo(WxybResult reqDTO) {
        return wxPayMapper.findWxybPayInfo(reqDTO);
    }

    @Override
    public List<WxResult> getWxNotSendInfo(HashMap<Object,Object> map) {

        return wxPayMapper.getWxNotSendInfo(map);
    }

    @Override
    public List<WxybResult> getWxybNotSendInfo(HashMap<Object,Object> map) {

        return wxPayMapper.getWxybNotSendInfo(map);
    }

    @Override
    public void addOrderInfo(HashMap<Object, Object> map) {
        wxPayMapper.addOrderInfo(map);
    }

    @Override
    public void updateOrderInfoPay(HashMap<Object, Object> map) {
        wxPayMapper.updateOrderInfoPay(map);
    }

    @Override
    public void updateYBOrderInfoPay(HashMap<Object, Object> map) {
        wxPayMapper.updateYBOrderInfoPay(map);
    }

    @Override
    public void updateOrderInfoComplete(HashMap<Object, Object> map) {
        wxPayMapper.updateOrderInfoComplete(map);
    }

    @Override
    public List<HashMap<Object, Object>> findOrderInfo(HashMap<Object, Object> map) {
        List<HashMap<Object, Object>> orderInfoList = wxPayMapper.findOrderInfo(map);

        //转小写，保持和调用返回的一样
        List<HashMap<Object,Object>> newList= new ArrayList<>();
        for (HashMap<Object, Object> hashMap : orderInfoList) {
            HashMap<Object,Object> newMap=new HashMap<>();

            newMap.put("pat_id",hashMap.get("PAT_ID"));
            newMap.put("zfjsbz",hashMap.get("ZFJSBZ"));
            newMap.put("payOrdId",hashMap.get("PAYORDID"));
            newMap.put("payToken",hashMap.get("PAYTOKEN"));
            newMap.put("gmt_out_create",hashMap.get("GMT_OUT_CREATE"));
            newMap.put("detail",hashMap.get("DETAIL"));
            newMap.put("hosp_out_trade_no",hashMap.get("HOSP_OUT_TRADE_NO"));
            newMap.put("status",hashMap.get("STATUS"));
            newMap.put("appId",hashMap.get("APPID"));
            newMap.put("timeStamp",hashMap.get("TIMESTAMP"));
            newMap.put("nonceStr",hashMap.get("NONCESTR"));
            newMap.put("package",hashMap.get("PACKAGE"));
            newMap.put("signType",hashMap.get("SIGNTYPE"));
            newMap.put("paySign",hashMap.get("PAYSIGN"));
            newMap.put("pay_appid",hashMap.get("PAY_APPID"));
            newMap.put("pay_url",hashMap.get("PAY_URL"));
            newMap.put("med_trans_id",hashMap.get("MED_TRANS_ID"));
            newMap.put("out_ksmc",hashMap.get("OUT_KSMC"));
            newMap.put("status_name",hashMap.get("STATUS_NAME"));

            newList.add(newMap);
        }


        return newList;
    }

    @Override
    public void updateOrderInfoEnd(HashMap<Object, Object> map) {
        wxPayMapper.updateOrderInfoEnd(map);
    }
}
