package com.ym.mec.collectfee.controller;

import com.alibaba.fastjson.JSON;
import com.ym.mec.collectfee.entity.Order;
import com.ym.mec.collectfee.service.OrderService;
import com.ym.mec.collectfee.utils.GenerateNum;
import com.ym.mec.collectfee.utils.yqpay.YqPayUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.math.BigDecimal;
import java.util.*;

//@ApiIgnore
@Controller
@RequestMapping("yqreg")
public class YqRegController {

    @Autowired
    private OrderService orderService;

    /**
     * 用户（商户）注册
     *
     * @param map
     * @return
     * @throws Exception
     */
   // @GetMapping("/per")
    public String per(ModelMap map) throws Exception {

        String notifyUrl = "http://47.99.212.176:9000/yqpay/notify"; //主动通知地址

        String seraialNumber = GenerateNum.getInstance().GenerateOrderNo();

        Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
        resultMap.put("type", "web");
        resultMap.put("returnUrl", "http://dev.dayaedu.com/");
        resultMap.put("seraialNumber", seraialNumber);
        resultMap.put("merType", "per");

        Map<String, Object> requestMap = new YqPayUtil(notifyUrl, resultMap).getRequestMap();
        map.addAttribute("info", requestMap);
        return "/reg/register";
    }

   // @GetMapping("/com")
    public String com(ModelMap map) throws Exception {
        String notifyUrl = "http://47.99.212.176:9000/yqpay/notify"; //主动通知地址

        String seraialNumber = GenerateNum.getInstance().GenerateOrderNo();

        Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
        resultMap.put("type", "H5");
        resultMap.put("returnUrl", "http://dev.dayaedu.com/");
        resultMap.put("seraialNumber", seraialNumber);
        resultMap.put("merType", "com");

        Map<String, Object> requestMap = new YqPayUtil(notifyUrl, resultMap).getRequestMap();
        map.addAttribute("info", requestMap);
        return "/reg/register";
    }

   // @GetMapping("/pcy")
    public String pcy(ModelMap map) throws Exception {
        String notifyUrl = "http://47.99.212.176:9000/yqpay/notify"; //主动通知地址

        String seraialNumber = GenerateNum.getInstance().GenerateOrderNo();

        Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
        resultMap.put("type", "H5");
        resultMap.put("returnUrl", "http://dev.dayaedu.com/");
        resultMap.put("seraialNumber", seraialNumber);
        resultMap.put("merType", "pcy");

        Map<String, Object> requestMap = new YqPayUtil(notifyUrl, resultMap).getRequestMap();
        map.addAttribute("info", requestMap);
        return "/reg/register";
    }

   // @GetMapping("/webcom")
    public String webcom(ModelMap map) throws Exception {
        String notifyUrl = "http://47.99.212.176:9000/yqpay/notify"; //主动通知地址

        String seraialNumber = GenerateNum.getInstance().GenerateOrderNo();

        Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
        resultMap.put("type", "web");
        resultMap.put("returnUrl", "http://dev.dayaedu.com/");
        resultMap.put("seraialNumber", seraialNumber);
        resultMap.put("merType", "com");

        Map<String, Object> requestMap = new YqPayUtil(notifyUrl, resultMap).getRequestMap();
        map.addAttribute("info", requestMap);
        return "/reg/register";
    }

   // @GetMapping("/webper")
    public String webper(ModelMap map) throws Exception {

        String notifyUrl = "http://47.99.212.176:9000/yqpay/notify"; //主动通知地址

        String seraialNumber = GenerateNum.getInstance().GenerateOrderNo();

        Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
        resultMap.put("type", "web");
        resultMap.put("returnUrl", "http://dev.dayaedu.com/");
        resultMap.put("seraialNumber", seraialNumber);
        resultMap.put("merType", "per");

        Map<String, Object> requestMap = new YqPayUtil(notifyUrl, resultMap).getRequestMap();
        map.addAttribute("info", requestMap);
        return "/reg/register";
    }

   // @GetMapping("/webpcy")
    public String webpcy(ModelMap map) throws Exception {
        String notifyUrl = "http://47.99.212.176:9000/yqpay/notify"; //主动通知地址

        String seraialNumber = GenerateNum.getInstance().GenerateOrderNo();

        Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
        resultMap.put("type", "web");
        resultMap.put("returnUrl", "http://dev.dayaedu.com/");
        resultMap.put("seraialNumber", seraialNumber);
        resultMap.put("merType", "pcy");

        Map<String, Object> requestMap = new YqPayUtil(notifyUrl, resultMap).getRequestMap();
        map.addAttribute("info", requestMap);
        return "/reg/register";
    }



}
