Exemplo n.º 1
0
        public OrderGoodsMedel GetOrderModel(string orderId, MemberOrderModel mOrder, SqlTransaction tran, decimal totalMoney, decimal totalPv)
        {
            //获取订单信息
            OrderGoodsMedel item = new OrderGoodsMedel();

            item.StoreId        = mOrder.StoreId;                                         //店铺ID
            item.OrderGoodsID   = orderId;                                                //订单号
            item.TotalMoney     = Convert.ToDecimal(totalMoney);                          //订单总金额
            item.TotalPv        = Convert.ToDecimal(totalPv);                             //订单总积分
            item.InceptAddress  = mOrder.ConAddress;                                      //收货人地址
            item.InceptPerson   = mOrder.Consignee;                                       //收货人姓名
            item.PostalCode     = mOrder.ConZipCode;                                      //收货人邮编
            item.Telephone      = mOrder.ConTelPhone;                                     //收货人电话
            item.OrderDatetime  = DateTime.Now.ToUniversalTime();                         //订单时间
            item.ExpectNum      = CommonDataBLL.GetMaxqishu();                            //获取期数
            item.TotalCommision = 0;                                                      //手续费
            item.GoodsQuantity  = 0;                                                      //货物件数
            item.Carriage       = 0;                                                      //运费
            item.Weight         = 0;                                                      //重要
            item.City.Country   = mOrder.ConCity.Country;                                 //国家
            item.City.Province  = mOrder.ConCity.Province;                                //省份
            item.City.City      = mOrder.ConCity.City;                                    //城市
            item.IscheckOut     = "Y";                                                    //是否支付
            item.OperateIP      = System.Web.HttpContext.Current.Request.UserHostAddress; //用户IP
            item.OrderType      = 0;                                                      //订单类型
            item.SendWay        = mOrder.SendWay;
            item.Description    = "会员【" + mOrder.Number + "】报单!";

            return(item);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 确认订单按钮
        /// </summary>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public Boolean OrderSubmit(string storeId, List <OrderDetailModel> orderDetails, OrderGoodsMedel storeItem, bool IsEdit)
        {
            using (SqlConnection conn = new SqlConnection(DBHelper.connString))
            {
                conn.Open();
                SqlTransaction tr = conn.BeginTransaction();//开启事务

                try
                {
                    if (IsEdit)                                                                                              //如果是修改订单,先删除原来的订单并还原原来的信息
                    {
                        BLL.CommonClass.ChangeLogs cl_h_info = new BLL.CommonClass.ChangeLogs("OrderGoods", "OrderGoodsID"); //实例日志类
                        cl_h_info.AddRecordtran(tr, storeItem.OrderGoodsID);                                                 //添加日志,修改前记录原来数据

                        StoreOrderDAL.DelStoreOrderItemProc(tr, storeItem.OrderGoodsID);
                        //StockDAL.DelStoreOrder(tr, OrderDetailDAL.GetOrderGoodsDetail(storeItem.StoreorderId), storeItem.StoreId);//还原店库存
                        //OrderDetailDAL.DelOrderGoodsDetail(tr, storeItem.StoreorderId);//明细表删除失败回滚
                        //StoreOrderDAL.DelOrderGoods(storeItem.StoreorderId, tr); //订单表删除失败回滚

                        cl_h_info.AddRecordtran(tr, storeItem.OrderGoodsID);                                                                                           //添加日志,修改后记录原来数据
                        cl_h_info.ModifiedIntoLogstran(tr, BLL.CommonClass.ChangeCategory.store10, storeItem.OrderGoodsID, BLL.CommonClass.ENUM_USERTYPE.objecttype2); //插入日志
                    }

                    //插入订单
                    if (new StoreOrderDAL().AddOrderGoods(storeItem, tr))
                    {
                        //订单表插入成功插入明细表
                        foreach (OrderDetailModel orderDetailItem in orderDetails)
                        {
                            if (!OrderDetailDAL.AddOrderGoodsDetail(tr, orderDetailItem, storeItem.OrderGoodsID))
                            {
                                tr.Rollback();
                                return(false);
                            }
                        }
                        //修改库存信息(预订数量)
                        foreach (OrderDetailModel orderDetailItem in orderDetails)
                        {
                            if (!StockDAL.UpdStockHasOrderCount(tr, storeItem.StoreId, orderDetailItem.ProductId, orderDetailItem.Quantity))
                            {
                                tr.Rollback();
                                return(false);
                            }
                        }

                        tr.Commit();//插入订单信息完成
                    }
                    else
                    {//订单插入失败回滚数据
                        tr.Rollback();
                        return(false);
                    }
                }
                catch
                {
                    //订单插入失败回滚数据
                    tr.Rollback();
                    return(false);
                }
                finally
                {
                    conn.Close();
                }
            }
            return(true);
        }
Exemplo n.º 3
0
        //报单调用的类
        public void SaveHOrder(SqlTransaction tran, IList <MemberDetailsModel> list, MemberOrderModel memberOrderModel)
        {
            RegistermemberBLL RegistermemberBLL = new RegistermemberBLL();

            //添加对账单
            if (memberOrderModel.DefrayType == 2)
            {
                BLL.Logistics.D_AccountBLL.AddAccount(memberOrderModel.ElectronicaccountId, Convert.ToDouble(memberOrderModel.TotalMoney), D_AccountSftype.MemberType, D_AccountKmtype.Declarations, DirectionEnum.AccountReduced, "会员【" + memberOrderModel.Number + "】用会员【" + memberOrderModel.ElectronicaccountId + "】电子货币报单,订单号为【" + memberOrderModel.OrderId + "】", tran);
                BLL.Logistics.D_AccountBLL.AddAccount(memberOrderModel.StoreId, Convert.ToDouble(memberOrderModel.TotalMoney), D_AccountSftype.StoreType, D_AccountKmtype.AccountTransfer, DirectionEnum.AccountsIncreased, "会员【" + memberOrderModel.Number + "】用会员【" + memberOrderModel.ElectronicaccountId + "】电子货币报单转入,订单号为【" + memberOrderModel.OrderId + "】", tran);
                // 电子帐户支付
                IsElecPay(tran, memberOrderModel);
            }

            AddOrderDataDAL addOrderDataDAL = new AddOrderDataDAL();

            //插入memberOrder表
            addOrderDataDAL.INSERT_H_Order(memberOrderModel, tran);

            foreach (Model.MemberDetailsModel mDetails in list)
            {
                //插入订单明细
                addOrderDataDAL.insert_MemberOrderDetails(memberOrderModel, mDetails, tran);

                //未支付报单不算库存
                if (memberOrderModel.DefrayState == 1)
                {
                    //更新减去店库存
                    int result = 0;
                    result = addOrderDataDAL.updateStore(memberOrderModel.StoreId, mDetails, tran);

                    ////添加该类型的记录,用负数表示
                    if (result <= 0)
                    {
                        addOrderDataDAL.updateStore2(memberOrderModel.StoreId, mDetails, tran);
                    }
                }
            }

            if (memberOrderModel.DefrayState == 1)
            {
                //报单生成订单
                int     count      = 0;
                decimal totalMoney = 0;
                decimal totalPv    = 0;
                foreach (MemberDetailsModel mDetails in list)
                {
                    if (mDetails.NotEnoughProduct > 0)
                    {
                        totalMoney += mDetails.NotEnoughProduct * mDetails.Price;
                        totalPv    += mDetails.NotEnoughProduct * mDetails.Pv;
                        count++;
                    }
                }
                if (count > 0)
                {
                    string orderId = "";
                    orderId = BLL.Logistics.OrderGoodsBLL.GetNewOrderID();
                    //自动为店铺生成要货申请单
                    OrderGoodsMedel storeItem = GetOrderModel(orderId, memberOrderModel, tran, totalMoney, totalPv);
                    //插入要货申请单明细
                    OrderSubmit(memberOrderModel.OrderId.ToString(), list, storeItem, tran);
                }



                int sd = addOrderDataDAL.updateStoreL(tran, memberOrderModel.OrderId);



                //添加对账单
                if (memberOrderModel.DefrayType == 1 || memberOrderModel.DefrayType == 2)
                {
                    if (Convert.ToDouble(memberOrderModel.LackProductMoney) > 0)
                    {
                        BLL.Logistics.D_AccountBLL.AddAccount(memberOrderModel.StoreId, Convert.ToDouble(memberOrderModel.LackProductMoney), D_AccountSftype.StoreType, D_AccountKmtype.Declarations, DirectionEnum.AccountReduced, "会员【" + memberOrderModel.Number + "】报单现金扣除额,订单号为【" + memberOrderModel.OrderId + "】", tran);
                    }
                }


                //增加该店铺的总报单的费用(累计)
                addOrderDataDAL.updateStore3(memberOrderModel.StoreId, tran, Convert.ToDouble(memberOrderModel.LackProductMoney));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 报单生成订单
        /// </summary>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public void OrderSubmit(string orderid, IList <MemberDetailsModel> mDetailsModel, OrderGoodsMedel storeItem, SqlTransaction tran)
        {
            //插入订单
            int ExpectNum  = CommonDataBLL.getMaxqishu();
            int ActiveFlag = 1;             //添加:1,修改:2,在线订货:0

            //订单表插入成功插入明细表
            if (new AddOrderDataDAL().AddOrderGoods(storeItem, orderid, tran, ActiveFlag))
            {
                //订单表插入成功插入明细表
                foreach (MemberDetailsModel mDetails in mDetailsModel)
                {
                    if (mDetails.NotEnoughProduct > 0)
                    {
                        new AddOrderDataDAL().AddOrderGoodsDetail(tran, mDetails, storeItem.OrderGoodsID, storeItem.StoreId, ExpectNum);
                    }
                }
            }
        }