public ActionResult GetOrder(ShopOrder order) { //order.TotalPrice = double.Parse(GetCart().ComputeTotalValue().ToString()); //order.OrderDate = DateTime.Now; try { storeContext.ShopOrders.Add(order); storeContext.SaveChanges(); ShopOrder currentOrder = storeContext.ShopOrders.ToList().Last(); foreach (CartLine cartLine in GetCart().Lines) { storeContext.Baskets.Add(new Basket { ProductId = cartLine.Product.Id, ShopOrderId = currentOrder.Id }); } storeContext.SaveChanges(); return(View(currentOrder)); } catch { return(View("ErrorMessage")); } }
/// <summary> /// 标记订单,委托 /// </summary> /// <param name="OrderID"></param> /// <returns></returns> public JsonResult WeiTuoOrder(string OrderID) { try { ShopOrder model = DB.ShopOrder.FindEntity(q => q.GUID == OrderID); //model.State = ShopEnum.OrderState.WeiTuo.GetHashCode(); #region 委托 //给零售区加库存 //var lingshouqu = DB.ShopOrderProduct.Where(p => p.OrderID == model.GUID).FirstOrDefault(); //var shopOrderProudct = DB.ShopProduct.Where(p => p.Title == lingshouqu.Name && p.CategoryID1 == 15).FirstOrDefault(); //shopOrderProudct.Inventory = Convert.ToInt32(shopOrderProudct.Inventory + model.ZongDay); //DB.ShopProduct.Update(shopOrderProudct); model.State = ShopEnum.OrderState.GuaM.GetHashCode(); model.Type = "挂卖中"; model.SubmitTime = DateTime.Now;//委托时间 //DB.ShopOrder.Update(model); #endregion if (DB.ShopOrder.Update(model)) { return(Success("操作成功")); } return(Error("操作失败")); } catch (Exception ex) { return(Error(ex)); } }
/// <summary> /// 返回支付渠道 /// </summary> /// <param name="args"></param> /// <returns></returns> //[HttpPost] //[Authorize] //public APIResult ToPayChannel([FromBody]ToAmountArgsModel args) //{ // ShopOrder shopOrder = db.Set<ShopOrder>().Find(args.id); // if (shopOrder == null) throw new Exception("订单不存在"); // CheckShopActor(shopOrder.ShopId, ShopActorType.超级管理员); // return Success(); //} /// <summary> /// 减少统计过的销量 /// </summary> /// <param name="model"></param> void DecreaseCommodity(ShopOrder model) { //获取订单中商品的数量 var commodityIdAndCounts = db.Query <ShopOrderItem>() .Where(m => m.ShopOrderId == model.Id) .Where(m => !m.IsDel) .Select(m => new { m.CommodityStock.Sku.CommodityId, m.Count }) .ToList() .GroupBy(m => m.CommodityId) .ToDictionary(m => m.Key, m => m.Select(x => x.Count).Sum()); //更新商品的销售量 //注意,这里如果有一个品牌,多个店铺的情况,会出现销售额共享的情况 var commodityIds = commodityIdAndCounts.Select(m => m.Key).ToList(); var commoditys = db.Query <ShopBrandCommodity>() .Where(m => commodityIds.Contains(m.Id)) .ToList(); foreach (var item in commoditys) { item.SalesForMonth -= commodityIdAndCounts[item.Id]; } }
internal static ShopOrder GetShopOrder(int id) { ShopOrder m = new ShopOrder(id); if (id > 0) { SafeProcedure.ExecuteAndMapRecords( Database.GetDatabase(JaneDefine.DBInstanceName), "dbo.Shop_orders_Get", delegate(IRecord record) { m.Id = record.GetInt32OrDefault(0, 0); m.UserId = record.GetInt32OrDefault(1, 0); m.AddDate = record.GetDateTimeOrEmpty(2); m.Ordertype = (OrderType)(record.GetInt32OrDefault(3, 0)); m.Address = record.GetStringOrEmpty(4); m.Email = record.GetStringOrEmpty(5); m.Mobile = record.GetStringOrEmpty(6); m.Paymoney = record.GetDouble(7); m.Paytype = (PayType)(record.GetInt32OrDefault(8, 0)); m.Payresult = (PayResult)(record.GetInt32OrDefault(9, 0)); m.Payremark = record.GetStringOrEmpty(10); m.Paythirdnum = record.GetStringOrEmpty(11); m.Paydate = record.GetDateTime(12); m.ZipCode = record.GetStringOrEmpty(13); m.UserName = record.GetStringOrEmpty(14); m.RegionId = record.GetInt32OrDefault(15, 0); m.Freight = record.GetDouble(16); m.RegionStr = record.GetStringOrEmpty(17); }, id); } return(m); }
public APIResult BalanceConsume([FromBody] BalanceConsumeArgsModel args) { int memberId = GetMemberId(); ShopOrder shopOrder = shopDb.GetSingle <ShopOrder>(args.OrderId); if (shopOrder == null) { throw new Exception("订单不存在"); } var shopMemberServer = new ShopMemberServer(shopDb, shopOrder.ShopId, memberId); //if (!shopMemberServer.CheckPassword(args.Password)) throw new Exception("支付密码不正确"); if (!shopMemberServer.BalanceConsume(shopOrder)) { throw new Exception("当前余额不足"); } var checkThirdResult = CheckThird(shopOrder, shopOrder.ShopId); if (!checkThirdResult.Success) { throw new Exception(checkThirdResult.Message); } shopDb.SaveChanges(); Utils.ShopOrderUtil.SetShopOrderFinishInBackgroup(shopOrder.Id); return(Success()); }
public void Delete(ShopOrder shopOrder, ShopCustomer shopCustomer, ShopOrderDetail shopOrderDetail) { context.ShopOrder.Remove(shopOrder); context.ShopCustomer.Remove(shopCustomer); context.ShopOrderDetail.Remove(shopOrderDetail); context.SaveChanges(); }
public ActionResult Save(ShopOrder entity) { var json = new JsonHelp(); try { json.IsSuccess = DB.ShopOrder.Update(entity); json.Msg = "修改"; if (json.IsSuccess) { json.ReUrl = ControllerPath + "/Index"; //注册成功就跳转到 激活页 json.Msg += "成功"; } else { json.Msg += "失败"; } } catch (Exception e) { json.IsSuccess = false; json.Msg = "操作失败"; LogHelper.Error("保存快递公司失败:" + WebTools.getFinalException(e)); } return(Json(json)); }
public ShopOrder loadShopOrder(bool decrypt) { ShopOrder data = null; string encrpytStr = null; string decryptStr = null; try { // Create an instance of StreamReader to read from a file. // The using statement also closes the StreamReader. using (StreamReader sr = new StreamReader(ShardShopPath)) { // Read and display lines from the file until the end of the file is reached. encrpytStr = sr.ReadToEnd(); } if (decrypt) { decryptStr = Crypto.DecryptStringAES(encrpytStr, Consts.shareShopSecret); data = SDK.Deserialize <ShopOrder> (decryptStr); } else { data = SDK.Deserialize <ShopOrder> (encrpytStr); } } catch (Exception e) { // Let the user know what went wrong. //WG.SLog (e.Message); } return(data); }
/// 修改订单信息 /// </summary> public void UpdateOrderInfo(List <string> orderList, int AddressID, string remark, bool isziti, string paytype) { //获取地址 ShopMyAddress address = DB.ShopMyAddress.FindEntity(q => q.ID == AddressID); if (address == null) { throw new Exception("获取收货地址失败"); } foreach (var item in orderList) { ShopOrder orderModel = DB.ShopOrder.FindEntity(item); if (orderModel != null) { orderModel.Receiver = address.Name; orderModel.PostAddress = address.ShowAddressName; orderModel.Type = address.ShowAddressId; orderModel.Tel = address.Tel; orderModel.Remark = remark; orderModel.IsZiTi = isziti; orderModel.PayWay = paytype; //if (orderModel.IsZiTi && orderModel.RealCongXiao > 0) //{ // orderModel.RealCongXiao = 0; //} DB.ShopOrder.Update(orderModel); } } }
/// <summary> /// 确认收货操作 /// </summary> /// <returns></returns> public ActionResult DoTakeGoods(string pwd2, string guid) { try { //1.验证支付密码 Member_Info curUser = User_Shop.GetMember_Info(); if (curUser.Pwd2 != Common.CryptHelper.DESCrypt.Encrypt(pwd2)) { throw new Exception("支付密码不正确"); } //2.订单进入,待评价/已收货状态 ShopOrder model = DB.ShopOrder.FindEntity(guid); model.State = ShopEnum.OrderState.Finish.GetHashCode(); //确认收货 model.FinishTime = DateTime.Now; DB.ShopOrder.Update(model); ////3.结算系统处理 //DB.ShopOrder.OrderSettlement(guid); //if (model.OrderType != "积分优惠券") //{ // DB.Jiang.GiveJiang(DB.Member_Info.FindEntity(model.MemberID), model); //} return(Success("操作成功")); } catch (Exception ex) { return(Error(ex)); } }
/// <summary> /// 标记订单,挂卖 /// </summary> /// <param name="OrderID"></param> /// <returns></returns> public ActionResult WeiTuoOrder(string pwd2, string guid) { try { //1.验证支付密码 Member_Info curUser = User_Shop.GetMember_Info(); if (curUser.Pwd2 != Common.CryptHelper.DESCrypt.Encrypt(pwd2)) { throw new Exception("支付密码不正确"); } ShopOrder model = DB.ShopOrder.FindEntity(q => q.GUID == guid); #region 挂卖 //给零售区加库存 //var lingshouqu = DB.ShopOrderProduct.Where(p => p.OrderID == model.GUID).FirstOrDefault(); //var shopOrderProudct = DB.ShopProduct.Where(p => p.Title == lingshouqu.Name && p.CategoryID1 == 15).FirstOrDefault(); //shopOrderProudct.Inventory = Convert.ToInt32(shopOrderProudct.Inventory + model.ZongDay); //DB.ShopProduct.Update(shopOrderProudct); model.State = ShopEnum.OrderState.GuaM.GetHashCode(); model.Type = "挂卖中"; model.SubmitTime = DateTime.Now;//挂卖时间 DB.ShopOrder.Update(model); #endregion return(Success("操作成功")); } catch (Exception ex) { return(Error(ex)); } }
public async System.Threading.Tasks.Task <IActionResult> Edit(int id, ShopOrder shopOrder) { if (id != shopOrder.ShopOrderNumber) { return(NotFound()); } if (ModelState.IsValid) { try { shopOrder.Customer = shopOrder.Customer; shopOrder.PartName = shopOrder.PartName; shopOrder.OrderQuantity = shopOrder.OrderQuantity; shopOrder.MachineId = shopOrder.MachineId; _context.Update(shopOrder); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShopOrderExists(shopOrder.ShopOrderNumber)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(shopOrder)); }
private ShopOrder loadShopOrder() { SharedPrefs prefs = SharedPrefs.getInstance(); ShopOrder data = prefs.loadShopOrder(Consts.AES_ENCRYPT); return(data); }
public void TestMethod1() { using (var shopDb = TShopDbContxtFactory.MarkShopDb()) { using (var db = TShopDbContxtFactory.MarkFinanceDb()) { BeginRechangeArgsModel args = new BeginRechangeArgsModel(); if (args.ShopFlag == null) { throw new ArgumentNullException("ShopFlag"); } if (!args.ShopOrderId.HasValue) { throw new ArgumentNullException("ShopOrderId"); } var memberId = 113; ShopOrder shopOrder = shopDb.GetSingle <ShopOrder>(args.ShopOrderId.Value); if (shopOrder == null) { throw new Exception("订单不存在"); } ShopPayInfo shopPayInfo = shopDb.Query <ShopPayInfo>() .Where(m => !m.IsDel) .Where(m => m.ShopFlag == args.ShopFlag && m.IsEnable) .FirstOrDefault(); if (shopPayInfo == null) { throw new Exception("当前商铺没有设置好支付信息。"); } PayProxyBase payProxy = FactoryUtil.GetPayProxyFactory().GetProxy(shopPayInfo); var tradeNo = "SP" + DateTime.Now.Ticks + CommonUtil.CreateNoncestr(5); var tradeDate = DateTime.Now.ToString("yyyyMMddHHmmss"); var model = new MemberTradeForRechange() { AddTime = DateTime.Now, MemberId = memberId, Detail = "用户支付" + shopOrder.Payment.Value + "分", OutBank = "", PayChannel = payProxy.PayChannel, Status = MemberTradeForRechangeStatus.未完成, TimeExpire = DateTime.Now, TimeStart = DateTime.Now, Title = "用户支付", TotalFee = shopOrder.Payment.Value, ShopOrderId = args.ShopOrderId.Value, MoneyOffRuleId = shopOrder.MoneyOffRuleId, TradeNo = tradeNo, PayWay = (int)shopPayInfo.PayWay, //ShopType = shopOrder RowVersion = DateTime.Now }; db.AddToMemberTradeForRechange(model); var payInfo = payProxy.GetPayInfo(model, ""); } } }
public async System.Threading.Tasks.Task <IActionResult> Create([Bind("ShopOrderNumber,Customer,PartNumber,PartName,OrderQuantity,RawMatlInventoryId,OrderRecDate,OrderDueDate,MachineId,ScheduleStartTime,ScheduleEndTime,OperationSetUpHours,OperationProductionHours,OperationTearDownHours,GrossProductionRate,NetProductionRate,Profitability")] ShopOrder shopOrder) { if (ModelState.IsValid) { _context.Add(shopOrder); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(shopOrder)); }
/// <summary> /// 直接设置订单完成 /// </summary> /// <param name="shopOrder"></param> /// <param name="printDbContext"></param> /// <param name="db"></param> /// <param name="options"></param> /// <param name="_logger"></param> public static void SetShopOrderFinish(this ShopOrder shopOrder, PrintDbContext printDbContext, ShopDbContext db, WechatTemplateSendOptions options, ThirdConfig toptions, ILogger _logger) { OrderFinish(printDbContext, db, options, toptions, shopOrder, _logger); var shopName = db.Query <Shop>() .Where(m => m.Id == shopOrder.ShopId) .Select(m => m.Name) .FirstOrDefault(); AfterOrderPlacing(printDbContext, db, toptions, shopOrder, shopName, options, _logger); }
private decimal GetFuWuBiLi(ShopOrder shoporder, int rote, int type) { var prolist = DB.ShopOrderProduct.Where(a => a.OrderID == shoporder.GUID).ToList(); var amount = 0m; for (int i = 0; i < prolist.Count; i++) { var productid = prolist[i].ProductID; var product = DB.ShopProduct.FindEntity(productid); if (type == 1 && rote == 1) { amount += (DB.ShopProduct.GetSPrice(product, prolist[i].GuiGe).ZC1 *prolist[i].Count).Value; } else if (type == 1 && rote == 2) { amount += (DB.ShopProduct.GetSPrice(product, prolist[i].GuiGe).ZC2 *prolist[i].Count).Value; } else if (type == 1 && rote == 3) { amount += (DB.ShopProduct.GetSPrice(product, prolist[i].GuiGe).ZC3 *prolist[i].Count).Value; } else if (type == 1 && rote == 4) { amount += (DB.ShopProduct.GetSPrice(product, prolist[i].GuiGe).ZC4 *prolist[i].Count).Value; } else if (type == 1 && rote == 5) { amount += (DB.ShopProduct.GetSPrice(product, prolist[i].GuiGe).ZC5 *prolist[i].Count).Value; } else if (type == 2 && rote == 1) { amount += (DB.ShopProduct.GetSPrice(product, prolist[i].GuiGe).TJZC1 *prolist[i].Count).Value; } else if (type == 2 && rote == 2) { amount += (DB.ShopProduct.GetSPrice(product, prolist[i].GuiGe).TJZC2 *prolist[i].Count).Value; } else if (type == 2 && rote == 3) { amount += (DB.ShopProduct.GetSPrice(product, prolist[i].GuiGe).TJZC3 *prolist[i].Count).Value; } else if (type == 2 && rote == 4) { amount += (DB.ShopProduct.GetSPrice(product, prolist[i].GuiGe).TJZC4 *prolist[i].Count).Value; } else if (type == 2 && rote == 5) { amount += (DB.ShopProduct.GetSPrice(product, prolist[i].GuiGe).TJZC3 *prolist[i].Count).Value; } } return(amount); }
//========================================================== //========================================================== public ActionResult Details(int?id) { ShopOrder order = db.ShopOrders .Include(o => o.ApplicationUser) .Include(o => o.ShopOrderProducts) .Where(b => b.Id == id) .SingleOrDefault(); if (order == null) { return(HttpNotFound()); } ViewOrder orderView = new ViewOrder { Id = order.Id, DateCreation = order.DateCreate, UserFullName = order.ApplicationUser.UserProfile.Surname + " " + order.ApplicationUser.UserProfile.Name + " " + order.ApplicationUser.UserProfile.Patronymic, Passport = order.ApplicationUser.UserProfile.PassportNumberAndSeries + ", выдан " + order.ApplicationUser.UserProfile.PassportIssuingDate.ToShortDateString() }; //адрес orderView.Adress = FromBDToAdressString( order.ApplicationUser.UserProfile.Country, order.ApplicationUser.UserProfile.City, order.ApplicationUser.UserProfile.ZipCode, order.ApplicationUser.UserProfile.Street, order.ApplicationUser.UserProfile.House, order.ApplicationUser.UserProfile.Apartment); orderView.Products = new List <ViewOrderProduct>(); foreach (ShopOrderProduct product in order.ShopOrderProducts) { orderView.PriceTotal = orderView.PriceTotal + product.Price; ViewOrderProduct productView = new ViewOrderProduct { Name = product.ShopProduct.Name, Brand = product.ShopProduct.ShopProductsBrand.Name, VendorCode = product.ShopProduct.VendorCode, Quantity = product.Quantity, PriceOne = product.Price, PriceAll = product.Quantity * product.Price }; orderView.Products.Add(productView); } return(View(orderView)); }
public ActionResult Payment(long customerID, decimal?TotalMoney, string shipName, string mobile, string address) { var totalorderdao = new TotalOrderDAO(); var totalorder = new TotalOrder(); totalorder.CustomerID = customerID; totalorder.CreateDate = DateTime.Now; totalorder.CustomerName = shipName; totalorder.Phone = mobile; totalorder.Address = address; totalorder.TotalPrice = TotalMoney; totalorder.Status = 0; try { var idTotalOrder = totalorderdao.Insert(totalorder); var cart = (List <CartItem>)Session[CartSession]; var listshopID = cart.GroupBy(x => x.Product.CreateBy).Select(group => new { ID = group.Key }); foreach (var shop in listshopID) { var shoporderdao = new ShopOrderDAO(); var shoporder = new ShopOrder(); shoporder.IDTotalOrder = idTotalOrder; shoporder.IDMerchant = shop.ID; shoporder.Status = 0; var idShopoder = shoporderdao.Insert(shoporder); decimal?tongtienshop = 0; foreach (var detail in cart) { if (detail.Product.CreateBy == shop.ID) { var detailorderdao = new OrderDetailDAO(); var detailorder = new OrderDetail(); detailorder.IDProduct = detail.Product.ID; detailorder.Price = detail.Product.Price; detailorder.Quantity = detail.Quantity; detailorder.IDShopOrder = idShopoder; tongtienshop += detailorder.Price * detailorder.Quantity; detailorderdao.Insert(detailorder); } new ProductDAO().UpdateQuantity(detail.Product.ID, detail.Quantity); } shoporderdao.UpdateTotalPrice(idShopoder, tongtienshop); } } catch (Exception ex) { // de cho vui return(Redirect("/loi-thanh-toan")); } Session[CartSession] = null; new ProductDAO().SetProductOutOfStock(); return(RedirectToAction("SuccessPayment")); }
public IHttpActionResult Get(int id) { var order = services.Get(id); if (order != null) { ShopOrder _order = mapper.Map <ShopOrder> (order); return(Ok(_order)); } return(NotFound()); }
public async Task <APIResult> CTestThird([FromBody] ThirdOrderAPIModels model) { var order = new ShopOrder() { AddTime = DateTime.Now, MemberId = 0, ShopId = model.ShopId, Remark = "达达配送", AddUser = $"member", AddIp = GetIp(), Flag = Guid.NewGuid().ToString(), IsTakeOut = true, Status = ShopOrderStatus.待支付, OrderNumber = model.OrderId //TakeDistributionType = args.TakeDistributionType }; db.Add(order); //处理达达配送 ThirdServer thirdServer = new ThirdServer(db, thirdConfig); var shoptakeoutinfo = db.ShopTakeOutInfo.FirstOrDefault(r => r.ShopId == model.ShopId && !r.IsDel); if (shoptakeoutinfo.TakeDistributionType == TakeDistributionType.达达配送) { var merchant = db.Merchant.FirstOrDefault(r => r.ShopId == model.ShopId); if (merchant == null) { throw new Exception("商户未在达达开户"); } var thirdshop = db.ThirdShop.FirstOrDefault(r => r.ShopId == model.ShopId); if (thirdshop == null) { throw new Exception("商户门店不存在"); } model.thirdShopAddOrderModel.origin_id = model.OrderId; var result = await thirdServer.ThirdAddOrder(model.thirdShopAddOrderModel, null); if (result.errorCode == 0 || result.status == "success") { db.ThirdMoneyReport.Add(new Data.ThirdMoneyReport() { OrderNumber = model.OrderId, Amount = result.result.fee, AddTime = DateTime.Now, ProduceType = Data.ProduceType.发起订单 }); } db.SaveChanges(); return(Success(result)); } return(Error("error")); }
static PrintParameter GetPrintParameter(ShopDbContext db, ShopOrder shopOrder) { PrintParameter parameter = new PrintParameter(); //是否外卖 if (shopOrder.IsTakeOut) { parameter.Title = "外卖单"; var memberAddress = db.Query <MemberAddress>() .Where(m => !m.IsDel && m.IsUsed) .Where(m => m.MemberId == shopOrder.MemberId) .FirstOrDefault(); if (memberAddress == null) { parameter.Address = "用户未填写地址"; var memberPhone = db.Query <MemberPhone>() .Where(m => !m.IsDel) .Where(m => m.State == MemberPhoneState.已绑定) .Where(m => m.MemberId == shopOrder.MemberId) .FirstOrDefault(); parameter.Mobile = memberPhone?.Phone; } else { shopOrder.memberAddressId = memberAddress.Id; parameter.Address = memberAddress.Detail; parameter.Mobile = memberAddress.Phone; parameter.OrderName = memberAddress.Name; } } else { string shoppart; if (shopOrder.ShopPartId == null) { shoppart = "无桌号"; } else { shoppart = db.Query <ShopPart>() .Where(m => m.Id == shopOrder.ShopPartId) .FirstOrDefault() .Title; } parameter.Title = shoppart + "的点餐单"; } parameter.ShopID = shopOrder.ShopId; parameter.TotalMoney = Math.Round(shopOrder.Amount / 100d, 2); parameter.Remark = shopOrder.Remark; parameter.OrderID = shopOrder.Id + ""; return(parameter); }
public string getTotalJiF(ShopOrder model) { if (model == null) { return(string.Empty); } StringBuilder sb = new StringBuilder(); Xml_Shop shopConfig = DB.XmlConfig.XmlShop; //sb.AppendFormat("{0}", model.RealShopping); sb.AppendFormat("积分:{0} ", model.RealScore); return(sb.ToString()); }
/// <summary> /// 退款到余额 /// </summary> /// <param name="amount"></param> public void RefundToBalance(ShopOrder shopOrder) { mShopMember.Balance += shopOrder.Payment.Value; ShopMemberRufund shopMemberRufund = new ShopMemberRufund() { Amount = shopOrder.Payment.Value, ShopMemberId = mShopMember.Id, ShopOrderId = shopOrder.Id, TransactionTime = DateTime.Now }; shopDb.Add(shopMemberRufund); }
/// <summary> /// 确认订单页面 /// </summary> /// <returns></returns> public ActionResult payment(string orderid) { LogHelper.Error("回调311111111111111111111111"); #region 如果页面无参数传入,微信会把Payment作为一个目录处理,这里增加个判断,如果无参数,则随便加个参数 if (Request.QueryString.Count == 0) { return(RedirectToAction("/mobile/mobilecenter/bill", new { q = "t", orderid = orderid })); } #endregion List <string> orderList = new List <string>(); if (string.IsNullOrEmpty(orderid)) { //throw new Exception("获取订单id失败"); //来自购物车 string cartlist = CookieHelper.GetCookieValue("cart"); if (string.IsNullOrEmpty(cartlist)) { return(RedirectToAction("Bill")); } //获取下单总金额 cartlist = SecurityHelper.UrlDecode(cartlist); Dictionary <int, int> prodList = cartlist.JsonDeserializer <Dictionary <int, int> >(); //生成订单 Member_Info curUser = User_Shop.GetMember_Info(); DB.ShopOrder.GenerateOrder(curUser, 0, null); //3.清空cookie CookieHelper.ClearCookie("cart"); CookieHelper.ClearCookie("total"); return(RedirectToAction("Bill"));//跳转待付款 } orderList.Add(orderid); ShopOrder model = DB.ShopOrder.FindEntity(orderid); if (model == null) { throw new Exception("获取订单信息失败"); } if (model.TraceNo.IsNull()) { model.TraceNo = model.GUID; DB.ShopOrder.Update(model); } CookieHelper.SetCookie("traceno", model.TraceNo, 1); CookieHelper.SetCookie("orderlist", orderList.ToJsonString(), null); return(View(model)); }
//========================================================== //========================================================== // GET: Order public ActionResult Index() { string currentUserId = HttpContext.User.Identity.GetUserId(); ApplicationUserManager userManager = new ApplicationUserManager(new UserStore <ApplicationUser>(db)); ApplicationUser currentUser = userManager.FindById(currentUserId); if (!currentUser.EmailConfirmed) { return(RedirectToAction("Index", "Profile")); } ShoppingCart cart = db.ShoppingCarts .Include(c => c.ShoppingCartsProducts) .Where(c => c.UserId == currentUser.Id).SingleOrDefault(); if (cart != null && cart.ShoppingCartsProducts != null && cart.ShoppingCartsProducts.Count > 0) { ShopOrder order = new ShopOrder { DateCreate = DateTime.Now, ApplicationUser = currentUser }; foreach (ShoppingCartsProduct cartProduct in cart.ShoppingCartsProducts) { ShopOrderProduct orderProduct = new ShopOrderProduct { Quantity = cartProduct.Quantity, ShopProduct = cartProduct.ShopProduct }; ShopProductsPrice price = db.ShopProductsPrices.Where(p => p.ShopProduct.Id == cartProduct.ShopProduct.Id && p.CurrentPrice).SingleOrDefault(); //cartProduct.ShopProduct.ShopProductsPrices.Where(p => p.CurrentPrice).SingleOrDefault(); if (price != null) { orderProduct.Price = price.Price; } order.ShopOrderProducts.Add(orderProduct); } db.ShopOrders.Add(order); db.ShoppingCartsProducts.RemoveRange(cart.ShoppingCartsProducts); db.SaveChanges(); return(View("Index")); } return(View("Error")); }
public APIResult ToAmount([FromBody] ToAmountArgsModel args) { ShopOrder shopOrder = db.Set <ShopOrder>().Find(args.id); if (shopOrder == null) { throw new Exception("订单不存在"); } CheckShopActor(shopOrder.ShopId, ShopActorType.超级管理员); shopOrder.Status = ShopOrderStatus.已退款; DecreaseCommodity(shopOrder); RefundToAmonut(shopOrder); db.SaveChanges(); return(Success()); }
/// <summary> /// 在后台任务中完成订单 /// </summary> /// <param name="shopOrderId"></param> public static void SetShopOrderFinish(int shopOrderId) { using (ShopDbContext shopDb = DbContextFactory.ShopDb) { using (var printDbContext = DbContextFactory.PrintDb) { ILogger logger = ServiceLocator.Instance.GetService <ILoggerFactory>().CreateLogger <ShopOrderUtil>(); ShopOrder shopOrder = shopDb.GetSingle <ShopOrder>(shopOrderId); ThirdConfig thirdConfig = ServiceLocator.Instance.GetService <IOptions <ThirdConfig> >().Value; WechatTemplateSendOptions wechatTemplateSend = ServiceLocator.Instance.GetService <IOptions <WechatTemplateSendOptions> >().Value; shopOrder.PayWay = "会员余额支付"; shopOrder.SetShopOrderFinish(printDbContext, shopDb, wechatTemplateSend, thirdConfig, logger); } } }
public ShopOrder AddOrder(long customerId, DateTime orderDate, string street, string city, string postalCode, string country) { ShopOrder order = new ShopOrder(); order.CustomerId = customerId; order.OrderDate = orderDate; order.Street = street; order.City = city; order.PostalCode = postalCode; order.Country = country; context.ShopOrder.Add(order); context.SaveChanges(); return(order); }
public void UpdateShOrder(ShopOrderDTO shopOrderDTO) { ShopOrder shopOrder = Database.ShopOrders.Get(shopOrderDTO.ShopOrderId); if (shopOrder == null) { throw new ValidationException("Заказ магазина не найден", ""); } // shopOrder.ProductId = shopOrderDTO.ProductId; shopOrder.ProductQuantity = shopOrderDTO.ProductQuantity; shopOrder.ShopAddress = shopOrderDTO.ShopAddress; shopOrder.ShExpDate = shopOrderDTO.ShExpDate; Database.ShopOrders.Update(shopOrder); Database.Save(); }