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 CResult SetAllShelves(IList <GoodsShelvesParamsDto> goodsShelvesParamsDtos)
        {
            /*1、插入上架表*/
            var insertFormatSql = @" INSERT INTO shangjia_sku_info
                            ( sku ,
                              Description ,
                              Price ,
                              ShangPinId ,
                              IsShangJia,
                              FenLeiId
                            ) 
                            values('{0}','{1}','{2}','{3}','{4}','{5}')";
            var listStr         = new List <string>();

            foreach (var item in goodsShelvesParamsDtos)
            {
                listStr.Add(string.Format(" delete from shangjia_sku_info where sku='{0}'", item.sku));
                //mendianId-fenleiId-shangpinid-yanse-chima
                var arrIds = item.sku.Split('-');
                listStr.Add(string.Format(insertFormatSql, item.sku, item.desc, item.price, arrIds[2], 1, arrIds[1]));
            }
            var db = Common.DbFactory.CreateDbSession();

            db.Context.ExcuteNoQuery(listStr);
            return(FunResult.GetSuccess());
        }
Exemplo n.º 3
0
        public CResult SetDownShelves(string skus)
        {
            var sqlFormat = "update shangjia_sku_info set IsShangJia=0 where  sku in('{0}')";
            var db        = Common.DbFactory.CreateDbSession();

            db.Context.ExcuteNoQuery(string.Format(sqlFormat, skus.Replace(",", "','")));
            return(FunResult.GetSuccess());
        }
Exemplo n.º 4
0
        public CResult SetDeliver(ExpressDto expressDto)
        {
            var sql       = string.Format(@"update `order` set ExpressCompany='{0}',
            Expresser='{1}',ExpressPhone='{2}',ExpressNum='{3}',ExpressDateTime='{4}',Status='{5}'
            where Id='{6}'", expressDto.ExpressCompany, "", "", expressDto.ExpressNo, DateTime.Now, (int)OrderStatusEnum.DeliverGoods, expressDto.OrderId);
            var dbSession = Common.DbFactory.CreateDbSession();

            dbSession.Context.ExcuteNoQuery(sql);
            return(FunResult.GetSuccess());
        }
Exemplo n.º 5
0
        public CResult PublishGoods(string goodsSKU, string newPath)
        {
            string     pathTemplate = this.opGoods.GetGoodsCurTemplate("1231");//模块以后根据不同商品改变 现在就一个
            Document   document     = GetVTDocument(goodsSKU, pathTemplate);
            TextWriter textWriter   = new StringWriter();

            document.Render(textWriter);
            //把生成的静态内容写入到目标文件
            string html = textWriter.ToString();

            File.WriteAllText(newPath + string.Format(@"\{0}.html", goodsSKU), html, Encoding.UTF8);
            return(FunResult.GetSuccess());
        }
Exemplo n.º 6
0
        public CResult PublishCatalog3Template()
        {
            string pathTemplate        = iOPGoodsCatalog.GetGoodsCatalogTemplate("TCatelog2.htm");
            var    listShangePinFeiLei = iOPGoodsCatalog.GetGoodsCataLog(new List <int>()
            {
                2, 3
            });
            var list2ShangePinFeiLei = listShangePinFeiLei.Where(e => e.Level == 2).ToList();

            foreach (var item in list2ShangePinFeiLei)
            {
                var        list3ShangePinFeiLei = listShangePinFeiLei.Where(e => e.PBianMa == item.BianMa && e.Level == 3).ToList();
                Document   document             = GetVTDocument(pathTemplate, list3ShangePinFeiLei);
                TextWriter textWriter           = new StringWriter();
                document.Render(textWriter);
                //把生成的静态内容写入到目标文件
                string html    = textWriter.ToString();
                var    newPath = Toolkit.Path.PathConfig.GetGeneratePath("Template");
                File.WriteAllText(newPath + @"\" + item.BianMa + ".html", html, Encoding.UTF8);
            }

            return(FunResult.GetSuccess());
        }
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);
        }
Exemplo n.º 8
0
 public CResult PutawayGoods(string sku)
 {
     return(FunResult.GetSuccess());
 }