package com.chinacreator.video.service;

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

import com.chinacreator.video.mapper.*;
import net.sf.json.JSONArray;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chinacreator.video.bean.ChannelBean;
import com.chinacreator.video.bean.CpSpBean;
import com.chinacreator.video.bean.OrderInfo;
import com.chinacreator.video.exception.BussinessException;
import com.chinacreator.video.restful.util.HttpInvoke;
import com.chinacreator.video.util.DesUtil;
import com.chinacreator.video.util.MD5;
import com.chinacreator.video.util.URLUtil;
import com.chinacreator.video.validate.ChannelValidate;
import com.chinacreator.video.validate.IpValidate;
import com.chinacreator.video.validate.TimetampValidate;

/**
 * 畅视2元C+组合产品
 * @author xu.zhou
 * @date 20200323
1170	changshi	联通2元畅视业务
1172	changshi	畅视2元超级包
1174	changshi	联通2元畅视业务（上海权益）
1175	changshi	畅视2元超级包（上海权益）

对应新SPID
1176	changshi	联通2元畅视业务	联通2元畅视业务（C+会员前向）
1177	changshi	畅视2元超级包	畅视2元超级包（C+会员前向）
1178	changshi	联通2元畅视业务	联通2元畅视业务（C+会员后向）
1179	changshi	畅视2元超级包	畅视2元超级包（C+会员后向）
 */
@Component
public class CsmakeupOrderService {
    private static final  Logger logger = LoggerFactory.getLogger(CsmakeupOrderService.class);

    private static final  Logger log = LoggerFactory.getLogger("csmakeup");

    @Autowired
    private CpSpDao CpSpDao;

    @Autowired
    private DictionaryDao dictionaryDao;

    @Autowired
    private ChannelDao channelDao;

    @Autowired
    private ChannelValidate channelValidate;

    @Autowired
    private IpValidate ipValidate;

    @Autowired
    private TimetampValidate timetampValidate;

    @Autowired
    private CsmakeupDao csmakeupDao;

    @Autowired
    CommonService commonService;

    @Autowired
    private CommConfDao commConfDao;

    public void busiCheck(OrderInfo orderInfo) throws Exception{

        valiParams(orderInfo);

        //timetamp验证
        timetampValidate.validate(orderInfo.getTimestamp());
        //渠道验证
        channelValidate.validate(orderInfo.getChannel());
        //ip验证
        ipValidate.volidate(orderInfo);
        //签名验证
        signValidate(orderInfo);
        //验证是否有业务配置
        valiBusiParams(orderInfo);
        //手机号码验证
        mobileVali(orderInfo);
		//省份办理限制验证
		commonService.valiChannelSpidLimit(orderInfo);
        //并发限制
        vistVali(orderInfo);
    }

    /**
     * 验证是否有业务配置
     * @param orderInfo
     * @return
     * @throws Exception
     */
    private void valiBusiParams(OrderInfo orderInfo) throws Exception {
        List<HashMap> list = csmakeupDao.getBusiConf(orderInfo.getSpid());
        if(list == null || list.size() == 0){
            throw new BussinessException("9058", "无业务配置信息");
        }else{
            HashMap conf = list.get(0);
            if(!conf.get("CPID").equals(orderInfo.getCpid())){
                throw new BussinessException("9058", "无业务配置信息");
            }
            orderInfo.setData(conf);
        }
    }

    /**
     * 手机号码验证
     * @param orderInfo
     * @param spid
     * @throws Exception
     */
    private void mobileVali(OrderInfo orderInfo) throws Exception {
        HashMap conf = (HashMap)orderInfo.getData();
        String spid = (String)conf.get("SPID");
        String userid = orderInfo.getUserid();
        if(StringUtils.isEmpty(userid)) {
            throw new BussinessException("10007", "手机号不能为空");
        }
        //业务类型, 1畅视+会员, 2纯会员, 3纯畅视
        if("1".equals(conf.get("BUSITYPE")) || "3".equals(conf.get("BUSITYPE"))){
            CpSpBean cpSpBean = CpSpDao.getCpSp(orderInfo.getCpid(), spid);
            if(cpSpBean == null) {
                throw new BussinessException("10010", "cpid/spid错误");
            }
        }

        ChannelBean channelBean = channelDao.queryChannel(orderInfo.getChannel());
        try {
            userid = DesUtil.decode(userid, channelBean.getPassword());
            if(userid.length() == 11 && isValid(userid)){
                orderInfo.setUserid(userid);
            }else{
                throw new BussinessException("10007", "手机号错误");
            }
        } catch (Exception e) {
            if(e instanceof BussinessException) {
                throw e;
            }else {
                throw new BussinessException("10007", "手机号加密错误");
            }
        }
    }

