Exemplo n.º 1
0
        public CResult VerifyEntity(CustomerOrder customerOrder)
        {
            var msg = "";

            if (customerOrder.DeliveryType == 2 && customerOrder.AddressId == 0)
            {
                msg = "收货人地址为空不能提交订单!";
            }
            else if (string.IsNullOrEmpty(customerOrder.CustomerId))
            {
                msg = "请重新登录!";
            }
            else if (customerOrder.PayType == 0)
            {
                msg = "请选择付款方式!";
            }
            else if (customerOrder.InvoiceTitleType == 2)
            {
                if (string.IsNullOrEmpty(customerOrder.InvoiceCompany))
                {
                    msg = "请填写发票的抬头";
                }
            }

            return(string.IsNullOrEmpty(msg)?FunResult.GetSuccess(): FunResult.GetError(msg));
        }
Exemplo n.º 2
0
 public JsonResult CreateTemplate()
 {
     try
     {
         var b = iPublish.PublishGoods("sku");
         return(Json(b));
     }
     catch (Exception ex)
     {
         return(Json(FunResult.GetError(ex.Message.ToString())));
     }
 }
Exemplo n.º 3
0
 public JsonResult GenerateCatalogList()
 {
     try
     {
         var b = iPublish.PublishCatalogTemplate();
         return(Json(b, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(FunResult.GetError(ex.Message.ToString()), JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 设置发货完成
        /// </summary>
        /// <returns></returns>
        public JsonResult SetDeliver()
        {
            var data = Request["data"];

            try
            {
                var expressDto = Toolkit.JsonHelp.JsonHelp.josnToObject <ExpressDto>(data);
                var cresult    = idelivergoods.SetDeliver(expressDto);
                return(Json(cresult, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(FunResult.GetError(ex.Message)));
            }
        }
Exemplo n.º 5
0
 public JsonResult SetShelves() 
 {
     try
     {
         var goodsDesc = Request["desc"];
         var sku = Request["sku"];
         var price = Request["price"];
         var mendianId = "1";
         var bShelves = iopshelves.SetUpShelves(new List<string>() { sku }, goodsDesc,price);
         var newPath = Toolkit.Path.PathConfig.GetGeneratePath("Product");
         iPublist.PublishGoods(sku,newPath);
         return Json(bShelves,JsonRequestBehavior.AllowGet);
     }
     catch(Exception ex)
     {
         return Json(FunResult.GetError(ex.Message.ToString()),JsonRequestBehavior.AllowGet);
     }
 }
Exemplo n.º 6
0
 public JsonResult SubmitOrder()
 {
     try
     {
         //绑定订单数据
         var entity = Request.CreateInstance <CustomerOrder>();
         entity.CreateDate = DateTime.Now;
         entity.CustomerId = this.CurrentUserInfo.Id;
         //验证订单信息
         var checkResult = customerOrder.VerifyEntity(entity);
         if (!checkResult.IsSuccess)
         {
             return(Json(checkResult));
         }
         //提交订单
         var result = customerOrder.SubmitOrder(entity);
         return(Json(result));
     }
     catch (Exception ex)
     {
         Log.Logger.Write("ordersubmit:error->" + ex.Message);
         return(Json(FunResult.GetError(ex.Message)));
     }
 }
Exemplo n.º 7
0
        //提交客户订单
        public CResultCode SubmitOrder(CustomerOrder customerOrder)
        {
            //1、调用购物车查询所有这次提交要买的商品
            var products = iOpCat.CartActivedList(customerOrder.CustomerId);

            if (products.Count == 0)
            {
                return(FunResult <CResultCode> .GetError("亲,购物车中没有商品,不能生成订单呦!"));
            }
            //2、获得商品库存状况
            var goodsCount = iOpStore.GetGoodsStore(products.Select(e => e.Sku).ToList());

            //3、检查是否有库存不满足 预留在这里吧
            foreach (var item in goodsCount)
            {
                //还有种情况是随然让你下订单,但是我需要通知商家补货。如不能补货 则取消订单。
                var product = products.FirstOrDefault(e => e.Sku == item.SKU);
                if (product != null)   //商品在库存中不存在 几乎不存在这种情况 前期测试为了严谨
                {
                    if (item.StoreCount < product.Quantity)
                    {
                        //应该不能拆单 直接返回给客服 让客服看是否可以补货  然后产生订单
                    }
                }
            }
            //3.1检查库存不符合的
            //4、自动拆单过程 涉及门店优先级 涉及就近地点 就近仓库

            //5、保存订单
            var listOrderReSql = new List <string>();
            //生成客户订单表
            var orderCustomerId        = Guid.NewGuid().ToString().Replace("-", "");
            var sqlFormatCustomerOrder = @"insert into customerorder (
                    Id,CustomerId,CreateDate,SendDateIndex,
                    PhoneConfirm,AddressId,InvoiceTitleType,
                    InvoiceContentType,InvoiceCompany,PayType,DeliveryType
                ) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}')";
            var sqlCustomerOrder       = string.Format(sqlFormatCustomerOrder,
                                                       orderCustomerId,
                                                       customerOrder.CustomerId,
                                                       customerOrder.CreateDate,
                                                       customerOrder.SendDateIndex,
                                                       customerOrder.PhoneConfirm?1:0,
                                                       customerOrder.AddressId,
                                                       customerOrder.InvoiceTitleType,
                                                       customerOrder.InvoiceContentType,
                                                       customerOrder.InvoiceCompany,
                                                       customerOrder.PayType,
                                                       customerOrder.DeliveryType);

            listOrderReSql.Add(sqlCustomerOrder);

            //生成订单表
            var orderId        = Framework.GetOrderNum();
            var sqlOrderFormat = @"insert into `order`(Id,SubOrder,CustomerOrderId,Status,OrderDate) values ('{0}','{1}','{2}','{3}','{4}')";
            var sqlOrder       = string.Format(sqlOrderFormat, orderId, 0, orderCustomerId, (int)OrderStatusEnum.Generate, customerOrder.CreateDate);

            listOrderReSql.Add(sqlOrder);
            //生成订单商品表
            foreach (var goods in products)
            {
                var sqlOrderGoodsFormat = @"insert into ordergoods(OrderId,Sku,Quantity,Price) value('{0}','{1}','{2}','{3}')";
                var sqlOrderGoods       = string.Format(sqlOrderGoodsFormat, orderId, goods.Sku, goods.Quantity, goods.Price);
                listOrderReSql.Add(sqlOrderGoods);
            }
            //删除购物车
            var deleteCatSql = iOpCat.GetDeleteActivedSql(customerOrder.CustomerId);

            listOrderReSql.Add(deleteCatSql);
            var dbSession = Common.DbFactory.CreateDbSession();

            dbSession.Context.ExcuteNoQuery(listOrderReSql);
            var result = FunResult <CResultCode> .GetSuccess();

            result.Code = orderId;
            return(result);
        }