private void AddBankroll(int paymentLogId)
 {
     if (!BankrollItem.ExistsPaymentLog(paymentLogId))
     {
         PaymentLogInfo paymentLogById = PaymentLog.GetPaymentLogById(paymentLogId);
         if (!paymentLogById.IsNull)
         {
             IEncourageStrategy <decimal> strategy = new UserMoney();
             int      userId          = 0;
             UserInfo usersByUserName = new UserInfo(true);
             if (!string.IsNullOrEmpty(paymentLogById.UserName))
             {
                 usersByUserName = Users.GetUsersByUserName(paymentLogById.UserName);
                 userId          = usersByUserName.UserId;
                 if (userId > 0)
                 {
                     strategy.IncreaseForUsers(userId.ToString(), paymentLogById.MoneyPay, "", false, "");
                     BankrollItemInfo bankrollItemInfo = new BankrollItemInfo();
                     bankrollItemInfo.UserName     = paymentLogById.UserName;
                     bankrollItemInfo.Money        = paymentLogById.MoneyPay;
                     bankrollItemInfo.MoneyType    = 3;
                     bankrollItemInfo.EBankId      = paymentLogById.PlatformId;
                     bankrollItemInfo.OrderId      = paymentLogById.OrderId;
                     bankrollItemInfo.PaymentId    = paymentLogId;
                     bankrollItemInfo.Remark       = "在线支付单号:" + paymentLogById.PaymentNum;
                     bankrollItemInfo.DateAndTime  = DateTime.Now;
                     bankrollItemInfo.CurrencyType = 1;
                     bankrollItemInfo.ClientId     = usersByUserName.ClientId;
                     BankrollItem.Add(bankrollItemInfo);
                 }
             }
             if (paymentLogById.OrderId > 0)
             {
                 OrderInfo orderById = Order.GetOrderById(paymentLogById.OrderId);
                 if (!orderById.IsNull)
                 {
                     decimal d = 0M;
                     if (orderById.MoneyTotal > orderById.MoneyReceipt)
                     {
                         if ((orderById.MoneyTotal - orderById.MoneyReceipt) > paymentLogById.MoneyPay)
                         {
                             if (SiteConfig.ShopConfig.EnablePartPay)
                             {
                                 d = paymentLogById.MoneyPay;
                                 orderById.MoneyReceipt += paymentLogById.MoneyPay;
                             }
                         }
                         else
                         {
                             d = orderById.MoneyTotal - orderById.MoneyReceipt;
                             orderById.MoneyReceipt = orderById.MoneyTotal;
                         }
                         orderById.Status = OrderStatus.Confirmed;
                         Order.Update(orderById);
                     }
                     if (d > 0M)
                     {
                         strategy.IncreaseForUsers(userId.ToString(), -d, "", false, "");
                         BankrollItemInfo info5 = new BankrollItemInfo();
                         info5.UserName     = usersByUserName.UserName;
                         info5.ClientId     = usersByUserName.ClientId;
                         info5.Money        = -d;
                         info5.MoneyType    = 4;
                         info5.EBankId      = 0;
                         info5.OrderId      = orderById.OrderId;
                         info5.PaymentId    = 0;
                         info5.Remark       = "支付订单费用,订单号:" + orderById.OrderNum;
                         info5.DateAndTime  = DateTime.Now;
                         info5.CurrencyType = 1;
                         BankrollItem.Add(info5);
                     }
                 }
             }
             else if (paymentLogById.Point > 0)
             {
                 IEncourageStrategy <int> strategy2 = new UserPoint();
                 strategy2.IncreaseForUsers(userId.ToString(), paymentLogById.Point, "购买" + SiteConfig.UserConfig.PointName, true, "");
                 BankrollItemInfo info6 = new BankrollItemInfo();
                 info6.UserName     = usersByUserName.UserName;
                 info6.ClientId     = usersByUserName.ClientId;
                 info6.Money        = (paymentLogById.MoneyPay > 0M) ? (-1M * paymentLogById.MoneyPay) : paymentLogById.MoneyPay;
                 info6.MoneyType    = 4;
                 info6.EBankId      = 0;
                 info6.OrderId      = 0;
                 info6.PaymentId    = 0;
                 info6.Remark       = "购买" + SiteConfig.UserConfig.PointName + ",购买数:" + paymentLogById.Point.ToString() + SiteConfig.UserConfig.PointUnit;
                 info6.DateAndTime  = new DateTime?(DateTime.Now);
                 info6.CurrencyType = 1;
                 BankrollItem.Add(info6);
                 if (usersByUserName.UserId > 0)
                 {
                     strategy.IncreaseForUsers(usersByUserName.UserId.ToString(), -(paymentLogById.MoneyPay), "", false, "");
                 }
             }
         }
     }
 }