    /**
     * 支持QQ号与手机号
     * zzb 2020/02/18
     * @throws BussinessException
     */
    private boolean isValid(String usermob){
        if (usermob == null) {
            return false;
        }
        usermob = usermob.replaceAll("[\\s-]", "");
        if(!usermob.matches("^[0-9]*$")){
            return false;
        }
        return true;
    }
    /**
     * 签名验证
     * @param orderInfo
     * @throws Exception
     */
    public void signValidate(OrderInfo orderInfo) throws Exception {
        String lcalsign = getSign(orderInfo);
        lcalsign += channelDao.queryChannel(orderInfo.getChannel()).getPassword();
        lcalsign = MD5.MD5Encode(lcalsign);
        if(!lcalsign.equals(orderInfo.getSignature())) {
            throw new BussinessException("10006", "签名校验失败");
        }
    }

    /**
     * 参数验证
     * @param orderInfo
     * @throws Exception
     */
    private void valiParams(OrderInfo orderInfo) throws Exception{
        String cpid = orderInfo.getCpid();
        String spid = orderInfo.getSpid();
        String channel = orderInfo.getChannel();
        String userid = orderInfo.getUserid();
        String timestamp = orderInfo.getTimestamp();
        String orderid = orderInfo.getOrderid();
        String type = orderInfo.getType();
        String usertype = orderInfo.getUsertype();
        if(StringUtils.isEmpty(orderid) || StringUtils.isEmpty(cpid) || StringUtils.isEmpty(spid)
                || StringUtils.isEmpty(userid) || StringUtils.isEmpty(timestamp) || StringUtils.isEmpty(channel)
                || (!"0".equals(type) && !"1".equals(type))) {
            throw new BussinessException("80015", "参数不合法");
        }
        if("1".equals(type) && (!"0".equals(usertype) && !"1".equals(usertype))){
            throw new BussinessException("80015", "参数不合法，usertype=>"+usertype);
        }
    }

    /**
     * 拼接签名信息 cpid+spid+userid+type+channel+timestamp
     * @param orderInfo
     * @return
     */
    private String getSign(OrderInfo orderInfo) {
        if (orderInfo == null) {
            return "";
        }
        StringBuilder strb = new StringBuilder();
        strb.append(orderInfo.getOrderid());
        strb.append(orderInfo.getCpid());
        strb.append(orderInfo.getSpid());
        strb.append(orderInfo.getUserid());
        strb.append(orderInfo.getType());
        strb.append(orderInfo.getUsertype());
        strb.append(orderInfo.getChannel());
        strb.append(orderInfo.getTimestamp());
        return strb.toString();
    }

