예제 #1
0
        public ActionResult GetWayBill(string orderNo, string shipTypeCode)
        {
            SaleOrderBLL saleOrderBLL = new SaleOrderBLL();

            var saleOrder           = saleOrderBLL.GetSaleOrder(orderNo);
            var saleOrderItem       = saleOrderBLL.GetOrderItemList(orderNo).FirstOrDefault();
            var appId               = "1276314";
            var appKey              = "319ee1b5-d572-4eb6-b2b9-228076c48eec";
            var url                 = "http://api.kdniao.cc/api/eorderservice";
            var printServer         = ExpressDockingFactory.GetKdNiaoExpressDocking(url);
            KdNiaoRequestData kdnrd = new KdNiaoRequestData();

            kdnrd.AppKey      = appKey;
            kdnrd.EBusinessID = appId;
            kdnrd.DataType    = "2";
            kdnrd.RequestType = "1007";
            KdNiaoWaybillRequestDataContent kdnrdc = new KdNiaoWaybillRequestDataContent();

            kdnrdc.Receiver = new KdNiaoAddress()
            {
                ProvinceName = saleOrder.Province,
                CityName     = saleOrder.City,
                ExpAreaName  = saleOrder.County,
                Address      = saleOrder.ReceiveAddress,
                Name         = saleOrder.ReceiveContact,
                Mobile       = saleOrder.ReceiveCellPhone,
                PostCode     = saleOrder.ReceiveZip
            };
            var sendInfo        = new WarehouseBLL().GetWarehouse(saleOrder.WarehouseId);
            var provinceCityBll = new BaseProvinceCityBll();

            kdnrdc.Sender = new KdNiaoAddress()
            {
                ProvinceName = provinceCityBll.GetNameByCode(sendInfo.ProvinceId),
                CityName     = provinceCityBll.GetNameByCode(sendInfo.CityId),
                ExpAreaName  = provinceCityBll.GetNameByCode(sendInfo.CountyId),
                Address      = sendInfo.Address,
                Name         = sendInfo.Contact,
                Mobile       = sendInfo.Phone,
                PostCode     = sendInfo.PostalCode
            };

            kdnrdc.Commodity = new List <KdNiaoCommodity>()
            {
                new KdNiaoCommodity()
                {
                    GoodsName     = saleOrderItem.ProductName,
                    GoodsWeight   = saleOrderItem.Weight.ToString(),
                    Goodsquantity = saleOrderItem.QtyScaned.ToString(),
                    GoodsVol      = saleOrderItem.Volume.ToString()
                }
            };
            kdnrdc.ShipperCode           = shipTypeCode;
            kdnrdc.OrderCode             = saleOrder.OrderNo;
            kdnrdc.ExpType               = "1";
            kdnrdc.PayType               = "1";
            kdnrdc.IsNotice              = "1";
            kdnrdc.IsReturnPrintTemplate = "1";
            if (shipTypeCode == "YTO")
            {
                kdnrdc.CustomerName = "k210314881";
                kdnrdc.MonthCode    = "f2ar5n8b";
            }
            kdnrd.RequestData        = kdnrdc.ToJson();
            kdnrd.RequestDataContent = kdnrdc;
            kdnrd.DataSign           = Encrypt.KdNiaoSingEncrypt(kdnrd.RequestData, appKey, "UTF-8");
            var kdnrp = printServer.GetWayBill(kdnrd);

            //if (!kdnrp.Success)
            //{
            //    return Content(kdnrp.ToJson());
            //}
            return(Content(kdnrp.PrintTemplate));
        }