Exemple #2
0
 public PayOnlineState UpdateOrder(string paymentNum, decimal amount, string eBankInfo, int status, string remark, bool updateDeliverStatus, bool updateOrderStatus)
 {
     if (Convert.ToString(PEContext.Current.Context.Session["PaymentNum"]) != paymentNum)
     {
         PEContext.Current.Context.Session["PaymentNum"] = paymentNum;
         StringBuilder payOnlineMessage = new StringBuilder(0x40);
         paymentNum = DataSecurity.FilterBadChar(paymentNum);
         eBankInfo  = DataSecurity.FilterBadChar(eBankInfo);
         remark     = DataSecurity.FilterBadChar(remark);
         PayOnlineState state = this.UpdatePaymentLog(paymentNum, amount, eBankInfo, status, remark);
         if (state != PayOnlineState.Ok)
         {
             PEContext.Current.Context.Session["PaymentNum"] = "";
             return(state);
         }
         if (!updateDeliverStatus)
         {
             PEContext.Current.Context.Session["PaymentNum"] = "";
             return(PayOnlineState.Ok);
         }
         bool doUpdate = !BankrollItem.ExistsPaymentLog(this.m_PaymentLogId);
         if (!doUpdate)
         {
             PEContext.Current.Context.Session["PaymentNum"] = "";
             return(PayOnlineState.AccountPaid);
         }
         bool isok = false;
         IEncourageStrategy <decimal> strategy = new UserMoney();
         if (updateOrderStatus)
         {
             if (this.m_UserId > 0)
             {
                 strategy.IncreaseForUsers(this.m_UserId.ToString(), this.m_MoneyReceipt, "", false, "");
             }
             BankrollItemInfo bankrollItemInfo = new BankrollItemInfo();
             bankrollItemInfo.UserName     = this.m_UserName;
             bankrollItemInfo.ClientId     = this.m_ClientID;
             bankrollItemInfo.Money        = this.m_MoneyReceipt;
             bankrollItemInfo.MoneyType    = 3;
             bankrollItemInfo.EBankId      = this.m_PlatformId;
             bankrollItemInfo.OrderId      = this.m_OrderInfo.OrderId;
             bankrollItemInfo.PaymentId    = this.m_PaymentLogId;
             bankrollItemInfo.Remark       = "在线支付单号:" + paymentNum;
             bankrollItemInfo.DateAndTime  = new DateTime?(DateTime.Now);
             bankrollItemInfo.CurrencyType = 1;
             isok = BankrollItem.Add(bankrollItemInfo);
         }
         if (this.m_OrderInfo.IsNull)
         {
             if (this.m_Point > 0)
             {
                 IEncourageStrategy <int> strategy2 = new UserPoint();
                 strategy2.IncreaseForUsers(this.m_UserId.ToString(), this.m_Point, "购买" + SiteConfig.UserConfig.PointName, true, "");
                 BankrollItemInfo info2 = new BankrollItemInfo();
                 info2.UserName     = this.m_UserName;
                 info2.ClientId     = this.m_ClientID;
                 info2.Money        = (this.m_MoneyReceipt > 0M) ? (-1M * this.m_MoneyReceipt) : this.m_MoneyReceipt;
                 info2.MoneyType    = 4;
                 info2.EBankId      = 0;
                 info2.OrderId      = this.m_OrderInfo.OrderId;
                 info2.PaymentId    = 0;
                 info2.Remark       = "购买" + SiteConfig.UserConfig.PointName + ",购买数:" + this.m_Point.ToString() + SiteConfig.UserConfig.PointUnit;
                 info2.DateAndTime  = new DateTime?(DateTime.Now);
                 info2.CurrencyType = 1;
                 isok = BankrollItem.Add(info2);
                 if (this.m_UserId > 0)
                 {
                     isok = strategy.IncreaseForUsers(this.m_UserId.ToString(), -(this.m_MoneyReceipt), "", false, "");//将decimal.op_UnaryNegation
                 }
             }
             PEContext.Current.Context.Session["PaymentNum"] = "";
             if (!isok)
             {
                 return(PayOnlineState.Fail);
             }
             return(PayOnlineState.Ok);
         }
         if (updateDeliverStatus && ((this.m_OrderInfo.MoneyTotal - this.m_OrderInfo.MoneyReceipt) <= this.m_MoneyReceipt))
         {
             this.m_OrderInfo.EnableDownload = true;
             isok = Order.Update(this.m_OrderInfo);
         }
         if ((this.m_OrderInfo.MoneyReceipt < this.m_OrderInfo.MoneyTotal) && updateOrderStatus)
         {
             bool flag3 = false;
             if ((this.m_OrderInfo.MoneyTotal - this.m_OrderInfo.MoneyReceipt) <= this.m_MoneyReceipt)
             {
                 this.m_MoneyPayout            = this.m_OrderInfo.MoneyTotal - this.m_OrderInfo.MoneyReceipt;
                 this.m_OrderInfo.MoneyReceipt = this.m_OrderInfo.MoneyTotal;
                 flag3 = true;
             }
             else if (SiteConfig.ShopConfig.EnablePartPay)
             {
                 this.m_MoneyPayout             = this.m_MoneyReceipt;
                 this.m_OrderInfo.MoneyReceipt += this.m_MoneyReceipt;
                 flag3 = true;
             }
             if (flag3)
             {
                 if (this.m_OrderInfo.Status <= OrderStatus.WaitForConfirm)
                 {
                     this.m_OrderInfo.Status = OrderStatus.Confirmed;
                 }
                 isok = Order.Update(this.m_OrderInfo);
                 BankrollItemInfo info3 = new BankrollItemInfo();
                 info3.UserName     = this.m_UserName;
                 info3.ClientId     = this.m_ClientID;
                 info3.Money        = (this.m_MoneyPayout > 0M) ? (-1M * this.m_MoneyPayout) : this.m_MoneyPayout;
                 info3.MoneyType    = 4;
                 info3.EBankId      = 0;
                 info3.OrderId      = this.m_OrderInfo.OrderId;
                 info3.PaymentId    = 0;
                 info3.Remark       = "支付订单费用,订单号:" + this.m_OrderInfo.OrderNum;
                 info3.DateAndTime  = new DateTime?(DateTime.Now);
                 info3.CurrencyType = 1;
                 isok = BankrollItem.Add(info3);
                 if (this.m_UserId > 0)
                 {
                     isok = strategy.IncreaseForUsers(this.m_UserId.ToString(), -(this.m_MoneyPayout), "", false, "");//将decimal.op_UnaryNegation改为了-
                 }
                 payOnlineMessage.Append("同时已经为您的订单编号为 " + this.m_OrderInfo.OrderNum + " 的订单支付了 " + this.m_MoneyPayout.ToString("N2") + "元。<br />");
             }
             else
             {
                 payOnlineMessage.Append("您的支付金额小于订单金额,不能对订单进行支付,资金已经打入您的帐户中做为预付款。<br />");
                 updateDeliverStatus = false;
             }
         }
         if (updateDeliverStatus)
         {
             this.ShowCardInfo(payOnlineMessage, doUpdate, isok);
         }
         payOnlineMessage.Append("<a href='../User/Shop/ShowOrder.aspx?OrderId=" + this.m_OrderInfo.OrderId.ToString() + "'>点此查看订单信息</a>");
         this.m_Message = payOnlineMessage.ToString();
         PEContext.Current.Context.Session["PaymentNum"] = "";
         if (!isok)
         {
             return(PayOnlineState.Fail);
         }
     }
     return(PayOnlineState.Ok);
 }