    /**
     * 业务办理
     * @param orderInfo
     * @throws Exception
     */
    public void busiProc(OrderInfo orderInfo)throws Exception {
        String resultcode = "";
        String errorinfo = "";
        try{
            String seno = csmakeupDao.getNo(); //获取业务流水号
            HashMap conf = (HashMap)orderInfo.getData();
            conf.put("SENO", seno);
            conf.put("STARTTIME", System.currentTimeMillis());

            //验证订单
            valiOrder(orderInfo);

            //业务类型, 1畅视+会员, 2纯会员, 3纯畅视
            String busitype = conf.get("BUSITYPE").toString();
            if("0".equals(orderInfo.getType())){//订购
                if("1".equals(busitype)){//1畅视+会员
                    invokeTwvip(orderInfo);
                    String orderUrl = getOrderUrl(orderInfo);
                    conf.put("INVOKEURL", orderUrl);
                    String result = doHandle(orderUrl);
                    if(!JSON.parseObject(result).get("resultcode").equals("0")) {
                        throw new BussinessException(JSON.parseObject(result).get("resultcode").toString(),JSON.parseObject(result).get("errorinfo").toString());
                    }
                }else if("2".equals(busitype)){//2纯会员
                    invokeTwvip(orderInfo);
                }else if("3".equals(busitype)){//3纯畅视
                    String orderUrl = getOrderUrl(orderInfo);
                    conf.put("INVOKEURL", orderUrl);
                    String result = doHandle(orderUrl);
                    if(!JSON.parseObject(result).get("resultcode").equals("0")) {
                        throw new BussinessException(JSON.parseObject(result).get("resultcode").toString(),JSON.parseObject(result).get("errorinfo").toString());
                    }
                }else{
                    throw new BussinessException("9058", "此产品暂未开放");
                }
            }else{//退订
                if("1".equals(conf.get("HASCANCEL"))){//不能退订
                    throw new BussinessException("80015", "参数异常，此业务不能退订");
                }
                if("1".equals(busitype)){//1畅视+会员
                    invokeTwvip(orderInfo);
                    String orderUrl = getOrderUrl(orderInfo);
                    conf.put("INVOKEURL", orderUrl);
                    String result = doHandle(orderUrl);
                    if(!JSON.parseObject(result).get("resultcode").equals("0")) {
                        throw new BussinessException(JSON.parseObject(result).get("resultcode").toString(),JSON.parseObject(result).get("errorinfo").toString());
                    }
                }else if("2".equals(busitype)){//2纯会员
                    invokeTwvip(orderInfo);
                }else if("3".equals(busitype)){//3纯畅视
                    String orderUrl = getOrderUrl(orderInfo);
                    conf.put("INVOKEURL", orderUrl);
                    String result = doHandle(orderUrl);
                    if(!JSON.parseObject(result).get("resultcode").equals("0")) {
                        throw new BussinessException(JSON.parseObject(result).get("resultcode").toString(),JSON.parseObject(result).get("errorinfo").toString());
                    }
                }else{
                    throw new BussinessException("9058", "此产品暂未开放");
                }
            }
            resultcode = "0";
            errorinfo = "ok";
        }catch(Exception e){
            e.printStackTrace();
            resultcode = "8000";
            errorinfo = "出现异常，"+e.getMessage();
            if(e instanceof BussinessException) {
                resultcode = ((BussinessException) e).getCode();
                errorinfo = ((BussinessException) e).getMessage();
            }

            throw e;
        }finally{
            //添加订购记录
            addOrderRec(orderInfo, resultcode, errorinfo);
        }
    }

    /**
     * 添加订购记录
     * @param orderInfo
     * @param resultcode
     * @param errorinfo
     */
    private void addOrderRec(OrderInfo orderInfo, String resultcode, String errorinfo){
        try{
            commonService.setAreaInfo(orderInfo);
            HashMap conf = (HashMap)orderInfo.getData();
            conf.put("ENDTIME", System.currentTimeMillis());
            HashMap<String, String> rec = new HashMap<String, String>();
            if(conf.get("SENO") == null){
                rec.put("ID", csmakeupDao.getNo());
            }else{
                rec.put("ID",conf.get("SENO").toString());
            }
            rec.put("USERID",orderInfo.getUserid());
            rec.put("ORDERID",orderInfo.getOrderid());
            rec.put("CHANNEL",orderInfo.getChannel());
            rec.put("CPID",orderInfo.getCpid());
            rec.put("MUSPID",orderInfo.getSpid());
            rec.put("PROVINCE",orderInfo.getProvince() == null ? "" : orderInfo.getProvince());
            rec.put("AREA",orderInfo.getArea() == null ? "" : orderInfo.getArea());
            rec.put("VIPRECODE",conf.get("VIPRECODE") == null ? "" : conf.get("VIPRECODE").toString());
            String vipreinfo = conf.get("VIPREINFO") == null ? "" : conf.get("VIPREINFO").toString();
            if (vipreinfo != null && vipreinfo.length() > 500){
            	vipreinfo = vipreinfo.substring(0, 500);
            }
            rec.put("VIPREINFO",vipreinfo);

            rec.put("RESULTCODE",resultcode);
            rec.put("RESULTINFO",errorinfo);
            try{
            	rec.put("TIMES",((Long.parseLong(conf.get("ENDTIME")+"")-Long.parseLong(conf.get("STARTTIME")+"")))+"");
            }catch(Exception ee){
            	rec.put("TIMES","");
            }
            rec.put("STATUS","0");//订购
            if("1".equals(orderInfo.getType())){
                rec.put("STATUS","1");//退订
            }
            //log.info("rec=>"+rec);
            csmakeupDao.addOrderRec(rec);
        }catch(Exception e){
            e.printStackTrace();
            log.error("记录订购数据出现异常，"+e.getMessage());
        }
    }

