Esempio n. 1
0
        //1.0.0
        public string ReceiveApi2(int cid = 0, int UserId = 0, decimal Amount = 0m, int BankID = 0, int PayType = 0)
        {
            Logs.WriteLog($"ReceiveApi2,cid:{cid},UserId:{UserId},Amount:{Amount},BankID:{BankID},PayType:{PayType}", "d:\\Log\\Yeepay", "ReceiveApi2");
            userEventDao.UserReceiveApi2(cid, UserId, Ip.GetClientIp(), 0, TQuery.GetString("version"), Amount, BankID, PayType);
            #region 参数验证
            if (UserId <= 0)
            {
                return(ApiReturnStr.getError(-100, "UserId参数错误"));
            }
            if (Amount < 500)
            {
                return(ApiReturnStr.getError(-100, "收款金额不能小于500元"));
            }

            var ubk = userBankCardDao.Single(BankID);
            if (ubk == null)
            {
                return(ApiReturnStr.getError(-100, "卡记录不存在"));
            }

            //卡数据验证
            var validateBankResult = userBankCardDao.ValidateBank(ubk);
            if (validateBankResult.backState != 0)
            {
                return(ApiReturnStr.getError(-100, validateBankResult.message));
            }

            var model = userDao.Single(UserId);
            if (model == null || model.UserId <= 0)
            {
                return(ApiReturnStr.getError(-100, "用户不存在"));
            }

            JObject data = new JObject();
            data["PayUrl"] = "";

            string msg = "";



            #region 测试通道
            //Thread.Sleep(3000);
            //int ChannelType = 4;
            //data["ChannelType"] = ChannelType;
            //data["BankID"] = BankID;
            //return ApiReturnStr.getApiData(-200, $"快捷协议未开通(03-{ChannelType})", data);
            #endregion

            #region  择通道
            int ChannelType = 0;
            //data["ChannelType"] = ChannelType;
            data["BankID"] = BankID;

            var option = SelectOptionChannel.Optimal(Amount, BankID, PayType);
            if (option.backState == 0)
            {
                ChannelType         = option.Data;
                data["ChannelType"] = ChannelType;
            }
            else
            {
                if (option.Data == 2)
                {
                    return(ApiReturnStr.getError(-100, "通道升级中,敬请期待"));
                }
                return(ApiReturnStr.getError(-100, option.message));
            }
            data["ChannelType"] = option.Data;
            #endregion


            if (Amount > 20000)
            {
                return(ApiReturnStr.getError(-100, "收款金额不能超过20000元"));
            }

            Logic.ChannelType ct = (Logic.ChannelType)ChannelType;
            switch (ct)
            {
            case Logic.ChannelType.易宝:
                #region 易宝逻辑
                var yeepayUser = yeepayUserDao.Single(" UserId=@UserId ", new { UserId });
                if (yeepayUser == null || model.UserId <= 0)
                {
                    return(ApiReturnStr.getError(-100, "未开通子商户功能"));
                }
                if (yeepayUser.RateState1 == 0 || yeepayUser.RateState3 == 0 || yeepayUser.RateState4 == 0 || yeepayUser.RateState5 == 0)
                {
                    return(ApiReturnStr.getError(-100, "费率未设置"));
                }
                if (yeepayUser.IsAudit == 0)
                {
                    return(ApiReturnStr.getError(-100, "子商户未审核通过"));
                }
                var result = YeepayDepository.ReceiveApi(UserId, Amount, cid, BankID);
                if (result.backState == 0)
                {
                    data["PayUrl"] = result.urlAES;
                    return(ApiReturnStr.getApiData(data));
                }
                msg = result.message;
                #endregion
                break;

            case Logic.ChannelType.荣邦科技积分:
            case Logic.ChannelType.荣邦科技无积分:
            case Logic.ChannelType.荣邦3:
                if (ChannelType == 2)
                {
                    return(ApiReturnStr.getError(-100, "通道升级中,敬请期待"));
                }
                #region 荣邦逻辑
                #region 验证
                if (Amount < 500)
                {
                    return(ApiReturnStr.getError(-100, "此通道要求支付金额不得小于500元!"));
                }
                //验证是否开户
                if (!masgetUserDao.QueryIsExist(UserId, ChannelType))
                {
                    return(ApiReturnStr.getApiData(-200, $"快捷协议未开通(01-{ChannelType})", data));                                                     //通道未开户
                }
                if (!masgetUserDao.QueryIsOpen(UserId, ChannelType))
                {
                    return(ApiReturnStr.getApiData(-200, $"快捷协议未开通(02-{ChannelType})", data));                                                    //通道未入驻
                }
                //验证快捷协议是否开通
                if (!bankTreatyApplyDao.QueryTreatycodeIsOpen(BankID, ChannelType))
                {
                    return(ApiReturnStr.getApiData(-200, $"快捷协议未开通(03-{ChannelType})", data));
                }
                #endregion
                //执行请求
                var resultBackPay = MasgetDepository.BackPay(BankID, Amount, cid, ct);
                if (resultBackPay.backState == 0)
                {
                    data["PayUrl"] = resultBackPay.url;
                    return(ApiReturnStr.getApiData(0, "请求成功,待确认支付", data));
                }
                else if (resultBackPay.backState == 8401)
                {
                    return(ApiReturnStr.getError(-8401, "通道暂无额度"));
                }
                else
                {
                    return(ApiReturnStr.getError(-100, resultBackPay.message));
                }

                #endregion
            case Logic.ChannelType.腾付通:
                var resultTeng = TengDepository.CreatePayCashier(UserId, cid, Amount, BankID);
                msg = resultTeng.message;
                if (resultTeng.backState == 0)
                {
                    data["PayUrl"] = resultTeng.Data["url"];
                    return(ApiReturnStr.getApiData(data));
                }
                break;

            case Logic.ChannelType.米刷:
                var resultMi = MiShuaDepository.PayDzero(BankID, cid, Amount);
                msg = resultMi.message;
                if (resultMi.backState == 0 && resultMi.Data.status == "00")
                {
                    data["PayUrl"] = resultMi.Data.tranStr;
                    return(ApiReturnStr.getApiData(data));
                }
                break;

            default:
                break;
            }

            #endregion

            return(ApiReturnStr.getError(-100, msg));
        }
Esempio n. 2
0
        public ActionResult Optimal(string BankCard, decimal Amount, int PayType)
        {
            var model = userBankCardDao.Single("BankCard=@BankCard", new { BankCard });

            return(View(SelectOptionChannel.Optimal(model.UserId, Amount, BankCard, PayType)));
        }