Example #1
0
        /// <summary>
        /// 验证平台订单号是否存在重复
        /// </summary>
        /// <param name="Code">订单号</param>
        /// <param name="CacheTime">缓存时间</param>
        /// <returns></returns>
        private bool VerificationCode(string Code, int CacheTime, int appid)
        {
            bool   msg      = false;
            string Cachekey = "VerificationCode" + Code;

            if (JMP.TOOL.CacheHelper.IsCache(Cachekey))//判读是否存在缓存
            {
                PayApiDetailErrorLogger.DownstreamErrorLog("报错信息:商户发起重复下单请求,订单编号" + Code, summary: "接口错误信息,商户多次发起支付请求!", appId: appid, errorType: EnumForLogForApi.ErrorType.RequestRepeat);
            }
            else
            {
                JMP.TOOL.CacheHelper.CacheObjectLocak <string>(Code, Cachekey, CacheTime);//存入缓存
                msg = true;
            }
            return(msg);
        }
Example #2
0
        /// <summary>
        /// 验证商户订单号是否唯一
        /// </summary>
        /// <param name="bizcode">商户订单号</param>
        /// <param name="appid">应用id</param>
        /// <returns></returns>
        private bool VerificationCode(string bizcode, int appid)
        {
            bool IsRepeat = false;

            JMP.MDL.jmp_order mode     = new JMP.MDL.jmp_order();
            JMP.BLL.jmp_order bll      = new JMP.BLL.jmp_order();
            string            Cachekey = "VerificationCode" + bizcode + appid;

            if (JMP.TOOL.CacheHelper.IsCache(Cachekey))//判读是否存在缓存
            {
                PayApiDetailErrorLogger.DownstreamErrorLog("报错信息:支付接口验证参数错误,商户订单重复,缓存值:" + Cachekey + ",商户订单号:" + bizcode, summary: "接口错误信息", appId: appid, errorType: EnumForLogForApi.ErrorType.OrderNoRepeat);
                IsRepeat = true;
            }
            else
            {
                IsRepeat = false;
            }
            return(IsRepeat);
        }
Example #3
0
        /// <summary>
        /// 根据订单编号查询订单信息并调取支付当时
        /// </summary>
        /// <param name="Code">订单编号</param>
        /// <param name="json">接受参数json字符串</param>
        /// <param name="ip">请求ip地址</param>
        /// <returns></returns>
        private JMP.MDL.jmp_order SelectCode(string Code, int CacheTime, string paytype)
        {
            JMP.MDL.jmp_order mode     = new JMP.MDL.jmp_order();
            JMP.BLL.jmp_order bll      = new JMP.BLL.jmp_order();
            string            Cachekey = "SelectCode" + Code + paytype;

            if (JMP.TOOL.CacheHelper.IsCache(Cachekey))//判读是否存在缓存
            {
                if (paytype == "4")
                {
                    mode = JMP.TOOL.CacheHelper.GetCaChe <JMP.MDL.jmp_order>(Cachekey);//获取缓存
                }
                else
                {
                    JMP.MDL.jmp_order moded = new JMP.MDL.jmp_order();
                    moded = JMP.TOOL.CacheHelper.GetCaChe <JMP.MDL.jmp_order>(Cachekey);//获取缓存
                    PayApiDetailErrorLogger.DownstreamErrorLog("报错信息:商户发起重复下单请求,订单编号" + Code, summary: "接口错误信息,商户多次发起支付请求!", appId: moded.o_app_id, errorType: EnumForLogForApi.ErrorType.RequestRepeat);
                    mode = null;
                }
                //mode = JMP.TOOL.CacheHelper.GetCaChe<JMP.MDL.jmp_order>(Cachekey);//获取缓存
                //if (mode == null)
                //{
                //    mode = bll.GetModelbycode(Code, "jmp_order");
                //    if (mode != null)
                //    {
                //        JMP.TOOL.CacheHelper.CacheObjectLocak<JMP.MDL.jmp_order>(mode, Cachekey, CacheTime);//存入缓存
                //    }
                //}
            }
            else
            {
                mode = bll.SelectCode(Code, "jmp_order");
                if (mode != null)
                {
                    JMP.TOOL.CacheHelper.CacheObjectLocak <JMP.MDL.jmp_order>(mode, Cachekey, CacheTime);//存入缓存
                }
            }
            return(mode);
        }
