Exemple #1
0
        public JsonResult WDTExpressTb()
        {
            int page_no = 0;
            int c       = 0;
            int s       = 0;

            App_Code.GY gy = new App_Code.GY();


            //do
            //{

            dic.Clear();
            //dic.Add("mine", "0");
            dic.Add("sid", "hhs2");
            dic.Add("appkey", "hhs2-ot");
            dic.Add("timestamp", GetTimeStamp());
            //dic.Add("page_no", page_no.ToString());//页号
            var      cmd      = CreateParam(dic, true);
            string   ret      = gy.DoPostnew("http://121.41.177.115/openapi2/logistics.php", cmd, Encoding.UTF8);
            string   ssx      = Regex.Unescape(ret);
            JsonData jsonData = null;

            jsonData = JsonMapper.ToObject(ret);
            string iscode = jsonData["code"].ToString();

            if (iscode != "0")
            {
                return(Json("", JsonRequestBehavior.AllowGet));
            }
            JsonData jsontrades = jsonData["logistics_list"];

            c = jsontrades.Count;



            return(Json(new { State = "Faile" }, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// 获取旺店通
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public JsonResult QuyerOrderBYcode(string code)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();

            if (code == "" || code == null)
            {
                return(Json("", JsonRequestBehavior.AllowGet));
            }
            App_Code.GY gy     = new App_Code.GY();
            string      repeat = "";
            List <T_InterceptLogistics> modelList = db.T_InterceptLogistics.Where(a => a.OrderNumber.Equals(code.Trim()) && a.Del == 0).ToList();

            if (modelList.Count > 0)
            {
                repeat += "物流拦截记录已存在此订单号";
            }
            #region
            ////查询旺店通
            //List<T_Retreat> modelList = db.T_Retreat.Where(a => a.Retreat_OrderNumber.Equals(code.Trim()) && a.Isdelete == "0").ToList();
            //if (modelList.Count > 0)
            //{

            //    repeat += "退货退款记录重复,";
            //}
            ////查是否有返现记录

            //List<T_CashBack> cash = db.T_CashBack.Where(a => a.OrderNum.Equals(code.Trim()) && a.For_Delete == 0 && a.Status != 2).ToList();
            //if (cash.Count > 0)
            //{
            //    repeat += "有返现记录重复,";
            //}
            //List<T_Reissue> Reissue = db.T_Reissue.Where(a => a.OrderCode.Equals(code.Trim()) && a.IsDelete == 0 && a.Status != 2).ToList();
            //if (Reissue.Count > 0)
            //{
            //    repeat += "有补发记录重复,";
            //}
            //List<T_ExchangeCenter> ExchangeCenter = db.T_ExchangeCenter.Where(a => a.OrderCode.Equals(code.Trim()) && a.IsDelete == 0 && a.Status != 2).ToList();
            //if (ExchangeCenter.Count > 0)
            //{
            //    repeat += "有换货记录重复,";
            //}
            //List<T_Intercept> Intercept = db.T_Intercept.Where(a => a.OrderNumber.Equals(code.Trim()) && a.IsDelete == 0 && a.Status != 2).ToList();
            //if (Intercept.Count > 0)
            //{
            //    repeat += "拦截模块有记录,";
            //}
            #endregion

            dic.Clear();
            dic.Add("src_tid", code);
            //dic.Add("trade_no", code);
            dic.Add("sid", "hhs2");
            dic.Add("appkey", "hhs2-ot");
            dic.Add("timestamp", GetTimeStamp());
            string   cmd      = CreateParam(dic, true);
            string   ret      = gy.DoPostnew("http://api.wangdian.cn/openapi2/trade_query.php", cmd, Encoding.UTF8);
            string   ssx      = Regex.Unescape(ret);
            JsonData jsonData = null;
            jsonData = JsonMapper.ToObject(ret);
            string iscode = jsonData["total_count"].ToString();
            if (iscode != "0")
            {
                JsonData jsontrades = jsonData["trades"];

                if (jsontrades.Count != 0)
                {
                    JsonData trades = jsontrades[0];
                    //店铺名称
                    string shop_name = trades["shop_name"].ToString();
                    //仓库编码
                    string warehouse_no = trades["warehouse_no"].ToString();
                    //原始订单编号
                    string src_tids = trades["src_tids"].ToString();
                    //下单时间
                    string trade_time = trades["trade_time"].ToString();
                    //付款时间
                    string pay_time = trades["pay_time"].ToString();
                    //旺旺号
                    string customer_name = trades["buyer_nick"].ToString();
                    //订单状态
                    string trade_status = trades["trade_status"].ToString();

                    //收件人姓名
                    string receiver_name = trades["receiver_name"].ToString();
                    //省
                    string receiver_province = trades["receiver_province"].ToString();
                    //市
                    string receiver_city = trades["receiver_city"].ToString();
                    //区
                    string receiver_district = trades["receiver_district"].ToString();
                    //详细地址
                    string receiver_address = trades["receiver_address"].ToString();
                    //电话号码
                    string receiver_mobile = trades["receiver_mobile"].ToString();
                    //邮政编码
                    string receiver_zip = trades["receiver_zip"].ToString();
                    //省市县
                    string receiver_area = trades["receiver_area"].ToString();
                    //快递公司编号
                    string logistics_code = trades["logistics_code"].ToString();
                    //快递公司名称
                    string logistics_name = trades["logistics_name"].ToString();
                    //快递单号
                    string logistics_no = trades["logistics_no"].ToString();
                    //买家留言
                    string buyer_message = trades["buyer_message"].ToString();
                    //客服备注
                    string cs_remark = trades["cs_remark"].ToString();
                    //实付金额
                    // string paid = trades["paid"].ToString();
                    //商品详情
                    List <T_RetreatDetails> DetailsList = new List <T_RetreatDetails>();
                    double paid = 0.00;
                    for (int c = 0; c < jsontrades.Count; c++)
                    {
                        paid += double.Parse(jsontrades[c]["paid"].ToString());
                        //JsonData goods_list = jsontrades[c]["goods_list"];
                        //for (int i = 0; i < goods_list.Count; i++)
                        //{
                        //    T_RetreatDetails DetailsModel = new T_RetreatDetails();
                        //    string ss = goods_list[i]["goods_no"] == null ? "" : goods_list[i]["goods_no"].ToString();
                        //    DetailsModel.item_code = ss;
                        //    DetailsModel.item_name = goods_list[i]["goods_name"] == null ? "" : goods_list[i]["goods_name"].ToString();
                        //    //   double ssds=double.Parse(goods_list[i]["paid"].ToString()) / double.Parse(goods_list[i]["actual_num"].ToString());

                        //    decimal dec = Convert.ToDecimal(Math.Round(double.Parse(goods_list[i]["share_amount"].ToString()), 2));
                        //    DetailsModel.amount = (double)dec;//分摊邮费


                        //    int qyt = Convert.ToInt32(Convert.ToDecimal(goods_list[i]["actual_num"].ToString()));
                        //    if (qyt != 0)
                        //    {
                        //        DetailsModel.qty = qyt;
                        //        DetailsModel.price = (double)dec / DetailsModel.qty;
                        //    }
                        //    else
                        //    {
                        //        DetailsModel.qty = 0;
                        //        DetailsModel.price = (double)dec;
                        //    }
                        //    if (qyt > 0)
                        //    {
                        //        DetailsList.Add(DetailsModel);
                        //    }

                        //}
                    }
                    T_InterceptLogistics model = new T_InterceptLogistics();
                    model.OrderNumber   = code;
                    model.ExpressName   = logistics_name;
                    model.ExpressNumber = logistics_no;
                    model.OrderMoney    = Convert.ToDecimal(paid);


                    //var json = new
                    //{

                    //    rows = (from r in DetailsList
                    //            select new T_RetreatDetails
                    //            {
                    //                item_code = r.item_code,
                    //                item_name = r.item_name,
                    //                price = r.price,
                    //                amount = r.amount,
                    //                qty = r.qty,
                    //                Simplename = r.Simplename,
                    //            }).ToArray()
                    //};
                    return(Json(new { ModelList = model, Repeat = repeat }, JsonRequestBehavior.AllowGet));
                }
            }
            return(Json("-1", JsonRequestBehavior.AllowGet));
        }
Exemple #3
0
        public JsonResult QuyerRetreatDetailBYcode(string code = "")
        {
            string [] codes = code.Split(',');
            List <T_ElectronicInvoice>        ElectronicModel = new List <T_ElectronicInvoice>();
            List <T_ElectronicInvoiceDetails> DetailsList     = new List <T_ElectronicInvoiceDetails>();

            for (int x = 0; x < codes.Length; x++)
            {
                string      codez  = codes[x];
                App_Code.GY gy     = new App_Code.GY();
                string      cmd    = "";
                string      repeat = "";


                dic.Clear();

                dic.Add("src_tid", codez);
                //dic.Add("trade_no", code);

                dic.Add("sid", "hhs2");
                dic.Add("appkey", "hhs2-ot");
                dic.Add("timestamp", GetTimeStamp());
                cmd = CreateParam(dic, true);

                string   ret      = gy.DoPostnew("http://api.wangdian.cn/openapi2/trade_query.php", cmd, Encoding.UTF8);
                string   ssx      = Regex.Unescape(ret);
                JsonData jsonData = null;
                jsonData = JsonMapper.ToObject(ret);
                string iscode = jsonData["total_count"].ToString();
                if (iscode != "0")
                {
                    JsonData jsontrades = jsonData["trades"];

                    if (jsontrades.Count != 0)
                    {
                        JsonData trades = jsontrades[0];
                        //店铺名称
                        string shop_name = trades["shop_name"].ToString();
                        //仓库编码
                        string warehouse_no = trades["warehouse_no"].ToString();
                        //原始订单编号
                        string src_tids = trades["src_tids"].ToString();
                        //下单时间
                        string trade_time = trades["trade_time"].ToString();
                        //付款时间
                        string pay_time = trades["pay_time"].ToString();
                        //旺旺号
                        string customer_name = trades["buyer_nick"].ToString();
                        //收件人姓名
                        string receiver_name = trades["receiver_name"].ToString();
                        //省
                        string receiver_province = trades["receiver_province"].ToString();
                        //市
                        string receiver_city = trades["receiver_city"].ToString();
                        //区
                        string receiver_district = trades["receiver_district"].ToString();
                        //详细地址
                        string receiver_address = trades["receiver_address"].ToString();
                        //电话号码
                        string receiver_mobile = trades["receiver_mobile"].ToString();
                        //邮政编码
                        string receiver_zip = trades["receiver_zip"].ToString();
                        //省市县
                        string receiver_area = trades["receiver_area"].ToString();
                        //快递公司编号
                        string logistics_code = trades["logistics_code"].ToString();
                        //快递单号
                        string logistics_no = trades["logistics_no"].ToString();
                        //买家留言
                        string buyer_message = trades["buyer_message"].ToString();
                        //客服备注
                        string cs_remark = trades["cs_remark"].ToString();
                        //实付金额
                        string paid = trades["paid"].ToString();
                        //商品详情
                        JsonData goods_list = trades["goods_list"];
                        //查询3次。对应到具体的省市区


                        //查询一次..
                        string shop_Code = "";


                        T_ElectronicInvoice model = new T_ElectronicInvoice();
                        model.OrderNumber      = codez;
                        model.ShopName         = shop_name;
                        model.TheInvoiceAmount = decimal.Parse(paid.ToString());
                        ElectronicModel.Add(model);



                        for (int i = 0; i < goods_list.Count; i++)
                        {
                            T_ElectronicInvoiceDetails DetailsModel = new T_ElectronicInvoiceDetails();


                            DetailsModel.Code     = goods_list[i]["goods_no"] == null ? "" : goods_list[i]["goods_no"].ToString();
                            DetailsModel.Name     = goods_list[i]["goods_name"] == null ? "" : goods_list[i]["goods_name"].ToString();
                            DetailsModel.specname = goods_list[i]["spec_name"] == null ? "" : goods_list[i]["spec_name"].ToString();

                            DetailsModel.UnitPrice = decimal.Parse(goods_list[i]["order_price"].ToString());

                            decimal qyt = decimal.Parse(goods_list[i]["actual_num"].ToString());
                            DetailsModel.qty = int.Parse(Math.Round(qyt).ToString());
                            DetailsList.Add(DetailsModel);
                        }
                    }
                }
            }
            var json = new
            {
                rows = (from r in DetailsList
                        select new T_ElectronicInvoiceDetails
                {
                    Code = r.Code,
                    Name = r.Name,
                    specname = r.specname,
                    UnitPrice = r.UnitPrice,
                    qty = r.qty,
                }).ToArray()
            };

            if (ElectronicModel.Count > 0)
            {
                string  ShopName         = ElectronicModel[0].ShopName;
                decimal TheInvoiceAmount = 0.00m;
                for (int d = 0; d < ElectronicModel.Count; d++)
                {
                    if (ShopName != ElectronicModel[d].ShopName)
                    {
                        return(Json("-1", JsonRequestBehavior.AllowGet));
                    }
                    TheInvoiceAmount += decimal.Parse(ElectronicModel[d].TheInvoiceAmount.ToString());
                }
                T_ElectronicInvoice model = new T_ElectronicInvoice();
                model.OrderNumber      = code;
                model.ShopName         = ShopName;
                model.TheInvoiceAmount = TheInvoiceAmount;
                return(Json(new { ModelList = model, Json = json }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("", JsonRequestBehavior.AllowGet));
            }
        }
Exemple #4
0
        public JsonResult ShopTb()
        {
            int page_no = 0;
            int c       = 0;
            int s       = 0;

            App_Code.GY gy = new App_Code.GY();
            //List<T_WDTshop> delMod = db.T_WDTshop.AsQueryable().ToList();
            //foreach (var item in delMod)
            //{
            //    db.T_WDTshop.Remove(item);
            //}
            //db.SaveChanges();
            do
            {
                dic.Clear();
                dic.Add("mine", "0");
                dic.Add("sid", "hhs2");
                dic.Add("appkey", "hhs2-ot");
                dic.Add("timestamp", GetTimeStamp());
                dic.Add("page_no", page_no.ToString());//页号
                var      cmd      = CreateParam(dic, true);
                string   ret      = gy.DoPostnew("http://api.wangdian.cn/openapi2/shop.php", cmd, Encoding.UTF8);
                string   ssx      = Regex.Unescape(ret);
                JsonData jsonData = null;
                jsonData = JsonMapper.ToObject(ret);
                string iscode = jsonData["code"].ToString();
                if (iscode != "0")
                {
                    return(Json("", JsonRequestBehavior.AllowGet));
                }
                JsonData jsontrades = jsonData["shoplist"];
                c = jsontrades.Count;


                for (int i = 0; i < jsontrades.Count; i++)
                {
                    string    shopno = jsontrades[i]["shop_no"].ToString();
                    T_WDTshop model  = db.T_WDTshop.FirstOrDefault(a => a.shop_no == shopno);
                    if (model == null)
                    {
                        T_WDTshop WDTshop = new T_WDTshop();
                        WDTshop.platform_id     = jsontrades[i]["platform_id"].ToString();
                        WDTshop.sub_platform_id = jsontrades[i]["sub_platform_id"].ToString();
                        WDTshop.shop_id         = jsontrades[i]["shop_id"].ToString();
                        WDTshop.shop_no         = jsontrades[i]["shop_no"].ToString();
                        WDTshop.shop_name       = jsontrades[i]["shop_name"].ToString();
                        WDTshop.account_id      = jsontrades[i]["account_id"].ToString();
                        WDTshop.account_nick    = jsontrades[i]["account_nick"].ToString();
                        WDTshop.province        = jsontrades[i]["province"].ToString();
                        WDTshop.city            = jsontrades[i]["city"].ToString();
                        WDTshop.district        = jsontrades[i]["district"].ToString();
                        WDTshop.address         = jsontrades[i]["address"].ToString();
                        WDTshop.contact         = jsontrades[i]["contact"].ToString();
                        WDTshop.zip             = jsontrades[i]["zip"].ToString();
                        WDTshop.mobile          = jsontrades[i]["mobile"].ToString();
                        WDTshop.telno           = jsontrades[i]["telno"].ToString();
                        db.T_WDTshop.Add(WDTshop);
                        s += db.SaveChanges();
                    }
                }
                page_no++;
            } while (c != 0);
            if (s > 0)
            {
                return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { State = "Faile" }, JsonRequestBehavior.AllowGet));
        }