示例#1
0
 /// <summary>
 /// 得到一个实体
 /// </summary>
 /// <param name="orderId"></param>
 /// <returns></returns>
 public ShowShop.Model.Order.PrepayMoney GetModelByOrderId(string orderId)
 {
     ShowShop.Model.Order.PrepayMoney model = new ShowShop.Model.Order.PrepayMoney();
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select  top 1 id,orderid,username,payoutmoney,remark,bosomnote,notedate,notename from yxs_prepaymoney ");
     strSql.Append(" where [orderid]=@orderid ");
     SqlParameter parameters = new SqlParameter("@orderid", SqlDbType.VarChar, 50);
     parameters.Value = orderId;
     using (SqlDataReader reader = ChangeHope.DataBase.SQLServerHelper.ExecuteReader(strSql.ToString(), parameters))
     {
         if (reader.Read())
         {
             model.ID = reader.GetInt32(0);
             model.OrderId = reader.GetString(1);
             model.UserName = reader.GetString(2);
             model.PayoutMoney = Convert.ToDecimal(reader["payoutmoney"]);
             model.Remark = reader.GetString(4);
             model.BosomNote = reader.GetString(5);
             model.NoteDate = reader.GetDateTime(6);
             model.NoteName = reader.GetString(7);
         }
         else
         {
             model = null;
         }
     }
     return model;
 }
        protected void lbtnSave_Click(object sender, EventArgs e)
        {
            /*修改人:YM
             *修改时间:2009-12-17
             *判断订单是否是会员订单及用户是否存在
             */
            if (this.lblUserName.Text.Trim() == "")
            {
                this.ltlMsg.Text = "操作失败!您所支付的订单可能是非会员生成的订单.";
                this.pnlMsg.Visible = true;
                this.pnlMsg.CssClass = "actionErr";
                return;
            }
            ShowShop.Model.Admin.AdminInfo adminInfo = (ShowShop.Model.Admin.AdminInfo)ShowShop.Common.AdministrorManager.Get();
            ShowShop.BLL.Member.MemberAccount memberBll = new ShowShop.BLL.Member.MemberAccount();
            ShowShop.Model.Member.MemberAccount memberModel = memberBll.GetModel(this.lblUserName.Text);
            if (memberModel == null)
            {
                this.ltlMsg.Text = "操作失败!该会员不存在.";
                this.pnlMsg.Visible = true;
                this.pnlMsg.CssClass = "actionErr";
                return;
            }
            #region 订单预付款资金
            ShowShop.Model.Order.PrepayMoney preModel = new ShowShop.Model.Order.PrepayMoney();
            ShowShop.BLL.Order.PrepayMoney preBll = new ShowShop.BLL.Order.PrepayMoney();
            preModel.OrderId = this.lblOrderId.Text;
            preModel.UserName = this.lblUserName.Text;
            preModel.PayoutMoney = Convert.ToDecimal(this.txtPayoutMoney.Text.Trim());
            preModel.Remark = this.txtRemark.Text;
            preModel.BosomNote = this.txtBosomNote.Text;
            preModel.NoteDate = DateTime.Now;
            preModel.NoteName = adminInfo.AdminName;
            #endregion

            #region 用户交易明细
            ShowShop.Model.Member.UserinAndExp userModel = new ShowShop.Model.Member.UserinAndExp();
            ShowShop.BLL.Member.UserinAndExp userBll = new ShowShop.BLL.Member.UserinAndExp();

            //资金的明细
            userModel.UID = memberModel.UID;
            userModel.AdsumMoneyDate = Convert.ToDateTime(this.txtAdsumMoneyDate.Text);
            userModel.AdsumMoney = Convert.ToDecimal(this.txtPayoutMoney.Text);
            userModel.PresentCoupons = 0;
            userModel.RemitMode = 2;
            userModel.RemitBank = string.Empty;
            userModel.Remark = this.txtRemark.Text;
            userModel.FormMode = string.Empty; //通知方式
            userModel.BosomNote = this.txtBosomNote.Text;
            userModel.NoteDate = DateTime.Now;
            userModel.NoteName = adminInfo.AdminName;
            userModel.InComeandExpState = 1;
            userModel.State = 0;
            userModel.UserId = this.lblUserName.Text;
            #endregion

            #region 订单状态
            ShowShop.BLL.Order.Orders orderBll = new ShowShop.BLL.Order.Orders();
            ShowShop.Model.Order.Orders orderModel = orderBll.GetModel(this.lblOrderId.Text);
            #endregion

            ShowShop.BLL.Member.MemberAccount mabll = new ShowShop.BLL.Member.MemberAccount();
            ShowShop.Model.Member.MemberAccount mamodel = mabll.GetModel(this.lblUserName.Text);
            try
            {
                //已付款+此次汇款的总和
                decimal payTotail = Convert.ToDecimal(this.GetPayed(this.lblOrderId.Text)) + Convert.ToDecimal(this.txtPayoutMoney.Text.Trim());
                #region 如果有多余的钱
                if (payTotail > Convert.ToDecimal(orderModel.FactPrice))
                {
                    ChangeHope.WebPage.BasePage.PageError("输入的金额大于了订单总额!", "order_bank_pay.aspx?OrderId=" + orderModel.Id);
                    return;
                }
                #endregion

                #region 查询用户金额 操作用户金额
                if (mamodel != null)
                {
                    decimal Price = decimal.Parse(mamodel.Capital.ToString());
                    if (Convert.ToDecimal(this.txtPayoutMoney.Text) > Price)
                    {
                        ChangeHope.WebPage.BasePage.PageError("用户余额不足!", "order_bank_pay.aspx?OrderId=" + orderModel.Id);
                        return;
                    }
                    mabll.Amend(mamodel.UID, "Capital", (Convert.ToDecimal(mamodel.Capital.ToString()) - Convert.ToDecimal(this.txtPayoutMoney.Text)));
                }

                #endregion
                preBll.Add(preModel);
                userBll.Add(userModel);

                #region 操作付款状态 订单状态

                int OrderId = ChangeHope.WebPage.PageRequest.GetQueryInt("OrderId");
                if (payTotail >= Convert.ToDecimal(orderModel.FactPrice))
                {
                    if (OrderId > 0)
                    {
                        orderBll.Amend(OrderId, "OrderStatus", ShowShop.Common.OrdersStatusEnum.OrderStatu.未结清.GetHashCode());
                        orderBll.Amend(OrderId, "PaymentStatus", ShowShop.Common.OrdersStatusEnum.PaymentStatu.已经付清.GetHashCode());
                        orderBll.Amend(OrderId, "OgisticsStatus", ShowShop.Common.OrdersStatusEnum.OgisticsStatus.配送中.GetHashCode());
                    }
                }
                else
                {
                    if (OrderId > 0)
                    {
                        orderBll.Amend(OrderId, "OrderStatus", ShowShop.Common.OrdersStatusEnum.OrderStatu.未结清.GetHashCode());
                        orderBll.Amend(OrderId, "PaymentStatus", ShowShop.Common.OrdersStatusEnum.PaymentStatu.未付清.GetHashCode());
                    }
                }
                #endregion
                ChangeHope.WebPage.BasePage.PageRight("已保存该信息", "order_bank_pay.aspx?OrderId=" + orderModel.Id);
            }
            catch
            {
                this.ltlMsg.Text = "操作失败!";
                this.pnlMsg.Visible = true;
                this.pnlMsg.CssClass = "actionErr";
            }
            finally
            {
                adminInfo = null;
                preModel = null;
                preBll = null;
                orderBll = null;
                orderModel = null;
                GC.Collect();
            }
        }