    /**
     * 拼接转发URL参数
     * @param orderInfo
     * @return
     * @throws BussinessException
     */
    private String getParams(OrderInfo orderInfo) throws Exception{
        String params = "";
        HashMap conf = (HashMap)orderInfo.getData();
        String cpid = orderInfo.getCpid();
        String spid = conf.get("SPID").toString(); //orderInfo.getSpid();
        String type = orderInfo.getType();
        String userid = orderInfo.getUserid();
        String timestamp = orderInfo.getTimestamp();
        String orderid = orderInfo.getOrderid();
        String channel = orderInfo.getChannel();
        String pwd = CpSpDao.getCpSp(orderInfo.getCpid(), spid).getPwd(); //TB_CP_ACCOUNT_CONFIG表NETPWD字段
        String signature = "";
        if("0".equals(conf.get("HASCANCEL"))){//可以退订，1170畅视2元业务，1172畅视2元超级包
            params += "orderid="+orderid+"&cpid="+cpid+"&apptype=2&spid="+spid+"&type="+type+"&channel="+channel+"&timestamp="+timestamp;
            userid = DesUtil.encode(userid, pwd); //手机号码加密
            signature = MD5.MD5Encode(orderid + type + cpid + spid + userid + pwd + timestamp);
        }else{//上海权益后向产品，1174，1175
            params += "orderid="+orderid+"&ordertype=0&apptype=2&channel="+channel+"&cpid="+cpid+"&spid="+spid+"&timestamp="+timestamp;
            userid = DesUtil.encode(userid, pwd); //手机号码加密
            signature = MD5.MD5Encode(orderid + cpid + spid + userid + timestamp + pwd);
        }
        params += "&userid="+URLEncoder.encode(userid, "utf-8")+"&signature="+signature; //重新编码

        return params;
    }

    /**
     * 获取订购url
     * @param orderInfo
     * @return
     * @throws Exception
     */
    public String getOrderUrl(OrderInfo orderInfo) throws Exception {
        HashMap conf = (HashMap)orderInfo.getData();
        String orderUrl = "";
        if("0".equals(conf.get("HASCANCEL"))){//可以退订，1170畅视2元业务，1172畅视2元超级包
            orderUrl = dictionaryDao.getValue("tcpreOrderUrl")+"tcpreOrder.do?";
            //orderUrl = "http://172.16.33.16:8082/videoif/"+"tcpreOrder.do?";
        }else{//上海权益后向产品，1174，1175
            orderUrl = dictionaryDao.getValue("commonOrderUrl")+"backorder.do?";
            //orderUrl = "http://172.16.33.16:8082/videoif/"+"backorder.do?";
        }
        orderUrl += this.getParams(orderInfo);
        return orderUrl;
    }

    /**
     * 验证订单
     * @param orderInfo
     */
    private void valiOrder(OrderInfo orderInfo)throws Exception{
        List<HashMap> list = csmakeupDao.getOrderByOrderid(orderInfo.getOrderid());
        if(list != null && list.size()>0){
            throw new BussinessException("9110", "重复订单");
        }

        HashMap conf = (HashMap)orderInfo.getData();
        String spid = (String)conf.get("SPID"); //获取真正的spid
        String busitype = (String)conf.get("BUSITYPE"); //业务类型, 1畅视+会员, 2纯会员, 3纯畅视
        //是否可以重复订购, 0是, 1否，只能退订后再重新订购
        String hasreorder = (String)conf.get("HASREORDER");
        //是否可以退订，0是，1否
        String hascancel = (String)conf.get("HASCANCEL");

        if("2".equals(busitype)){//纯会员
            return;
        }
        //查询订购关系表的订购状态或业务互斥状态
        HashMap orderMap = commonService.getOrderStatus(orderInfo.getUserid(), spid);
        boolean hasmutual = (Boolean)orderMap.get("HASMUTUAL"); //是否业务互斥
        String orderstatus = (String)orderMap.get("ORDERSTATUS"); //当前订购状态，空为未订购，0已订购，1已退订，2已失效
        if("0".equals(orderInfo.getType())){//订购
            //判断业务是否互斥
            if((Boolean)orderMap.get("HASMUTUAL")){
                throw new BussinessException("9117", "已办理互斥业务");
            }

            if("1".equals(hasreorder) && "0".equals(orderstatus)){
                throw new BussinessException("9115", "已有订购关系，不能重复订购");
            }
        }else{//退订
            if("1".equals(hascancel)){//不能退订
                throw new BussinessException("80015", "参数异常，此业务不能退订");
            }
            if(!"0".equals(orderstatus)){//当前不是订购状态
                throw new BussinessException("9118","未订购，不能退订");
            }
        }

        //判断是否订购了组合产品
        hasOrderMUSPID(orderInfo);
    }

