コード例 #1
0
        public ActionResult AddReview(int commodityId, string orderNo)
        {
            if (Request.Cookies[SessionKeys.USERID] == null || Request.Cookies[SessionKeys.USERID].Value.ToString() == "")
            {
                return(RedirectToAction("Index", "login"));
                //return Json(new ResultMessage() { Code = -2, Msg = "/login/Index" });
            }
            var strId  = Request.Cookies[SessionKeys.USERID].Value.ToString();
            int userId = 0;

            int.TryParse(strId, out userId);
            var model = CommodityService.GetById(commodityId);

            ViewData["orderNo"] = orderNo;
            return(View(model));
        }
コード例 #2
0
        public ActionResult Get(Guid commodityId)
        {
            try
            {
                var commodity = _commodityService.GetById(commodityId);

                return(Ok(Response.WriteAsync(JsonConvert.SerializeObject(commodity,
                                                                          new JsonSerializerSettings {
                    Formatting = Formatting.Indented
                }))));
            }
            catch (Exception ex)
            {
                return(BadRequest(Response.WriteAsync(JsonConvert.SerializeObject(ex.Message,
                                                                                  new JsonSerializerSettings
                {
                    Formatting = Formatting.Indented
                }))));
            }
        }
コード例 #3
0
        public void OnOrderCancelTimer(object source, System.Timers.ElapsedEventArgs e)
        {
            string sql  = "select * from fz_Orders where orderState=1 and DATEDIFF(mi,submitTime,GETDATE())>30";
            var    list = new QueryObject <Order>(_databaseInstance, sql, null).ToList();

            if (list != null && list.Count() > 0)
            {
                foreach (var item in list)
                {
                    var tran = _databaseInstance.BeginTransaction();
                    try
                    {
                        var order = IOrderService.GetById(item.orderId);
                        if (order.orderState == OrderStates.awaitPay)
                        {
                            if (order.orderType == OrderType.normal)
                            {
                                var details = IOrderDetailService.GetAllByOrderNo(order.orderNo).ToList();
                                if (details != null && details.Count() > 0)
                                {
                                    foreach (var detail in details)
                                    {
                                        var commodit = ICommodityService.GetById(detail.commodityId);
                                        if (commodit != null)
                                        {
                                            commodit.commodityInventory += detail.quantity;
                                            commodit.sellQuantity       -= detail.quantity;
                                            commodit.sellQuantity1      -= detail.quantity;
                                            ICommodityService.Update(commodit);
                                        }
                                    }
                                }
                            }
                            else if (order.orderType == OrderType.secondKill)
                            {
                                var details = IOrderDetailService.GetAllByOrderNo(order.orderNo).ToList();
                                if (details != null && details.Count() > 0)
                                {
                                    foreach (var detail in details)
                                    {
                                        var secondKillCommodity = ISecondKillCommoditysService.GetBycommodityId(detail.commodityId);
                                        if (secondKillCommodity != null)
                                        {
                                            secondKillCommodity.payNum     -= detail.quantity;
                                            secondKillCommodity.surplusNum += detail.quantity;
                                            ISecondKillCommoditysService.Update(secondKillCommodity);
                                        }
                                    }
                                }
                            }
                            order.orderState   = OrderStates.cancel;
                            order.completeTime = DateTime.Now;
                            IOrderService.Update(order);
                            tran.Commit();
                        }
                    }
                    catch (Exception ex)
                    {
                        tran.Rollback();
                        log.Debug(string.Format("取消订单出错:{0}!", ex.Message));
                    }
                    finally
                    {
                        tran.Dispose();
                    }
                }
            }
        }
コード例 #4
0
        public async Task <IActionResult> GetById(int id)
        {
            var response = await _commodityService.GetById(id);

            return(Ok(response));
        }