示例#1
0
        public HttpResponseMessage BalanceRecharge(int BalanceID, string MemberCode, int PayWay)
        {
            var response = new MyHttpResponseMessage();

            response.apiNumber = "C100_CrdController_BalanceRecharge";
            var msg = "";

            try
            {
                var balanceType = crd.crd_BalanceTypeSQLSugar.GetSingle(p => p.BalanceID == BalanceID && p.IsOnline == true);

                if (balanceType == null)
                {
                    response.SetContent(HttpStatus.error, "未能找到相关充值类型", balanceType, ResponseType.josn);
                    return(response);
                }

                var crdLog = new ORM.SqlSugar.Model.crd.crd_BalanceLog();

                crdLog.BalanceNo       = "Balance" + Utils.GetRamCode() + "";
                crdLog.Balance         = balanceType.OriginalAmount + balanceType.DonationAmount;
                crdLog.OriginalBalance = balanceType.OriginalAmount;
                crdLog.DonationBalance = balanceType.DonationAmount;
                crdLog.BalanceID       = BalanceID;
                crdLog.MemberCode      = MemberCode;
                crdLog.BalanceType     = 1;
                crdLog.Remark          = "";
                crdLog.TradeNo         = "";
                crdLog.PayTime         = null;
                crdLog.PayWay          = PayWay;
                crdLog.Status          = 0;
                crdLog.CreateDate      = DateTime.Now;
                var result = db.SqlServerClient.Ado.UseTran(() =>
                {
                    crd.crd_BalanceLogSQLSugar.Insert(crdLog);
                });

                if (result.IsSuccess)
                {
                    response.SetContent(HttpStatus.ok, "订单生成成功", crdLog, ResponseType.josn);
                }
                else
                {
                    response.SetContent(HttpStatus.error, result.ErrorMessage, "", ResponseType.josn);
                }
            }

            catch (Exception ex)
            {
                msg = "ERROR";
                AddErrorLog(LogEnum.adv, ex.Message, ex.StackTrace);
                response.SetContent(HttpStatus.error, ex.Message, msg, ResponseType.josn);
            }
            return(response);
        }
示例#2
0
        public HttpResponseMessage PayBalance(string MemberCode, string CardNo)
        {
            var response = new MyHttpResponseMessage();

            response.apiNumber = "C028_SysControllerr_PayBalance";
            try
            {
                if (CardNo.Contains("Card"))
                {
                    var Card  = mb.mb_CardList.GetById(CardNo);
                    var vCard = org.org_VirtualCardSugar.GetById(Card.VCardNo);


                    var wallet = mb.mb_WalletSugar.GetById(MemberCode);
                    if (wallet == null)
                    {
                        response.SetContent(HttpStatus.error, "没找到您的余额账户!", Card, ResponseType.josn);
                        return(response);
                    }
                    if (wallet.Balance < Card.Amount)
                    {
                        response.SetContent(HttpStatus.error, "您的余额不足,请充值!", Card, ResponseType.josn);
                        return(response);
                    }
                    var result = db.SqlServerClient.Ado.UseTran(() =>
                    {
                        var f = mb.FinshRecharg(Card, vCard);
                        if (f)
                        {
                            Card.Status  = 3;
                            Card.PayNo   = "Balance" + JVS_ADM.Common.Utils.GetRamCode();
                            Card.PayTime = DateTime.Now;
                            mb.mb_CardList.Update(Card);
                            var crdLog             = new ORM.SqlSugar.Model.crd.crd_BalanceLog();
                            crdLog.BalanceNo       = "Balance" + Utils.GetRamCode() + "";
                            crdLog.Balance         = -Card.Amount;
                            crdLog.OriginalBalance = -Card.Amount;
                            crdLog.DonationBalance = 0;
                            crdLog.BalanceID       = 0;
                            crdLog.MemberCode      = MemberCode;
                            crdLog.BalanceType     = 2;
                            crdLog.Remark          = "";
                            crdLog.TradeNo         = "";
                            crdLog.PayTime         = null;
                            crdLog.PayWay          = 0;
                            crdLog.Status          = 3;
                            crdLog.CreateDate      = DateTime.Now;
                            crd.crd_BalanceLogSQLSugar.Insert(crdLog);
                            wallet.Balance = wallet.Balance - Card.Amount;
                            mb.mb_WalletSugar.Update(wallet);
                            if (mb.mb_MemberCorpSugar.Count(p => p.MemberCode == Card.MemberCode && p.CorpCode == vCard.CorpCode) <= 0)
                            {
                                var mcorp        = new ORM.SqlSugar.Model.mb.mb_MemberCorp();
                                mcorp.CorpCode   = vCard.CorpCode;
                                mcorp.MemberCode = Card.MemberCode;
                                mcorp.ShopID     = 0;
                                mcorp.CreateTime = DateTime.Now;
                                mb.mb_MemberCorpSugar
                                .Insert(mcorp);
                            }
                        }
                    });

                    if (result.IsSuccess)
                    {
                        response.SetContent(HttpStatus.ok, "支付完成", Card, ResponseType.josn);
                        return(response);
                    }
                    else
                    {
                        response.SetContent(HttpStatus.error, "余额扣款失败", Card, ResponseType.josn);
                        return(response);
                    }
                }



                response.SetContent(HttpStatus.error, "余额支付失败", "", ResponseType.josn);
                return(response);
            }
            catch (Exception ex)
            {
                AddErrorLog(LogEnum.member, ex.Message, ex.StackTrace);
                response.SetContent(HttpStatus.error, ex.Message, ex.Message, ResponseType.josn);
                return(response);
            }
        }