    /**
     * 调拓维会员接口
     * @param orderInfo
     * @throws Exception
     */
    private void invokeTwvip(OrderInfo orderInfo) throws Exception{
        boolean res = false;
        HashMap conf = (HashMap)orderInfo.getData();
        String vipurl = "";
        String jsonParams = "";
        if("1".equals(orderInfo.getType())){//退订
            vipurl = dictionaryDao.getValue("csmakeupvipcancelurl");
            jsonParams = this.fullCancelParams(orderInfo);
        }else{//订购
            vipurl = dictionaryDao.getValue("csmakeupviporderurl");
            jsonParams = this.fullOrderParams(orderInfo);
        }
        log.info("vipurl=>"+vipurl+", jsonParams=>"+jsonParams);
        //String result = ""; //调拓维会员接口返回结果
        //if("0".equals(orderInfo.getType())){//订购
        //result = URLUtil.postJson(vipurl, jsonParams);
        //}else{//退订
        //result = URLUtil.postForm(vipurl, jsonParams);
        //}
        String result = HttpInvoke.sendhttpsReq("POST", vipurl, jsonParams, getProperty(orderInfo.getType()));
        log.info("调拓维会员接口返回结果："+result);
        //去空格、换行符号
        if(result != null) result = result.replaceAll("\r|\n", "").replaceAll("	", "").replaceAll(" ", "");

        //result = "{\"code\":0,\"message\":\"成功\",\"success\":true}";
        //result = "{\"code\":7007,\"message\":\"签名无效\",\"success\":false}";
        conf.put("VIPREINFO", result);

        if(StringUtils.isEmpty(result)) {
            throw new BussinessException("9002","调拓维会员接口失败，返回信息为空");
        }
        try{
        	String viprecode = JSON.parseObject(result).get("code").toString();
        	//String vipreinfo = JSON.parseObject(result).get("message").toString();
        	conf.put("VIPRECODE", viprecode);
        	//conf.put("VIPREINFO", vipreinfo);
            if("0".equals(viprecode)) {
                res = true;
            }
        }catch(Exception e){
            throw new BussinessException("9002","调拓维会员接口返回报文格式异常，"+e.getMessage());
        }
        if(!res){
            throw new BussinessException("9002","调拓维会员接口返回未成功");
        }
    }

    /**
     * 获取请求属性性
     * @return
     */
    private static Map getProperty(String type){
        Map reqProperty = new HashMap();
        if("0".equals(type)){//订购
            reqProperty.put("Content-type", "application/json;charset=utf-8");
        }else{//退订
            reqProperty.put("Content-type", "application/x-www-form-urlencoded");
        }

        return reqProperty;
    }

    /**
     * 填充订购会员参数
     * @param orderInfo
     * @return
     */
    private String fullOrderParams(OrderInfo orderInfo)throws Exception {
        HashMap conf = (HashMap)orderInfo.getData();
        String jsonParams = "";
        String timestamp = System.currentTimeMillis()+"";
        String spid = conf.get("VSPID").toString();
        String cpid = conf.get("VCPID").toString();
        String mobile = orderInfo.getUserid();
        String memberUrl = "";
        String orderNumber = conf.get("SENO").toString();
        String password = conf.get("VPWD").toString();
        mobile = DesUtil.encode(mobile, password); //手机号码加密
        String signature = MD5.MD5Encode(spid + cpid + orderNumber + timestamp + password);

        JSONObject json = new JSONObject();
        JSONArray jsonArray = new JSONArray();
        jsonArray.add(mobile);
        json.put("timestamp", timestamp);
        json.put("signature", signature);
        json.put("spid", spid);
        json.put("cpid", cpid);
        json.put("mobiles", jsonArray);
        json.put("memberUrl", memberUrl);
        json.put("orderNumber", orderNumber);
        jsonParams = json.toJSONString();

        return jsonParams;
    }

