Exemplo n.º 1
0
        /// <summary>
        /// 判断支付平台,根据支付平台返回对应信息
        /// </summary>
        /// <param name="paytype">支付类型</param>
        /// <param name="paymode">关联平台(1:安卓,2:ios,3:H5)</param>
        /// <param name="apptype">风控配置表id</param>
        /// <param name="CacheTime">缓存时间</param>
        /// <param name="appid">应用id</param>
        /// <returns></returns>
        private InnerResponse judge(int paytype, int paymode, int apptype, int CacheTime, int appid)
        {
            InnerResponse Inn = new InnerResponse();

            JmPayParameter.JsonStr Jsonstr = new JsonStr();
            JmPayParameter.PayTypeFactory.PayTypeFactory payTypeFactory = new PayTypeFactory.PayTypeFactory();
            if (paytype == 0)
            {
                #region 收银台模式
                //收银台模式
                if (paymode == 3)
                {
                    PayBankModels modes = Jsonstr.ParameterEntity(pr.code, pr.goodsname, pr.price, pr.ThispayType, apptype, paymode);
                    //h5模式
                    Inn = Jsonstr.BankJsonStr(modes, pr.ip);
                    //设置为跳转模式
                    Inn.IsJump = true;
                }
                else
                {
                    //获取优先级设置(微信wap和微信appid根据优先级返回其中之一)
                    int SdkPriority = Int32.Parse(ConfigurationManager.AppSettings["SdkPriority"].ToString());
                    //判断收银台模式优先返回微信调用方式
                    if (SdkPriority == 2 && pr.ThispayType.Contains("2") && pr.ThispayType.Contains("5"))
                    {
                        pr.ThispayType = pr.ThispayType.Replace("5", "@").Replace(",@", "");
                    }
                    else if (SdkPriority == 5 && pr.ThispayType.Contains("2") && pr.ThispayType.Contains("5"))
                    {
                        pr.ThispayType = pr.ThispayType.Replace("2", "@").Replace(",@", "");
                    }

                    PayBankModels modes = Jsonstr.ParameterEntity(pr.code, pr.goodsname, pr.price, pr.ThispayType, apptype, paymode);
                    //sdk模式
                    Inn = Jsonstr.BankSdk(modes, pr.ip);
                }
                #endregion
            }
            else
            {
                if (paymode == 3)
                {
                    #region H5模式
                    if (paytype == 6 || paytype == 7)
                    {
                        try
                        {
                            var payType = payTypeFactory.Create(paytype);
                            var channel = payType.LoadChannel(paymode, apptype, CacheTime, appid);
                            JmPayParameter.PlaceOrder.PlaceOrderFactory placeOrderFactory = new PlaceOrder.PlaceOrderFactory();
                            //返回支付信息
                            Inn = placeOrderFactory.Create(channel.PassName, paymode, apptype, pr.code, pr.goodsname, pr.price, pr.orderid, pr.ip, appid);
                        }
                        catch (Exc e)
                        {
                            Inn = e.Response;
                            return(Inn);
                        }
                    }
                    else
                    {
                        PayBankModels modes = Jsonstr.ParameterEntity(pr.code, pr.goodsname, pr.price, paytype.ToString(), apptype, paymode);
                        //h5模式
                        Inn = Jsonstr.H5JsonStr(modes, pr.ip);
                        //设置为跳转模式
                        //Inn.IsJump = true;
                    }
                    #endregion
                }
                else
                {
                    #region sdk模式
                    //sdk模式
                    try
                    {
                        var payType = payTypeFactory.Create(paytype);
                        var channel = payType.LoadChannel(paymode, apptype, CacheTime, appid);
                        JmPayParameter.PlaceOrder.PlaceOrderFactory placeOrderFactory = new PlaceOrder.PlaceOrderFactory();
                        //返回支付信息
                        Inn = placeOrderFactory.Create(channel.PassName, paymode, apptype, pr.code, pr.goodsname, pr.price, pr.orderid, pr.ip, appid);
                    }
                    catch (Exc e)
                    {
                        Inn = e.Response;
                        return(Inn);
                    }
                    #endregion
                }
            }
            return(Inn);
        }
Exemplo n.º 2
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);
        }