示例#3
0
 /// <summary>
 /// 得到指定条件的所有集合
 /// </summary>
 /// <param name="uid"></param>
 /// <returns></returns>
 public List<ShowShop.Model.Order.PrepayMoney> GetAll(string strWhere)
 {
     List<ShowShop.Model.Order.PrepayMoney> list = new List<ShowShop.Model.Order.PrepayMoney>();
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select  id,orderid,username,payoutmoney,remark,bosomnote,notedate,notename from yxs_prepaymoney ");
     if (strWhere != null && strWhere != "")
     {
         strSql.Append("where " + strWhere + " ");
     }
     using (SqlDataReader reader = ChangeHope.DataBase.SQLServerHelper.ExecuteReader(strSql.ToString()))
     {
         while (reader.Read())
         {
             ShowShop.Model.Order.PrepayMoney model = new ShowShop.Model.Order.PrepayMoney();
             model.ID = reader.GetInt32(0);
             model.OrderId = reader.GetString(1);
             model.UserName = reader.GetString(2);
             model.PayoutMoney = Convert.ToDecimal(reader["payoutmoney"]);
             model.Remark = reader.GetString(4);
             model.BosomNote = reader.GetString(5);
             model.NoteDate = reader.GetDateTime(6);
             model.NoteName = reader.GetString(7);
             list.Add(model);
         }
     }
     return list;
 }