コード例 #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>
        /// 地址确认支付页面中关于发票相关信息
        /// </summary>
        /// <param name="par1"></param>
        /// <param name="par2"></param>
        /// <param name="par3"></param>
        /// <param name="par4"></param>
        /// <returns></returns>
        public ActionResult OrderIsNeedInvoiceOpe(string par1, string par2, string par3, string par4)
        {
            string orderID = par1;
            bool isNeed = par2.Equals("True");
            string invoiceTitle = par3;
            string remark = string.IsNullOrEmpty(par4) ? string.Empty : par4;

            WX_ZZSCBeOrderInfo model = new WX_ZZSCBeOrderInfo()
            {
                ID = orderID,
                NeedInvoice = isNeed ? 1 : 0,
                InvoiceTitle = invoiceTitle,
                Remark = remark
            };

            bool result = shopService.OrderInvoiceInfoOpe(model);

            return Content(JsonConvert.SerializeObject(new { Flag = result, Msg = string.Empty }));
        }
コード例 #3
0
        /// <summary>
        /// 订单发票相关数据Update
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool OrderInvoiceInfoOpe(WX_ZZSCBeOrderInfo model)
        {
            //DAL
            WX_ZZSCBeOrderDAL orderDal = new WX_ZZSCBeOrderDAL();

            WX_ZZSCBeOrderInfo item = orderDal.Query<WX_ZZSCBeOrderInfo>("ID = @ID", model).FirstOrDefault();

            bool result = false;

            if (item != null)
            {
                item.NeedInvoice = model.NeedInvoice;
                item.InvoiceTitle = model.NeedInvoice.Equals(1) ? model.InvoiceTitle : string.Empty;
                item.Remark = model.Remark;

                result = shopCommodityDal.Execute(orderDal.UpdateSQL(), item) > 0;
            }

            return result;
        }