Example #4
0
        /// <summary>
        /// 验证数据是否合法(需要使用查询数据)
        /// </summary>
        /// <param name="mode">请求参数实体</param>
        /// <param name="json">参数json字符串</param>
        /// <param name="app">应用实体</param>
        /// <returns></returns>
        private InnerResponse ValidationApp(RequestParameter mode, string json, jmp_app app)
        {
            InnerResponse Inn = new InnerResponse();

            try
            {
                if (app == null)
                {
                    return(Inn = Inn.ToResponse(ErrorCode.Code9998));
                }
                //验证签名的方式  price + bizcode+timestamp+appkey
                string Verificationsign = mode.price + mode.bizcode + mode.timestamp + app.a_key;
                string sign             = JMP.TOOL.MD5.md5strGet(Verificationsign, true).ToUpper();
                if (mode.sign != sign)
                {
                    PayApiDetailErrorLogger.DownstreamErrorLog("报错信息9989:支付接口签名验证失败,获取到的参数:" + json + ",组装的签名字符串:" + Verificationsign + ",我们生产的签名:" + sign, summary: "接口错误信息", appId: app.a_id, errorType: EnumForLogForApi.ErrorType.Other);

                    return(Inn = Inn.ToResponse(ErrorCode.Code9989));
                }
                //判断终端唯一标示码。ios和安卓模式为必传
                if (app.a_platform_id < 3 && app.a_platform_id > 0)
                {
                    if (string.IsNullOrEmpty(mode.termkey) || mode.termkey.Length > 64)
                    {
                        return(Inn = Inn.ToResponse(ErrorCode.Code9996));
                    }
                }
                else
                {
                    mode.termkey = "";
                }
                if (string.IsNullOrEmpty(mode.address))
                {
                    mode.address = app.a_notifyurl;
                }
                else
                {
                    if (mode.address.Length > 200)
                    {
                        return(Inn = Inn.ToResponse(ErrorCode.Code9995));
                    }
                }

                if (app.a_platform_id == 3)
                {
                    if (string.IsNullOrEmpty(mode.showaddress))
                    {
                        mode.showaddress = app.a_showurl;
                    }
                    else
                    {
                        if (mode.showaddress.Length > 200)
                        {
                            return(Inn = Inn.ToResponse(ErrorCode.Code9994));
                        }
                    }
                }

                if (mode.paytype < 0 || mode.paytype > 8)
                {
                    return(Inn = Inn.ToResponse(ErrorCode.Code9990));
                }
                else
                {
                    if (mode.paytype > 0 && !app.a_paymode_id.Contains(mode.paytype.ToString()))
                    {
                        return(Inn = Inn.ToResponse(ErrorCode.Code105));
                    }
                    else
                    {
                        pr.ThispayType = app.a_paymode_id;
                    }
                }
                Inn = Inn.ToResponse(ErrorCode.Code100);
            }
            catch (Exception e)
            {
                PayApiGlobalErrorLogger.Log("报错信息103:支付接口验证参数错误,获取到的参数:" + json + ",报错信息:" + e.ToString(), summary: "接口错误信息");
                Inn = Inn.ToResponse(ErrorCode.Code103);
            }
            return(Inn);
        }
Example #5
0
        /// <summary>
        /// H5和收银台模式下单主通道
        /// </summary>
        /// <param name="mode">接受参数modes实体</param>
        /// <param name="CacheTime"></param>
        /// <param name="ip"></param>
        /// <returns></returns>
        public InnerResponse H5OrBankEntrance(PayBankModels mode, int CacheTime, string ip)
        {
            InnerResponse Inn = new InnerResponse();

            if (mode != null)
            {
                Inn = InspectParameter(mode);
                if (Inn.Success == true)
                {
                    JMP.MDL.jmp_order mod = new JMP.MDL.jmp_order();
                    mod = SelectCode(mode.code, CacheTime, mode.paytype);
                    if (mod != null && mod.o_state == 0)
                    {
                        Inn = checkSign(mode, mod);
                        if (Inn.Success == true)
                        {
                            Apprate apprate = new Apprate();
                            if (Int32.Parse(mode.paytype) > 0 && !apprate.SelectApprate(mod.o_app_id, Int32.Parse(mode.paytype), CacheTime))
                            {
                                return(Inn = Inn.ToResponse(ErrorCode.Code8987));
                            }
                            if (UpdateCode(mod.o_id, int.Parse(mode.paytype)))
                            {
                                try
                                {
                                    JmPayParameter.PayTypeFactory.PayTypeFactory payTypeFactory = new PayTypeFactory.PayTypeFactory();
                                    var payType = payTypeFactory.Create(int.Parse(mode.paytype));
                                    if (mode.paytype == "4" && (mode.paymode == 2 || mode.paymode == 1))
                                    {
                                        mode.paymode = 3;
                                    }
                                    var channel = payType.LoadChannel(mode.paymode, mode.apptype, CacheTime, mod.o_app_id);
                                    JmPayParameter.PlaceOrder.PlaceOrderFactory placeOrderFactory = new PlaceOrder.PlaceOrderFactory();
                                    //返回支付信息
                                    Inn = placeOrderFactory.Create(channel.PassName, mode.paymode, mode.apptype, mode.code, mode.goodsname, mode.price, mod.o_id, ip, mod.o_app_id);
                                }
                                catch (Exc e)
                                {
                                    Inn = e.Response;
                                    return(Inn);
                                }
                            }
                            else
                            {
                                PayApiDetailErrorLogger.DownstreamErrorLog("报错信息:支付接口收银台模式报错,修改订单失败:订单id:" + mod.o_id + ",支付方式:" + mode.paymode + ",订单编号:" + mode.code, summary: "接口错误信息", appId: mod.o_app_id, errorType: EnumForLogForApi.ErrorType.RequestRepeat);
                                Inn = Inn.ToResponse(ErrorCode.Code8999);
                            }
                        }
                    }
                    else
                    {
                        Inn = Inn.ToResponse(ErrorCode.Code8991);
                    }
                }
            }
            else
            {
                PayApiGlobalErrorLogger.Log("报错信息103:支付接口收银台模式报错,未获取到下单参数,接收参数的实体为空", summary: "接口错误信息");
                Inn = Inn.ToResponse(ErrorCode.Code103);
            }
            return(Inn);
        }