コード例 #1
0
        /// <summary>
        /// 购物车 -> 待付款立即购买
        /// </summary>
        /// <param name="arrID"></param>
        /// <returns></returns>
        public Tuple<bool, string> ShopOrderToBeOrderOpe(string[] arrID)
        {
            //Init
            string strIDs = string.Join("','", arrID);
            strIDs = string.Format("'{0}'", strIDs);

            WX_ZZSCBeOrderDAL beOrderDal = new WX_ZZSCBeOrderDAL();
            WX_ZZSCOrderLineDAL orderLienDal = new WX_ZZSCOrderLineDAL();
            WX_ZZSCShopOrderDAL shopOrderDal = new WX_ZZSCShopOrderDAL();

            //Query
            IEnumerable<WX_ZZSCShopOrderInfo> list = new WX_ZZSCShopOrderDAL().Query<WX_ZZSCShopOrderInfo>(string.Format(" ID IN ({0})", strIDs));

            //Check
            if (list.Count().Equals(0)) { return new Tuple<bool, string>(false, "无购物车数据!"); }

            //SQL
            List<string> listSql = new List<string>();
            List<object> listPar = new List<object>();

            //Result Data
            string beOrderIDs = string.Empty;

            //1.需要分组:不同商城

            string userID = list.FirstOrDefault().UserID;

            foreach (var item in list.GroupBy(x => x.StoreID))
            {
                WX_ZZSCBeOrderInfo beOrderMod = new WX_ZZSCBeOrderInfo();
                beOrderMod.ID = Guid.NewGuid().ToString("N");
                beOrderIDs += beOrderMod.ID + ",";
                beOrderMod.StoreID = item.Key;
                beOrderMod.UserID = userID;
                beOrderMod.OpeDate = DateTime.Now;
                beOrderMod.OrderType = 3;
                beOrderMod.DiscountType = 0;
                beOrderMod.Remark = string.Empty;
                beOrderMod.RealPrice = 0;
                beOrderMod.Price = 0;
                beOrderMod.OrderState = 1;
                beOrderMod.OrderNum = GUIDHelper.GenerateOrderNum();

                foreach (var vItem in item)
                {
                    WX_ZZSCOrderLineInfo orderLineMod = new WX_ZZSCOrderLineInfo();
                    orderLineMod.ID = Guid.NewGuid().ToString("N");
                    orderLineMod.LineID = beOrderMod.ID;
                    orderLineMod.CommodityID = vItem.CommodityID;
                    orderLineMod.CommodityOptionID = string.IsNullOrEmpty(vItem.CommodityOptionID) ? string.Empty : vItem.CommodityOptionID;
                    orderLineMod.Count = vItem.Count;
                    orderLineMod.UnitPrice = vItem.Price / vItem.Count;
                    orderLineMod.RealUnitPrice = vItem.RealPrice / vItem.Count;
                    orderLineMod.TotalPrice = vItem.RealPrice;
                    orderLineMod.DiscountType = vItem.DiscountType;
                    orderLineMod.Remark = string.Empty;
                    orderLineMod.CommodityType = vItem.CommodityType;
                    orderLineMod.OpeDate = DateTime.Now;

                    beOrderMod.RealPrice += Convert.ToDouble(vItem.RealPrice);
                    beOrderMod.Price += Convert.ToDouble(vItem.Price);

                    //存上BeOrder表的ID,作为凭证
                    vItem.Remark = beOrderMod.ID;

                    listSql.Add(orderLienDal.AddSQL());
                    listPar.Add(orderLineMod);
                }

                listSql.Add(beOrderDal.AddSQL());
                listPar.Add(beOrderMod);
            }

            //Update 购物车订单数据
            foreach (var item in list)
            {
                item.OrderState = 1;
                item.OrderType = 3;
                listSql.Add(shopOrderDal.UpdateSQL());
                listPar.Add(item);
            }

            //2执行SQL
            return new Tuple<bool, string>(new BaseDAL().ExecuteTran(listSql, listPar), beOrderIDs);
        }
コード例 #2
0
 /// <summary>
 /// 根据ID进行删除
 /// </summary>
 /// <param name="shopID"></param>
 public void DeleteShopOrder(string shopID)
 {
     var result = new WX_ZZSCShopOrderDAL().Delete(new { ID = shopID });
 }
コード例 #3
0
 /// <summary>
 /// 加入购物车:Inser 表数据
 /// </summary>
 /// <param name="model"></param>
 public void AddShopOpe(WX_ZZSCShopOrderInfo model)
 {
     try
     {
         var resultNa = new WX_ZZSCShopOrderDAL().Add(model);
     }
     catch (Exception ex)
     {
         LogFileHelper.WriteLogByTxt("立即购买:PlaceOrderOpe方法执行失败:" + ex.Message);
     }
 }
コード例 #4
0
 /// <summary>
 /// 进行Update
 /// </summary>
 /// <param name="model"></param>
 public void UpdateShopOrder(WX_ZZSCShopOrderInfo model)
 {
     var result = new WX_ZZSCShopOrderDAL().Update(model);
 }