예제 #1
0
        public override PopOrderState GetOrderState(Domain.Shop shop, string popOrderId)
        {
            var orderState = this.GetOrderStatePingduoduo(shop, popOrderId);
            var os         = ConvertToOrderState(popOrderId, orderState);

            var popOrderState = new PopOrderState
            {
                PopOrderId         = popOrderId,
                PopOrderStateValue = orderState.order_status,
                State = os,
            };

            return(popOrderState);
        }
예제 #2
0
        private PopOrderState ParseOrderState(Shop shop, string popOrderId)
        {
            var pos = new PopOrderState()
            {
                PopOrderId         = popOrderId,
                PopOrderStateValue = "",
                State = OrderState.NONE
            };

            //订单信息
            var js   = ScriptManager.GetBody(jspath, "//TAOBAO_GET_ORDER").Replace("###bizOrderId", popOrderId);
            var task = wb1.GetBrowser().MainFrame.EvaluateScriptAsync(js, "", 1, new TimeSpan(0, 0, 30));
            var ret  = task.Result;

            if (ret.Success == false || (ret.Result != null && ret.Result.ToString().StartsWith("ERROR")))
            {
                throw new Exception("执行操作失败:" + ret.Message);
            }
            var    content = ret.Result.ToString();
            string title   = shop.PopType == PopType.TMALL ? "var detailData" : "var data = JSON";

            int si = content.IndexOf(title);

            if (si <= 0)
            {
                throw new Exception("未找到订单详情数据开始标识" + title);
            }
            si = content.IndexOf('{', si);
            if (si <= 0)
            {
                throw new Exception("未找到订单详情数据开始标识" + title);
            }
            int ei = content.IndexOf("</script>", si);

            if (ei <= si)
            {
                throw new Exception("未找到详情结尾数据");
            }
            while (ei >= 0 && content[ei] != '}')
            {
                ei--;
            }
            if (ei <= si)
            {
                throw new Exception("未找到详情结尾数据");
            }
            String orderInfo = content.Substring(si, ei - si + 1).Trim();

            if (shop.PopType == PopType.TMALL)
            {
                var oi = Newtonsoft.Json.JsonConvert.DeserializeObject <TmallQueryOrderDetailResponse>(orderInfo);
                pos.PopOrderStateValue = oi.overStatus.status.content[0].text;
            }
            else
            {
                orderInfo = Regex.Unescape(orderInfo);
                var oi = Newtonsoft.Json.JsonConvert.DeserializeObject <TaobaoQueryOrderDetailResponse>(orderInfo);
                pos.PopOrderStateValue = oi.mainOrder.statusInfo.text;
            }
            pos.State = ConveretState(pos.PopOrderStateValue);

            return(pos);
        }