Example #1
0
        public HttpResponseMessage ImportOrder([FromBody] OrderInfoListClient orderInfoListClient)
        {
            InsertLog.Insert("订单导入数据获得的订单数据", orderInfoListClient.xmOrderInfoClientList.Count.ToString());
            _utilManager.Write(JsonConvert.SerializeObject(orderInfoListClient));
            var apiMessage = new ApiMassage();

            apiMessage.Header = new Header();
            var str = string.Empty;

            if (orderInfoListClient.xmOrderInfoClientList.Count == 0)
            {
                apiMessage.Header.IsSuccess = false;
                apiMessage.Header.Message   = "请求的参数为空";
                str = JsonConvert.SerializeObject(apiMessage);
                return(_utilManager.HttpMessage(str));
            }
            var nostatus = new List <string>()
            {
                "待付款", "待使用", "已完成", "已发货"
            };
            var clientOrderList = orderInfoListClient.xmOrderInfoClientList.Where(m => !nostatus.Contains(m.OrderStatus)).ToList();

            if (clientOrderList.Count > 500 || clientOrderList.Count == 0)
            {
                apiMessage.Header.IsSuccess = false;
                apiMessage.Header.Message   = "传入的订单条数不能超过500!或者少于0";
                str = JsonConvert.SerializeObject(apiMessage);
                return(_utilManager.HttpMessage(str));
            }
            _orderInsertManager.InsertXMOrderInfo(clientOrderList, apiMessage.Header);
            if (string.IsNullOrWhiteSpace(apiMessage.Header.Message))
            {
                apiMessage.Header.IsSuccess = true;
                apiMessage.Header.Message   = "接口接收订单数量:" + clientOrderList.Count.ToString() + "处理成功!";
            }
            else
            {
                apiMessage.Header.IsSuccess = false;
            }
            //apiMessage.Header.Message += errorStr;
            str = JsonConvert.SerializeObject(apiMessage);
            InsertLog.Insert("订单导入数据返回值", str);
            return(_utilManager.HttpMessage(str));
            //return JsonConvert.SerializeObject(apiMessage);
        }