private void btnReChargeOK_Click(object sender, EventArgs e) { decimal num; int length = 0; if (txtReCharge.Text.Trim().IndexOf(".") > 0) { length = txtReCharge.Text.Trim().Substring(txtReCharge.Text.Trim().IndexOf(".") + 1).Length; } if (!(decimal.TryParse(txtReCharge.Text.Trim(), out num) && (length <= 2))) { ShowMsg("本次充值要给当前客户加款的金额只能是数值,且不能超过2位小数", false); } else if ((num < -10000000M) || (num > 10000000M)) { ShowMsg("金额大小必须在正负1000万之间", false); } else { Distributor user = Users.GetUser(userId, false) as Distributor; if (user == null) { ShowMsg("此分销商已经不存在", false); } else { decimal num3 = num + user.Balance; BalanceDetailInfo info2 = new BalanceDetailInfo(); info2.UserId = userId; info2.UserName = user.Username; info2.TradeDate = DateTime.Now; info2.TradeType = TradeTypes.BackgroundAddmoney; info2.Income = new decimal?(num); info2.Balance = num3; info2.Remark = Globals.HtmlEncode(txtRemarks.Text.Trim()); BalanceDetailInfo target = info2; ValidationResults results = Hishop.Components.Validation.Validation.Validate<BalanceDetailInfo>(target, new string[] { "ValBalanceDetail" }); string msg = string.Empty; if (!results.IsValid) { foreach (ValidationResult result in (IEnumerable<ValidationResult>)results) { msg = msg + Formatter.FormatErrorMessage(result.Message); } ShowMsg(msg, false); } else { if (DistributorHelper.AddBalance(target)) { ShowMsg(string.Format("本次充值已成功,充值金额:{0}", num), true); } txtReCharge.Text = string.Empty; txtRemarks.Text = string.Empty; lblUseableBalance.Money = num3; } } } }
public static bool AddBalance(BalanceDetailInfo balanceDetails) { if (null == balanceDetails) { return false; } EventLogs.WriteOperationLog(Privilege.DistributorReCharge, string.Format(CultureInfo.InvariantCulture, "给分销商\"{0}\"添加预付款\"{1}\"", new object[] { balanceDetails.UserName, balanceDetails.Balance })); return DistributorProvider.Instance().InsertBalanceDetail(balanceDetails, null); }
public static bool AddUnderlingBalanceDetail(BalanceDetailInfo balanceDetails) { bool flag = UnderlingProvider.Instance().AddUnderlingBalanceDetail(balanceDetails); if (flag) { Users.ClearUserCache(Users.GetUser(balanceDetails.UserId)); } return flag; }
public static bool AddBalance(BalanceDetailInfo balanceDetails) { if (null == balanceDetails) { return false; } bool flag = MemberProvider.Instance().InsertBalanceDetail(balanceDetails); if (flag) { Users.ClearUserCache(Users.GetUser(balanceDetails.UserId)); } EventLogs.WriteOperationLog(Privilege.MemberAccount, string.Format(CultureInfo.InvariantCulture, "给会员\"{0}\"添加预付款\"{1}\"", new object[] { balanceDetails.UserName, balanceDetails.Balance })); return flag; }
public override bool AddBalanceDetail(BalanceDetailInfo balanceDetails) { if (null == balanceDetails) { return false; } string query = "INSERT INTO Hishop_BalanceDetails(UserId, UserName, TradeDate, TradeType, Income, Balance,Remark) VALUES (@UserId, @UserName,@TradeDate, @TradeType, @Income, @Balance, @Remark)"; DbCommand sqlStringCommand = database.GetSqlStringCommand(query); database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, balanceDetails.UserId); database.AddInParameter(sqlStringCommand, "UserName", DbType.String, balanceDetails.UserName); database.AddInParameter(sqlStringCommand, "TradeDate", DbType.DateTime, balanceDetails.TradeDate); database.AddInParameter(sqlStringCommand, "TradeType", DbType.Int32, (int)balanceDetails.TradeType); database.AddInParameter(sqlStringCommand, "Income", DbType.Currency, balanceDetails.Income); database.AddInParameter(sqlStringCommand, "Balance", DbType.Currency, balanceDetails.Balance); database.AddInParameter(sqlStringCommand, "Remark", DbType.String, balanceDetails.Remark); return (database.ExecuteNonQuery(sqlStringCommand) >= 1); }
public override bool AddBalanceDetail(BalanceDetailInfo balanceDetails, string inpourId) { if (null == balanceDetails) { return false; } DbCommand sqlStringCommand = database.GetSqlStringCommand("INSERT INTO Hishop_DistributorBalanceDetails(UserId,UserName, TradeDate, TradeType, Income, Balance, Remark) VALUES (@UserId, @UserName, @TradeDate, @TradeType, @Income, @Balance, @Remark); DELETE FROM Hishop_DistributorInpourRequest WHERE InpourId = @InpourId;"); database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, balanceDetails.UserId); database.AddInParameter(sqlStringCommand, "UserName", DbType.String, balanceDetails.UserName); database.AddInParameter(sqlStringCommand, "TradeDate", DbType.DateTime, balanceDetails.TradeDate); database.AddInParameter(sqlStringCommand, "TradeType", DbType.Int32, (int)balanceDetails.TradeType); database.AddInParameter(sqlStringCommand, "Income", DbType.Currency, balanceDetails.Income); database.AddInParameter(sqlStringCommand, "Balance", DbType.Currency, balanceDetails.Balance); database.AddInParameter(sqlStringCommand, "Remark", DbType.String, balanceDetails.Remark); database.AddInParameter(sqlStringCommand, "InpourId", DbType.String, inpourId); return (database.ExecuteNonQuery(sqlStringCommand) >= 1); }
public override bool AddUnderlingBalanceDetail(BalanceDetailInfo balanceDetails) { if (null == balanceDetails) { return false; } DbCommand sqlStringCommand = database.GetSqlStringCommand("INSERT INTO distro_BalanceDetails (UserId,UserName, DistributorUserId, TradeDate, TradeType, Income, Expenses, Balance, Remark) VALUES(@UserId,@UserName, @DistributorUserId, @TradeDate, @TradeType, @Income, @Expenses, @Balance, @Remark)"); database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, balanceDetails.UserId); database.AddInParameter(sqlStringCommand, "UserName", DbType.String, balanceDetails.UserName); database.AddInParameter(sqlStringCommand, "DistributorUserId", DbType.Int32, HiContext.Current.User.UserId); database.AddInParameter(sqlStringCommand, "TradeDate", DbType.DateTime, balanceDetails.TradeDate); database.AddInParameter(sqlStringCommand, "TradeType", DbType.Int32, (int)balanceDetails.TradeType); database.AddInParameter(sqlStringCommand, "Income", DbType.Currency, balanceDetails.Income); database.AddInParameter(sqlStringCommand, "Expenses", DbType.Currency, balanceDetails.Expenses); database.AddInParameter(sqlStringCommand, "Balance", DbType.Currency, balanceDetails.Balance); database.AddInParameter(sqlStringCommand, "Remark", DbType.String, balanceDetails.Remark); return (database.ExecuteNonQuery(sqlStringCommand) > 0); }
public override bool ConfirmPay(BalanceDetailInfo balance, string purchaseOrderId) { bool flag; using (DbConnection connection = database.CreateConnection()) { connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { DbCommand sqlStringCommand = database.GetSqlStringCommand("INSERT INTO Hishop_DistributorBalanceDetails(UserId,UserName,TradeDate,TradeType,Expenses,Balance) VALUES(@UserId,@UserName,@TradeDate,@TradeType,@Expenses,@Balance)"); database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, balance.UserId); database.AddInParameter(sqlStringCommand, "UserName", DbType.String, balance.UserName); database.AddInParameter(sqlStringCommand, "TradeDate", DbType.DateTime, balance.TradeDate); database.AddInParameter(sqlStringCommand, "TradeType", DbType.Int32, (int)balance.TradeType); database.AddInParameter(sqlStringCommand, "Expenses", DbType.Currency, balance.Expenses); database.AddInParameter(sqlStringCommand, "Balance", DbType.Currency, balance.Balance); if (database.ExecuteNonQuery(sqlStringCommand, transaction) <= 0) { transaction.Rollback(); return false; } DbCommand command = database.GetSqlStringCommand("UPDATE Hishop_PurchaseOrders SET PurchaseStatus=@PurchaseStatus,PayDate=@PayDate WHERE PurchaseOrderId = @PurchaseOrderId AND DistributorId=@DistributorId"); database.AddInParameter(command, "PurchaseOrderId", DbType.String, purchaseOrderId); database.AddInParameter(command, "PayDate", DbType.DateTime, DateTime.Now); database.AddInParameter(command, "DistributorId", DbType.String, HiContext.Current.User.UserId); database.AddInParameter(command, "PurchaseStatus", DbType.Int32, 2); if (database.ExecuteNonQuery(command, transaction) <= 0) { transaction.Rollback(); return false; } transaction.Commit(); flag = true; } catch { transaction.Rollback(); flag = false; } finally { connection.Close(); } } return flag; }
public static bool Recharge(BalanceDetailInfo balanceDetails, string InpourId) { bool flag = PersonalProvider.Instance().AddBalanceDetail(balanceDetails); if (flag) { PersonalProvider.Instance().RemoveInpourRequest(InpourId); } return flag; }
public abstract bool InsertBalanceDetail(BalanceDetailInfo balanceDetail, DbTransaction dbTran);
public abstract bool InsertBalanceDetail(BalanceDetailInfo balanceDetail);
public abstract bool AddBalanceDetail(BalanceDetailInfo balanceDetails);
public abstract bool AddBalanceDetail(BalanceDetailInfo balanceDetails, string inpourId);
private void btnAddBalance_Click(object sender, EventArgs e) { decimal num; int length = 0; if (txtReCharge.Text.Trim().IndexOf(".") > 0) { length = txtReCharge.Text.Trim().Substring(txtReCharge.Text.Trim().IndexOf(".") + 1).Length; } if (!(decimal.TryParse(txtReCharge.Text.Trim(), out num) && (length <= 2))) { ShowMsg("本次充值要给当前客户加款的金额只能是数值,且不能超过2位小数", false); } else if ((num < -10000000M) || (num > 10000000M)) { ShowMsg("金额大小必须在正负1000万之间", false); } else { int userId = int.Parse(currentUserId.Value); Member user = Users.GetUser(userId, false) as Member; if (!((user != null) && user.IsOpenBalance)) { ShowMsg("本次充值已失败,该用户的预付款还没有开通", false); } else { decimal num4 = num + user.Balance; BalanceDetailInfo info2 = new BalanceDetailInfo(); info2.UserId = userId; info2.UserName = user.Username; info2.TradeDate = DateTime.Now; info2.TradeType = TradeTypes.BackgroundAddmoney; info2.Income = new decimal?(num); info2.Balance = num4; info2.Remark = Globals.HtmlEncode(txtRemark.Text.Trim()); BalanceDetailInfo target = info2; ValidationResults results = Hishop.Components.Validation.Validation.Validate<BalanceDetailInfo>(target, new string[] { "ValBalanceDetail" }); string msg = string.Empty; if (!results.IsValid) { foreach (ValidationResult result in (IEnumerable<ValidationResult>)results) { msg = msg + Formatter.FormatErrorMessage(result.Message); } ShowMsg(msg, false); } else if (UnderlingHelper.AddUnderlingBalanceDetail(target)) { txtReCharge.Text = ""; ReBind(false); } } } }
void Notify_Finished(object sender, FinishedEventArgs e) { DateTime now = DateTime.Now; TradeTypes selfhelpInpour = TradeTypes.SelfhelpInpour; Member user = Users.GetUser(this.InpourRequest.UserId, false) as Member; decimal num = user.Balance + this.InpourRequest.InpourBlance; BalanceDetailInfo balanceDetails = new BalanceDetailInfo(); balanceDetails.UserId = this.InpourRequest.UserId; balanceDetails.UserName = user.Username; balanceDetails.TradeDate = now; balanceDetails.TradeType = selfhelpInpour; balanceDetails.Income = new decimal?(this.InpourRequest.InpourBlance); balanceDetails.Balance = num; if (this.paymode != null) { balanceDetails.Remark = "充值支付方式:" + this.paymode.Name; } if (PersonalHelper.Recharge(balanceDetails, this.InpourRequest.InpourId)) { Users.ClearUserCache(user); this.ResponseStatus(true, "success"); } else { PersonalHelper.RemoveInpourRequest(this.InpourId); this.ResponseStatus(false, "fail"); } }
public static bool ConfirmPay(BalanceDetailInfo balance, PurchaseOrderInfo purchaseOrder) { if (!purchaseOrder.CheckAction(PurchaseOrderActions.DISTRIBUTOR_CONFIRM_PAY)) { return false; } bool flag = SubsiteSalesProvider.Instance().ConfirmPay(balance, purchaseOrder.PurchaseOrderId); if (flag) { SubsiteSalesProvider.Instance().UpdateProductStock(purchaseOrder.PurchaseOrderId); SubsiteSalesProvider.Instance().UpdateDistributorAccount(purchaseOrder.GetPurchaseTotal()); Users.ClearUserCache(Users.GetUser(purchaseOrder.DistributorId)); } return flag; }
public abstract bool AddUnderlingBalanceDetail(BalanceDetailInfo balanceDetails);
public static bool UserPayOrder(OrderInfo order, bool isBalancePayOrder) { bool flag = false; if (order.CheckAction(OrderActions.BUYER_PAY)) { using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { if (!TradeProvider.Instance().UserPayOrder(order, isBalancePayOrder, dbTran)) { dbTran.Rollback(); return false; } if ((HiContext.Current.SiteSettings.IsDistributorSettings && (order.GroupBuyId <= 0)) && !PurchaseOrderProvider.CreateInstance().CreatePurchaseOrder(order, dbTran)) { dbTran.Rollback(); return false; } flag = true; dbTran.Commit(); } catch { dbTran.Rollback(); return false; } finally { connection.Close(); } } if (!flag) { return flag; } if (!HiContext.Current.SiteSettings.IsDistributorSettings) { TradeProvider.Instance().UpdateStockPayOrder(order.OrderId); } TradeProvider.Instance().UpdateProductSaleCounts(order.LineItems); if ((order.UserId == 0) || (order.UserId == 0x44c)) { return flag; } IUser user = Users.GetUser(order.UserId, false); if (((user == null) || (user.UserRole != UserRole.Member)) && ((user == null) || (user.UserRole != UserRole.Underling))) { return flag; } Member member = user as Member; UserPointInfo point = new UserPointInfo(); point.OrderId = order.OrderId; point.UserId = member.UserId; point.TradeDate = DateTime.Now; point.TradeType = UserPointTradeType.Bounty; point.Increased = new int?(order.GetTotalPoints()); point.Points = order.GetTotalPoints() + member.Points; if ((point.Points > 0x7fffffff) || (point.Points < 0)) { point.Points = 0x7fffffff; } TradeProvider.Instance().AddMemberPoint(point); int referralDeduct = HiContext.Current.SiteSettings.ReferralDeduct; if (((referralDeduct > 0) && member.ReferralUserId.HasValue) && (member.ReferralUserId.Value > 0)) { IUser user2 = Users.GetUser(member.ReferralUserId.Value, false); if ((user2 != null) && ((user2.UserRole == UserRole.Member) || (user2.UserRole == UserRole.Underling))) { Member member2 = user2 as Member; if ((member.ParentUserId == member2.ParentUserId) && member2.IsOpenBalance) { decimal num2 = member2.Balance + ((order.GetTotal() * referralDeduct) / 100M); BalanceDetailInfo balanceDetails = new BalanceDetailInfo(); balanceDetails.UserId = member2.UserId; balanceDetails.UserName = member2.Username; balanceDetails.TradeDate = DateTime.Now; balanceDetails.TradeType = TradeTypes.ReferralDeduct; balanceDetails.Income = new decimal?((order.GetTotal() * referralDeduct) / 100M); balanceDetails.Balance = num2; balanceDetails.Remark = string.Format("提成来自'{0}'的订单{1}", order.Username, order.OrderId); PersonalProvider.Instance().AddBalanceDetail(balanceDetails); } } } TradeProvider.Instance().UpdateUserAccount(order.GetTotal(), point.Points, order.UserId); int historyPoint = TradeProvider.Instance().GetHistoryPoint(member.UserId); TradeProvider.Instance().ChangeMemberGrade(member.UserId, member.GradeId, historyPoint); Users.ClearUserCache(user); } return flag; }
private void BtnRefund_Click(object sender, EventArgs e) { PurchaseOrderInfo purchaseOrder = SalesHelper.GetPurchaseOrder(purchaseOrderId); if (!purchaseOrder.CheckAction(PurchaseOrderActions.MASTER_REJECT_REFUND)) { ShowMsg("未付款或不在进行中的订单没有退款操作", false); } else { int length = 0; decimal result = 0M; if (purchaseOrder.PurchaseStatus == OrderStatus.SellerAlreadySent) { if (txtRefundTotal.Text.Trim().IndexOf(".") > 0) { length = txtRefundTotal.Text.Trim().Substring(txtRefundTotal.Text.Trim().IndexOf(".") + 1).Length; } if (!(decimal.TryParse(txtRefundTotal.Text.Trim(), out result) && (length <= 2))) { ShowMsg("退款金额只能是数值,且不能超过2位小数", false); return; } if ((result <= 0M) || (result > purchaseOrder.GetPurchaseTotal())) { ShowMsg("退款金额必须大于0,小于等于实收款", false); return; } } if (txtRefundRemark.Text.Length > 200) { ShowMsg("退款说明限制在200个字符以内", false); } else { decimal num3; Distributor user = Users.GetUser(purchaseOrder.DistributorId) as Distributor; if (purchaseOrder.PurchaseStatus == OrderStatus.SellerAlreadySent) { num3 = result; } else { num3 = decimal.Parse(lblRefundTotal.Money.ToString()); } BalanceDetailInfo balanceDetails = new BalanceDetailInfo(); balanceDetails.UserId = purchaseOrder.DistributorId; balanceDetails.UserName = purchaseOrder.Distributorname; balanceDetails.TradeDate = DateTime.Now; balanceDetails.TradeType = TradeTypes.RefundOrder; balanceDetails.Income = new decimal?(num3); balanceDetails.Balance = user.Balance + num3; balanceDetails.Remark = "采购单退款到预付款"; if (DistributorHelper.AddBalance(balanceDetails)) { purchaseOrder.RefundAmount = num3; purchaseOrder.RefundRemark = Globals.HtmlEncode(txtRefundRemark.Text.Trim()); purchaseOrder.FinishDate = DateTime.Now; if (purchaseOrder.PurchaseStatus == OrderStatus.BuyerAlreadyPaid) { purchaseOrder.PurchaseStatus = OrderStatus.Closed; } if (purchaseOrder.PurchaseStatus == OrderStatus.SellerAlreadySent) { purchaseOrder.PurchaseStatus = OrderStatus.Finished; } if (SalesHelper.RefundPurchaseOrder(purchaseOrder)) { Page.Response.Redirect(Globals.ApplicationPath + string.Format("/Admin/purchaseOrder/RefundPurchaseOrderDetails.aspx?PurchaseOrderId={0}", purchaseOrder.PurchaseOrderId)); } else { ShowMsg("退款失败", false); } } } } }
static void ReduceDeduct(OrderInfo order, Member member) { int referralDeduct = HiContext.Current.SiteSettings.ReferralDeduct; if (((referralDeduct > 0) && member.ReferralUserId.HasValue) && (member.ReferralUserId.Value > 0)) { IUser user = Users.GetUser(member.ReferralUserId.Value, false); if ((user != null) && (user.UserRole == UserRole.Member)) { Member member2 = user as Member; if ((member.ParentUserId == member2.ParentUserId) && member2.IsOpenBalance) { decimal num2 = member2.Balance - ((order.RefundAmount * referralDeduct) / 100M); BalanceDetailInfo balanceDetail = new BalanceDetailInfo(); balanceDetail.UserId = member2.UserId; balanceDetail.UserName = member2.Username; balanceDetail.TradeDate = DateTime.Now; balanceDetail.TradeType = TradeTypes.ReferralDeduct; balanceDetail.Expenses = new decimal?((order.RefundAmount * referralDeduct) / 100M); balanceDetail.Balance = num2; balanceDetail.Remark = string.Format("退回提成因为'{0}'的订单{1}已退款", order.Username, order.OrderId); MemberProvider.Instance().InsertBalanceDetail(balanceDetail); } } } }
static void UpdateUserAccount(OrderInfo order) { int userId = order.UserId; if (userId == 0x44c) { userId = 0; } IUser user = Users.GetUser(userId, false); if ((user != null) && (user.UserRole == UserRole.Member)) { Member member = user as Member; UserPointInfo point = new UserPointInfo(); point.OrderId = order.OrderId; point.UserId = member.UserId; point.TradeDate = DateTime.Now; point.TradeType = UserPointTradeType.Bounty; point.Increased = new int?(order.GetTotalPoints()); point.Points = order.GetTotalPoints() + member.Points; if ((point.Points > 0x7fffffff) || (point.Points < 0)) { point.Points = 0x7fffffff; } SalesProvider.Instance().AddMemberPoint(point); int referralDeduct = HiContext.Current.SiteSettings.ReferralDeduct; if (((referralDeduct > 0) && member.ReferralUserId.HasValue) && (member.ReferralUserId.Value > 0)) { IUser user2 = Users.GetUser(member.ReferralUserId.Value, false); if ((user2 != null) && (user2.UserRole == UserRole.Member)) { Member member2 = user2 as Member; if ((member.ParentUserId == member2.ParentUserId) && member2.IsOpenBalance) { decimal num3 = member2.Balance + ((order.GetTotal() * referralDeduct) / 100M); BalanceDetailInfo balanceDetail = new BalanceDetailInfo(); balanceDetail.UserId = member2.UserId; balanceDetail.UserName = member2.Username; balanceDetail.TradeDate = DateTime.Now; balanceDetail.TradeType = TradeTypes.ReferralDeduct; balanceDetail.Income = new decimal?((order.GetTotal() * referralDeduct) / 100M); balanceDetail.Balance = num3; balanceDetail.Remark = string.Format("提成来自'{0}'的订单{1}", order.Username, order.OrderId); MemberProvider.Instance().InsertBalanceDetail(balanceDetail); } } } SalesProvider.Instance().UpdateUserAccount(order.GetTotal(), order.UserId); int historyPoint = SalesProvider.Instance().GetHistoryPoint(member.UserId); SalesProvider.Instance().ChangeMemberGrade(member.UserId, member.GradeId, historyPoint); Users.ClearUserCache(user); } }
private void btnConfirmPay_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtTradePassword.Text)) { ShowMsg("请输入交易密码", false); } else if (((decimal)lblUseableBalance.Money) < ((decimal)lblTotalPrice.Money)) { ShowMsg("您的预付款金额不足", false); } else { Distributor user = SubsiteStoreHelper.GetDistributor(); if ((user.Balance - user.RequestBalance) < purchaseOrder.GetPurchaseTotal()) { ShowMsg("您的预付款金额不足", false); } else { BalanceDetailInfo balance = new BalanceDetailInfo(); balance.UserId = user.UserId; balance.UserName = user.Username; balance.TradeType = TradeTypes.Consume; balance.TradeDate = DateTime.Now; balance.Expenses = new decimal?(purchaseOrder.GetPurchaseTotal()); balance.Balance = user.Balance - purchaseOrder.GetPurchaseTotal(); user.TradePassword = txtTradePassword.Text; if (Users.ValidTradePassword(user)) { if (!SubsiteSalesHelper.ConfirmPay(balance, purchaseOrder)) { ShowMsg("付款失败", false); } else { PaySucceess.Visible = true; } } else { ShowMsg("交易密码错误", false); } } } }
private void BtnRefund_Click(object sender, EventArgs e) { OrderInfo orderInfo = SubsiteSalesHelper.GetOrderInfo(orderId); if (!orderInfo.CheckAction(OrderActions.SELLER_REJECT_REFUND)) { ShowMsg("未付款或不在进行中的订单没有退款操作", false); } else { int length = 0; decimal result = 0M; if (orderInfo.OrderStatus == OrderStatus.SellerAlreadySent) { if (txtRefundTotal.Text.Trim().IndexOf(".") > 0) { length = txtRefundTotal.Text.Trim().Substring(txtRefundTotal.Text.Trim().IndexOf(".") + 1).Length; } if (!(decimal.TryParse(txtRefundTotal.Text.Trim(), out result) && (length <= 2))) { ShowMsg("退款金额只能是数值,且不能超过2位小数", false); return; } if ((result <= 0M) || (result > orderInfo.GetTotal())) { ShowMsg("退款金额必须大于0,小于等于实收款", false); return; } } if (txtRefundRemark.Text.Length > 200) { ShowMsg("退款说明限制在200个字符以内", false); } else { decimal money; Member user = Users.GetUser(orderInfo.UserId) as Member; if (orderInfo.OrderStatus == OrderStatus.SellerAlreadySent) { money = result; } else if ((orderInfo.GroupBuyId > 0) && (orderInfo.GroupBuyStatus != GroupBuyStatus.Failed)) { money = ((decimal)lblTotalPrice.Money) - orderInfo.NeedPrice; } else { money = (decimal)lblTotalPrice.Money; } BalanceDetailInfo balanceDetails = new BalanceDetailInfo(); balanceDetails.UserId = orderInfo.UserId; balanceDetails.UserName = orderInfo.Username; balanceDetails.TradeDate = DateTime.Now; balanceDetails.TradeType = TradeTypes.RefundOrder; balanceDetails.Income = new decimal?(money); balanceDetails.Balance = user.Balance + money; balanceDetails.Remark = "订单退款到预付款"; if (rdolist.SelectedValue == "2") { if (!user.IsOpenBalance) { ShowMsg("本次退款已失败,该用户的预付款还没有开通", false); } else if (UnderlingHelper.AddUnderlingBalanceDetail(balanceDetails)) { orderInfo.RefundAmount = money; orderInfo.RefundRemark = Globals.HtmlEncode(txtRefundRemark.Text.Trim()); orderInfo.FinishDate = DateTime.Now; orderInfo.RefundStatus = RefundStatus.Refund; if (SubsiteSalesHelper.RefundOrder(orderInfo)) { Messenger.OrderRefund(user, orderInfo.OrderId, money); orderInfo.OnRefund(); Page.Response.Redirect(Globals.ApplicationPath + string.Format("/Shopadmin/sales/RefundOrderDetails.aspx?OrderId={0}", orderInfo.OrderId)); } else { ShowMsg("退款失败", false); } } } else { orderInfo.RefundAmount = money; orderInfo.RefundRemark = Globals.HtmlEncode(txtRefundRemark.Text.Trim()); orderInfo.FinishDate = DateTime.Now; orderInfo.RefundStatus = RefundStatus.Below; if (SubsiteSalesHelper.RefundOrder(orderInfo)) { Messenger.OrderRefund(user, orderInfo.OrderId, money); orderInfo.OnRefund(); Page.Response.Redirect(Globals.ApplicationPath + string.Format("/Shopadmin/sales/RefundOrderDetails.aspx?OrderId={0}", orderInfo.OrderId)); } else { ShowMsg("退款失败", false); } } } } }
public override bool InsertBalanceDetail(BalanceDetailInfo balanceDetails, DbTransaction dbTran) { if (null == balanceDetails) { return false; } DbCommand sqlStringCommand = database.GetSqlStringCommand("INSERT INTO Hishop_DistributorBalanceDetails (UserId,UserName, TradeDate, TradeType, Income, Expenses, Balance, Remark) VALUES(@UserId,@UserName, @TradeDate, @TradeType, @Income, @Expenses, @Balance, @Remark);UPDATE aspnet_Distributors SET Balance = @Balance WHERE UserId = @UserId;"); database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, balanceDetails.UserId); database.AddInParameter(sqlStringCommand, "UserName", DbType.String, balanceDetails.UserName); database.AddInParameter(sqlStringCommand, "TradeDate", DbType.DateTime, balanceDetails.TradeDate); database.AddInParameter(sqlStringCommand, "TradeType", DbType.Int32, (int)balanceDetails.TradeType); database.AddInParameter(sqlStringCommand, "Income", DbType.Currency, balanceDetails.Income); database.AddInParameter(sqlStringCommand, "Expenses", DbType.Currency, balanceDetails.Expenses); database.AddInParameter(sqlStringCommand, "Balance", DbType.Currency, balanceDetails.Balance); database.AddInParameter(sqlStringCommand, "Remark", DbType.String, balanceDetails.Remark); if (dbTran != null) { return (database.ExecuteNonQuery(sqlStringCommand, dbTran) > 0); } return (database.ExecuteNonQuery(sqlStringCommand) > 0); }
void Notify_Finished(object sender, FinishedEventArgs e) { DateTime now = DateTime.Now; TradeTypes selfhelpInpour = TradeTypes.SelfhelpInpour; Distributor user = Users.GetUser(InpourRequest.UserId, false) as Distributor; decimal num = user.Balance + InpourRequest.InpourBlance; BalanceDetailInfo balanceDetails = new BalanceDetailInfo(); balanceDetails.UserId = InpourRequest.UserId; balanceDetails.UserName = user.Username; balanceDetails.TradeDate = now; balanceDetails.TradeType = selfhelpInpour; balanceDetails.Income = new decimal?(InpourRequest.InpourBlance); balanceDetails.Balance = num; if (paymode != null) { balanceDetails.Remark = "充值支付方式:" + paymode.Name; } if (SubsiteStoreHelper.AddBalanceDetail(balanceDetails, InpourId)) { Users.ClearUserCache(user); ResponseStatus(true, "success"); } else { SubsiteStoreHelper.RemoveInpourRequest(InpourId); ResponseStatus(false, "fail"); } }
public static bool AddBalanceDetail(BalanceDetailInfo balanceDetails, string inpourId) { return SubsiteStoreProvider.Instance().AddBalanceDetail(balanceDetails, inpourId); }