Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public Respbase <ThridPartyPayDto> ThridPartyPay_Pro(ThridPartyPayReq req)
        {
            if (!CheckSign(req.ReqTime, req.Sign))
            {
                return(new Respbase <ThridPartyPayDto> {
                    Result = -1, Message = PromptInfo.Message, Data = null
                });
            }

            TssoOpenUser openUser = db.TssoOpenUserSet.Where(c => c.Openid == req.Nodecode && c.Opentype == 4).FirstOrDefault();

            if (openUser == null)
            {
                return(new Respbase <ThridPartyPayDto> {
                    Result = -1, Message = "没有绑定PCN账号", Data = null
                });
            }

            PurseFactory purseFactory = new PurseFactory(wcfProxy);
            Purse        fromPurse    = new Purse(OwnerType.个人钱包, openUser.Nodeid, PurseType.现金钱包, CurrencyType.RMB, wcfProxy);
            Purse        toPurse      = purseFactory.SystemPurseRand(openUser.Nodeid);
            Currency     currency     = new Currency(CurrencyType.RMB, req.Amount);

            if (fromPurse.UsableBalance < currency.ConvertTo(fromPurse.CurrencyType).Amount)
            {
                log.Info("支付转账失败:余额不足," + fromPurse.UsableBalance);
                return(new Respbase <ThridPartyPayDto> {
                    Result = -1, Message = "余额不足", Data = null
                });
            }
            int            reasonid = 33180;//广州豪盾游戏充值
            TransferResult transferResult;

            transferResult = wcfProxy.Transfer(fromPurse, toPurse, currency, reasonid, req.Subject);
            if (!transferResult.IsSuccess)
            {
                log.Info("支付转账失败:" + transferResult.Message);
                return(new Respbase <ThridPartyPayDto> {
                    Result = -1, Message = "转账失败", Data = null
                });
            }

            if (PromptInfo.Result <= 0)
            {
                return(new Respbase <ThridPartyPayDto> {
                    Result = -1, Message = PromptInfo.Message
                });
            }
            return(new Respbase <ThridPartyPayDto> {
                Result = 1, Message = "成功", Data = new ThridPartyPayDto {
                    TransferId = transferResult.TransferId
                }
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// SV扣除
        /// </summary>
        /// <param name="nodecode">用户账号</param>
        /// <param name="amount">金额</param>
        /// <param name="subject">商品名</param>
        /// <returns></returns>
        private bool Transfer_SV(string nodecode, decimal amount, string subject)
        {
            if (!CheckSign())
            {
                return(false);
            }

            //TssoOpenUser openUser = db.TssoOpenUserSet.Where(d => d.Openid == nodecode && d.Opentype == 4).FirstOrDefault();
            //if (openUser == null)
            //{
            //    Alert("没有绑定PCN账号");
            //    return false;
            //}
            TnetReginfo reginfo = db.TnetReginfoSet.FirstOrDefault(c => c.Nodecode == nodecode || c.Mobileno == nodecode);

            if (reginfo == null)
            {
                Alert("用户账号不存在");
                return(false);
            }
            PurseFactory purseFactory = new PurseFactory(wcfProxy);
            Purse        fromPurse    = new Purse(OwnerType.个人钱包, reginfo.Nodeid, PurseType.现金钱包, CurrencyType.RMB, wcfProxy);
            Purse        toPurse      = purseFactory.SystemPurseRand(reginfo.Nodeid);
            Currency     currency     = new Currency(CurrencyType.RMB, amount);

            if (fromPurse.UsableBalance < currency.ConvertTo(fromPurse.CurrencyType).Amount)
            {
                Alert("余额不足");
                log.Info("支付转账失败:余额不足," + fromPurse.UsableBalance);
                return(false);
            }
            int            reasonid = 33180;//广州豪盾游戏充值
            TransferResult transferResult;

            transferResult = wcfProxy.Transfer(fromPurse, toPurse, currency, reasonid, subject);
            if (!transferResult.IsSuccess)
            {
                Alert("转账失败");
                log.Info("支付转账失败:" + transferResult.Message);
                return(false);
            }
            TransferId = transferResult.TransferId;

            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 将资金回收到系统
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public Respbase <RecoveryDto> Recovery(PurseRecoveryReq req)
        {
            TnetReginfo tnet_reginfo = null;

            if (req.Nodeid > 0)
            {
                tnet_reginfo = CommonApiTransfer.Instance.GetTnetReginfo(new GetRegInfoReq {
                    KeyType = 0, RegInfoKey = req.Nodeid.ToString()
                });
            }
            else
            {
                tnet_reginfo = CommonApiTransfer.Instance.GetTnetReginfo(new GetRegInfoReq {
                    KeyType = 1, RegInfoKey = req.Nodecode.ToString()
                });
            }
            if (!UserPwd.Check(req.Paypwd, tnet_reginfo.UserpwdBak, tnet_reginfo.Nodeid, tnet_reginfo.Nodecode))
            {
                return(this.Fail <RecoveryDto>("支付密码错误"));
            }
            if (tnet_reginfo == null)
            {
                log.Info($"Recovery接口,获取用户信息失败,UE账号={req.Nodecode}");
                return(this.Fail <RecoveryDto>("获取用户信息失败"));
            }

            if (req.Reason <= 0)
            {
                log.Info($"Recovery接口,参数错误,Reason={req.Reason}");
                return(this.Fail <RecoveryDto>("参数错误"));
            }

            //检查typeid
            TnetPurseConfig purse_config = db.TnetPurseConfigSet.Where(c => c.Infoid == req.Pursetype).FirstOrDefault();

            if (purse_config == null)
            {
                log.Info($"Recovery接口,获取钱包信息失败,Infoid={req.Pursetype}");
                return(this.Fail <RecoveryDto>("获取钱包信息失败"));
            }

            //检查完毕,开始转账
            BalanceWcfProxy wcfProxy = new BalanceWcfProxy(db.NewTradeId);

            if (!wcfProxy.OpenSession())
            {
                return(this.Fail <RecoveryDto>($"不能建立会话,{wcfProxy.PromptInfo}"));
            }
            if (!wcfProxy.BeginTransaction())
            {
                wcfProxy.CloseSession();
                return(this.Fail <RecoveryDto>($"事务开启失败,{wcfProxy.PromptInfo}"));
            }
            PurseFactory purseFactory = new PurseFactory(wcfProxy);
            Purse        fromPurse    = new Purse((OwnerType)1, tnet_reginfo.Nodeid, (PurseType)purse_config.Pursetype, purse_config.Subid, new CurrencyType(purse_config.Currencytype), wcfProxy);
            Purse        toPurse      = purseFactory.SystemPurseRand(tnet_reginfo.Nodeid);//到系统钱包
            Currency     currency     = new Currency(CurrencyType.RMB, req.Amount);

            if (req.currencytype > 0)
            {
                currency = new Currency(new CurrencyType(req.currencytype), req.Amount);
            }
            //转账
            log.Info($"Recovery接口,开始回收,frompurseid={fromPurse.PurseId},到钱包ID={toPurse.PurseId},金额={currency.Amount},单位={currency.CurrencyUnit}");
            TransferResult transferResult = wcfProxy.Transfer(fromPurse, toPurse, currency, req.Reason, req.Remarks);

            if (!transferResult.IsSuccess)
            {
                log.Info("Recovery接口,转账失败:" + transferResult.Message);
                wcfProxy.Rollback();
                wcfProxy.CloseSession();
                return(this.Fail <RecoveryDto>(transferResult.Message));
            }
            log.Info($"Recovery接口,回收成功,账号={tnet_reginfo.Nodecode},类型={req.Pursetype},金额={currency.Amount},单位={currency.CurrencyUnit},备注={req.Remarks}");
            if (!wcfProxy.Commit())
            {
                wcfProxy.CloseSession();
                return(this.Fail <RecoveryDto>("转账提交失败"));
            }
            return(this.Ok("操作成功", new RecoveryDto {
                TransferId = transferResult.TransferId.ToString()
            }));
        }