    /**
     * 填充退订会员参数
     * @param orderInfo
     * @return
     */
    private String fullCancelParams(OrderInfo orderInfo) throws Exception {
        HashMap conf = (HashMap)orderInfo.getData();
        String jsonParams = "";
        HashMap<String, String> params = new HashMap<String, String>();
        String timestamp = System.currentTimeMillis()+"";
        String spid = conf.get("VSPID").toString();
        String cpid = conf.get("VCPID").toString();
        String mobile = orderInfo.getUserid();
        String userType = orderInfo.getUsertype();
        String password = conf.get("VPWD").toString();
        mobile = DesUtil.encode(mobile, password); //手机号码加密
        String refundTime = orderInfo.getCanceltime();
        String signature = MD5.MD5Encode(spid + cpid + mobile + timestamp + userType + password);
        signature = MD5.MD5Encode(spid + cpid + mobile + refundTime + userType + timestamp + password);

        JSONObject json = new JSONObject();
        json.put("timestamp", timestamp);
        json.put("signature", signature);
        json.put("spid", spid);
        json.put("cpid", cpid);
        json.put("mobile", mobile);
        json.put("userType", userType);
        json.put("refundTime", refundTime);
        jsonParams = json.toJSONString();
        //去除json格式
        jsonParams = jsonParams.replaceAll(":", "=").replaceAll(",", "&")
                .replaceAll("\"", "").replaceAll("\\{", "").replaceAll("\\}", "");
        return jsonParams;
    }

    public String doHandle(String url) throws Exception {
        return  URLUtil.get(url,0);
    }

    /**
     * 退订时判断是否订购了组合产品
     * @param orderInfo
     * @throws Exception
     */
    public void hasOrderMUSPID(OrderInfo orderInfo) throws Exception {
        HashMap conf = (HashMap)orderInfo.getData();
        //是否可以重复订购, 0是, 1否，只能退订后再重新订购
        String hasreorder = (String)conf.get("HASREORDER");
        String orderstatus = ""; //订购状态，0已订购，1已退订
        List<HashMap> orderList = csmakeupDao.getOrderRec(orderInfo.getUserid(), orderInfo.getSpid());
        if(orderList != null && orderList.size()> 0){
            HashMap tmphm = orderList.get(0);
            orderstatus = (String)tmphm.get("STATUS");
            if("1".equals(orderInfo.getType()) && "1".equals(orderstatus)){//当前是退订状态，再次退订
                throw new BussinessException("9118","已退订组合产品，不能重复退订");
            }else if("0".equals(orderInfo.getType()) && "1".equals(hasreorder) && "0".equals(orderstatus)){//不能重复订购，当前是订购状态，再次订购
                String spid = (String)conf.get("SPID");
                if("1184".equals(spid)){
                    System.out.println("---spid---"+spid);
                    System.out.println("---userid---"+orderInfo.getUserid());
                    System.out.println("---cpid---"+orderInfo.getCpid());
                    HashMap map = commConfDao.findOrderRela(orderInfo.getUserid(),orderInfo.getCpid(),spid);
                    if("2".equals(map.get("STATUS"))){

                    }else{
                        throw new BussinessException("9115", "已订购组合产品，不能重复订购");
                    }
                }else{

                    throw new BussinessException("9115", "已订购组合产品，不能重复订购");
                }

            }
        }else{
            if("1".equals(orderInfo.getType())){
                throw new BussinessException("9118","未订购组合产品，不能退订");
            }
        }
    }

    /**
     * 验证访问限制，1分钟内同一业务只能办理一次
     * @param orderInfo
     * @throws Exception
     */
    private void vistVali(OrderInfo orderInfo) throws Exception {
        String [] params = new String [3];
        params[0] = orderInfo.getChannel();
        params[1] = orderInfo.getSpid();
        params[2] = orderInfo.getUserid();
        if(commonService.vistVali(params, "csmakeup")){
            throw new BussinessException("8000", "指定时间内重复请求");
        }
    }
}
