Пример #1
0
        /// <summary>
        /// 拉取订单待发货订单
        /// </summary>
        /// <returns></returns>
        public string List()
        {
            var    result   = new JsonResult();
            string appid    = HttpContext.Current.Request["appid"];
            string sign     = HttpContext.Current.Request["sign"];
            string jsonData = HttpContext.Current.Request["jsonData"];

            //验证秘钥
            bool isPass = Security.SecurityCheck(appid, sign, jsonData);

            if (!isPass)
            {
                result.code    = (int)OrderError.接口秘钥无效;
                result.message = OrderError.接口秘钥无效.ToString();
                result.data    = null;
                return(JsonHelper.GetJson(result));
            }

            //序列化json
            PageForm pageFrom = JsonHelper.ConvertToObj <PageForm>(jsonData);

            string strWhere = string.Empty;

            strWhere += " CreateTime > '" + ConvertDataTimeHelper.ConvertLongDateTime(pageFrom.StartTime).ToString() + "'";
            strWhere += " AND CreateTime < '" + ConvertDataTimeHelper.ConvertLongDateTime(pageFrom.EndTime).ToString() + "'";
            int count = 0;//总条数
            OperationResult <IList <OrdersInfo> > orderInfoList =
                OrderLogisticsSqlBLL.Instance.Orders_GetList(pageFrom.Page, pageFrom.Size, " CreateTime DESC ", strWhere, 0, out count);

            OperationResult <IList <OrderProductInfo> > orderProductInfoList =
                OrderLogisticsSqlBLL.Instance.OrderProduct_GetList(strWhere);
            //数据组合
            IList <OrdersResponse> response = new List <OrdersResponse>();

            foreach (var o in orderInfoList.AppendData)
            {
                OrdersResponse or = new OrdersResponse();
                or.OrderID      = o.OrderID;
                or.PaySum       = o.PaySum;
                or.ProductFee   = o.ProductFee;
                or.NewShipFee   = o.NewShipFee;
                or.VoucherFee   = o.VoucherFee;
                or.ShipMethodID = o.ShipMethodID;
                or.Province     = o.Province;
                or.City         = o.City;
                or.County       = o.County;
                or.Address      = o.Address;
                or.Receiver     = o.Receiver;
                or.Telephone    = o.Telephone;
                or.Mobile       = o.Mobile;
                or.Invoice      = o.Invoice;
                or.Remarks      = o.Remarks;
                or.CreateTime   = ConvertDataTimeHelper.ConvertDataTimeLong(o.CreateTime);
                or.OrderDetails = new List <OrderProductInfo>();
                foreach (var op in orderProductInfoList.AppendData)
                {
                    if (o.OrderID == op.OrderID)
                    {
                        OrderProductInfo opInfo = new OrderProductInfo();
                        opInfo.OrderID        = op.OrderID;
                        opInfo.ProductCode    = op.ProductCode;
                        opInfo.ProductID      = op.ProductID;
                        opInfo.ProductName    = op.ProductName;
                        opInfo.ProfeeDiscount = op.ProfeeDiscount;
                        opInfo.Quantity       = opInfo.Quantity;
                        or.OrderDetails.Add(opInfo);
                    }
                }
                response.Add(or);
            }
            //返回结果
            if (orderInfoList.ResultType != OperationResultType.Success)
            {
                result.message = orderInfoList.Message;
                result.code    = (int)OrderError.数据连接失败;
                result.data    = null;
            }
            else
            {
                result.message = OrderError.数据返回成功.ToString();
                result.code    = (int)OrderError.数据返回成功;
                result.data    = JsonHelper.GetJson(response);
            }
            return(JsonHelper.GetJson(result));
        }
Пример #2
0
        /// <summary>
        /// 金象隐形眼镜 自动设置订单已发货
        /// </summary>
        /// <returns></returns>
        public string  Shipping_Status()
        {
            var    result   = new JsonResult();
            string appid    = HttpContext.Current.Request["appid"];
            string sign     = HttpContext.Current.Request["sign"];
            string jsonData = HttpContext.Current.Request["jsonData"];

            //验证秘钥
            bool isPass = Security.SecurityCheck(appid, sign, jsonData);

            if (!isPass)
            {
                result.code    = (int)OrderError.接口秘钥无效;
                result.message = OrderError.接口秘钥无效.ToString();
                result.data    = null;
                return(JsonHelper.GetJson(result));
            }

            //数据更新异常结果集
            IList <string> errorOrderIDList = new List <string>();

            //序列化json
            IList <ShippingInfo> spInfoList = JsonHelper.ConvertToObj <IList <ShippingInfo> >(jsonData);

            for (int i = 0; i < spInfoList.Count; i++)
            {
                //更新数据
                DateTime           createTime = ConvertDataTimeHelper.ConvertLongDateTime(spInfoList[i].Shipped_Time);
                OrderLogisticsInfo olInfo     = new OrderLogisticsInfo()
                {
                    OrderID          = spInfoList[i].OrderID,
                    ExpressID        = Convert.ToInt32(spInfoList[i].Express_Id),
                    LogisticsCompany = spInfoList[i].Express_Name,
                    LogisticsNum     = spInfoList[i].Express_Sn,
                    UID        = 0,
                    Creator    = spInfoList[i].Sender,
                    CreateTime = createTime
                };
                OperationResult <int> olResult = OrderLogisticsSqlBLL.Instance.OrderLogistics_Insert(olInfo);
                if (olResult.AppendData > 0)
                {
                    int        logisticsID = olResult.AppendData;
                    OrdersInfo oInfo       = new OrdersInfo()
                    {
                        OrderID = spInfoList[i].OrderID,
                    };
                    olResult = OrderLogisticsSqlBLL.Instance.Order_Update(oInfo, "可得");
                    if (olResult.ResultType != OperationResultType.Success)
                    {
                        //没有更新成功 取消插入
                        OrderLogisticsSqlBLL.Instance.OrderLogistics_Delete(logisticsID);
                        errorOrderIDList.Add(spInfoList[i].OrderID);
                        continue;
                    }
                }
                else
                {
                    errorOrderIDList.Add(spInfoList[i].OrderID);
                    continue;
                }
            }
            if (errorOrderIDList.Count() > 0)
            {
                result.data    = JsonHelper.GetJson(errorOrderIDList);
                result.code    = (int)OrderError.未知的订单号;
                result.message = OrderError.未知的订单号.ToString();
            }
            else
            {
                result.code    = (int)OrderError.数据返回成功;
                result.message = OrderError.数据返回成功.ToString();
                result.data    = null;
            }

            return(JsonHelper.GetJson(result));
        }