|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Web;
|
|
|
using System.Web.Script.Serialization;
|
|
|
using NetLibrary.Log;
|
|
|
using System.IO;
|
|
|
using TradeModel;
|
|
|
using NetLibrary;
|
|
|
using static TradeManage.GetOrder;
|
|
|
using TradeData;
|
|
|
|
|
|
namespace TradeManageNew.OuterService
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// GetPostFee 的摘要说明
|
|
|
/// </summary>
|
|
|
public class GetPostFee : IHttpHandler
|
|
|
{
|
|
|
|
|
|
public void ProcessRequest(HttpContext context)
|
|
|
{
|
|
|
context.Response.ContentType = "text/plain";
|
|
|
string UserCode = context.Request.QueryString["UserCode"];
|
|
|
string Method = context.Request.QueryString["Method"];
|
|
|
JavaScriptSerializer jsonconvert = new JavaScriptSerializer();
|
|
|
SyncDataModel md = new SyncDataModel();
|
|
|
md.Result = "";
|
|
|
string content2 = "";
|
|
|
if (string.IsNullOrEmpty(UserCode) == true || string.IsNullOrEmpty(Method) == true)
|
|
|
{
|
|
|
md.Code = "101";
|
|
|
md.Result = "缺少参数或者参数不正确,请确保有如下UserCode,Method参数";
|
|
|
content2 = jsonconvert.Serialize(md);
|
|
|
context.Response.Write(content2);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (UserCode != "YYERP@251")
|
|
|
{
|
|
|
md.Code = "102";
|
|
|
md.Result = UserCode+"不正确";
|
|
|
content2 = jsonconvert.Serialize(md);
|
|
|
context.Response.Write(content2);
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
try
|
|
|
{
|
|
|
StreamReader sr = new StreamReader(context.Request.InputStream);
|
|
|
string ResponseContent = sr.ReadToEnd();
|
|
|
ErrorFollow.TraceWrite("协议", "", ResponseContent);
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(ResponseContent) == true)
|
|
|
{
|
|
|
md.Code = "104";
|
|
|
md.Result = "提交数据不能为空";
|
|
|
content2 = jsonconvert.Serialize(md);
|
|
|
context.Response.Write(content2);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
|
|
|
if (Method == "GetFedex")
|
|
|
{
|
|
|
Fedex_GoodsInfo model = jsonconvert.Deserialize<Fedex_GoodsInfo>(ResponseContent);
|
|
|
|
|
|
if (model != null)
|
|
|
{
|
|
|
if (model.Long == null || model.Height == null || model.Width == null || model.Weight == null)
|
|
|
{
|
|
|
md.Code = "105";
|
|
|
md.Result = "货物尺寸和重量不能为空";
|
|
|
content2 = jsonconvert.Serialize(md);
|
|
|
context.Response.Write(content2);
|
|
|
return;
|
|
|
}
|
|
|
string Width = model.Width.Value.ToString();
|
|
|
string Height = model.Height.Value.ToString();
|
|
|
string Long = model.Long.Value.ToString();
|
|
|
string Weight = (model.Weight.Value* 0.035274M).ToString();//克转盎司
|
|
|
int Num = 1;
|
|
|
string RevAddr = "Grace 3806 Glenfield Shadow";
|
|
|
string RevPhone = "9012637906";
|
|
|
string RevCity = "Katy";
|
|
|
string RevProvinceCode = "TX";
|
|
|
string RevPostCode = "77493";
|
|
|
|
|
|
List<Fedex_FeeReuslt> rlist = new List<Fedex_FeeReuslt>();
|
|
|
var obj = new HuoWuData();
|
|
|
int GoodsId = 1;
|
|
|
DataNew.DeletelPostFee(GoodsId);
|
|
|
string str = GoodsFedexFee3(GoodsId, 237, RevAddr, RevPhone, RevCity, RevProvinceCode, RevPostCode, Width, Height, Long, Weight, Num, "SMART_POST");
|
|
|
string str2 = "";
|
|
|
string str3 = "";
|
|
|
string str4 = "";
|
|
|
string str5 = "";
|
|
|
if (str != "")
|
|
|
str2 = GoodsFedexFee3(GoodsId, 237, RevAddr, RevPhone, RevCity, RevProvinceCode, RevPostCode, Width, Height, Long, Weight, Num, "FEDEX_GROUND");
|
|
|
if (str2 != "")
|
|
|
str3 = GoodsFedexFee3(GoodsId, 237, RevAddr, RevPhone, RevCity, RevProvinceCode, RevPostCode, Width, Height, Long, Weight, Num, "GROUND_HOME_DELIVERY");
|
|
|
if (str3 != "")
|
|
|
str4 = GoodsFedexFee3(GoodsId, 228, RevAddr, RevPhone, RevCity, RevProvinceCode, RevPostCode, Width, Height, Long, Weight, Num, "SMART_POST");
|
|
|
if (str4 != "")
|
|
|
str5 = GoodsFedexFee3(GoodsId, 228, RevAddr, RevPhone, RevCity, RevProvinceCode, RevPostCode, Width, Height, Long, Weight, Num, "FEDEX_GROUND");
|
|
|
if (str5 != "")
|
|
|
GoodsFedexFee3(GoodsId, 228, RevAddr, RevPhone, RevCity, RevProvinceCode, RevPostCode, Width, Height, Long, Weight, Num, "GROUND_HOME_DELIVERY");
|
|
|
var fmd = DataNew.GetModelPostFee(GoodsId);
|
|
|
if (fmd != null)
|
|
|
{
|
|
|
Fedex_FeeReuslt frmd = new Fedex_FeeReuslt();
|
|
|
if (fmd.Fee1 != null&& fmd.Fee1>0)
|
|
|
{
|
|
|
frmd = new Fedex_FeeReuslt();
|
|
|
frmd.StoreName = "W仓";
|
|
|
frmd.PostName = "SMART_POST";
|
|
|
frmd.PostFee = fmd.Fee1;
|
|
|
rlist.Add(frmd);
|
|
|
}
|
|
|
if (fmd.Fee2 != null && fmd.Fee2 > 0)
|
|
|
{
|
|
|
frmd = new Fedex_FeeReuslt();
|
|
|
frmd.StoreName = "W仓";
|
|
|
frmd.PostName = "FEDEX_GROUND";
|
|
|
frmd.PostFee = fmd.Fee2;
|
|
|
rlist.Add(frmd);
|
|
|
}
|
|
|
if (fmd.Fee3 != null && fmd.Fee3 > 0)
|
|
|
{
|
|
|
frmd = new Fedex_FeeReuslt();
|
|
|
frmd.StoreName = "W仓";
|
|
|
frmd.PostName = "GROUND_HOME_DELIVERY";
|
|
|
frmd.PostFee = fmd.Fee3;
|
|
|
rlist.Add(frmd);
|
|
|
}
|
|
|
|
|
|
if (fmd.Fee5 != null && fmd.Fee5> 0)
|
|
|
{
|
|
|
frmd = new Fedex_FeeReuslt();
|
|
|
frmd.StoreName = "E仓";
|
|
|
frmd.PostName = "SMART_POST";
|
|
|
frmd.PostFee = fmd.Fee5;
|
|
|
rlist.Add(frmd);
|
|
|
}
|
|
|
if (fmd.Fee6 != null && fmd.Fee6 > 0)
|
|
|
{
|
|
|
frmd = new Fedex_FeeReuslt();
|
|
|
frmd.StoreName = "E仓";
|
|
|
frmd.PostName = "FEDEX_GROUND";
|
|
|
frmd.PostFee = fmd.Fee6;
|
|
|
rlist.Add(frmd);
|
|
|
}
|
|
|
if (fmd.Fee7 != null && fmd.Fee7 > 0)
|
|
|
{
|
|
|
frmd = new Fedex_FeeReuslt();
|
|
|
frmd.StoreName = "E仓";
|
|
|
frmd.PostName = "GROUND_HOME_DELIVERY";
|
|
|
frmd.PostFee = fmd.Fee7;
|
|
|
rlist.Add(frmd);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
md.Code = "100";
|
|
|
md.Result = "Success";
|
|
|
md.Data = jsonconvert.Serialize(rlist);
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//获取用户数据
|
|
|
// var ListUserInfo = BaseService.GetListSyncUserInfo(model.CompanyID);
|
|
|
md.Code = "400";
|
|
|
md.Result = "数据参数不能为空";
|
|
|
md.Data = null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
md.Code = "104";
|
|
|
md.Result = ex.Message;
|
|
|
|
|
|
}
|
|
|
content2 = jsonconvert.Serialize(md);
|
|
|
ErrorFollow.TraceWrite("返回值", "", content2);
|
|
|
context.Response.Write(content2);
|
|
|
}
|
|
|
public string GoodsFedexFee3(int GoodsId, int PostId, string RevAddr, string RevPhone, string RevCity, string RevProvinceCode, string RevPostCode, string Width, string Height, string Long, string Weight, int Num, string PostType)
|
|
|
{
|
|
|
|
|
|
var obj = new HuoWuData();
|
|
|
JC_ExpressService service = new JC_ExpressService();
|
|
|
JC_ExpressPost expressModel = service.GetExpressModel(1, PostId);
|
|
|
TradeManageNew.FedexRateNew2 rate = new TradeManageNew.FedexRateNew2();
|
|
|
TradeManageNew.FedexRateNew2.Key = expressModel.UserCode;
|
|
|
TradeManageNew.FedexRateNew2.Password = expressModel.CheckCode;
|
|
|
TradeManageNew.FedexRateNew2.AccountNumber = expressModel.client_id;
|
|
|
TradeManageNew.FedexRateNew2.MeterNumber = expressModel.client_secret;
|
|
|
TradeManageNew.FedexRateNew2.PayAccountNumber = expressModel.refresh_token;
|
|
|
TradeManageNew.FedexRateNew2.HubId = expressModel.Code;
|
|
|
TradeManageNew.FedexRateNew2.PostId = PostId;
|
|
|
TradeManageNew.FedexFeeMdNew md = new TradeManageNew.FedexFeeMdNew();
|
|
|
TradeManageNew.FedexRateNew2.Addr2 = 1;
|
|
|
md.OrderGoodsId = GoodsId;
|
|
|
md.RevName = "jack";
|
|
|
md.RevPhone = RevPhone;
|
|
|
|
|
|
md.RevAddr = RevAddr;
|
|
|
|
|
|
md.RevCity = RevCity;
|
|
|
|
|
|
md.RevProv = RevProvinceCode;
|
|
|
|
|
|
md.RevPostCode = RevPostCode;
|
|
|
md.RevCountry = "US";
|
|
|
md.OrderId = 0;
|
|
|
JC_PostAddress address = new BaseService().GetAddressModel2(PostId);
|
|
|
md.SendAddr = address.EnglishAddress;
|
|
|
md.SendAddr = address.EnglishAddress;
|
|
|
md.SendCountry = address.countycode;
|
|
|
md.SendCity = address.city;
|
|
|
md.SendProv = address.provincecode;
|
|
|
md.SendPostCode = address.PostCode;
|
|
|
|
|
|
//md.SendAddr = "2611 E LINDSAY PRIVADO";// address.EnglishAddress;
|
|
|
//md.SendCountry = "US";// address.countycode;
|
|
|
//md.SendCity = "ONTARIO";// address.city;
|
|
|
//md.SendProv = "CA";// address.provincecode;
|
|
|
//md.SendPostCode = "91761";// address.PostCode;
|
|
|
|
|
|
//md.SendAddr = "480 W 83rd St";// address.EnglishAddress;
|
|
|
//md.SendCountry = "US";// address.countycode;
|
|
|
//md.SendCity = "Hialeah";// address.city;
|
|
|
//md.SendProv = "FL";// address.provincecode;
|
|
|
//md.SendPostCode = "33166";// address.PostCode;3 1 JIDE TOYS CORP. JIDE TOYS CORP. 2611 E LINDSAY PRIVADO 2611 E LINDSAY PRIVADO 9012637906 91761 CA ONTARIO US 315000 CA ONTARIO US NULL
|
|
|
|
|
|
if (Width != null && Width != "")
|
|
|
{
|
|
|
md.Width = (Math.Ceiling(Convert.ToDecimal(Width) * Num).ToString());
|
|
|
}
|
|
|
if (Height != null && Height != "")
|
|
|
{
|
|
|
md.Height = Math.Ceiling(Convert.ToDecimal(Height) * Num).ToString();
|
|
|
}
|
|
|
if (Long != null && Long != "")
|
|
|
{
|
|
|
md.Lenght = Math.Ceiling(Convert.ToDecimal(Long) * Num).ToString();
|
|
|
}
|
|
|
md.Weight = Convert.ToDecimal(Weight) * 0.0625M * Num;
|
|
|
md.PostType = PostType;// "SMART_POST";
|
|
|
string str = "";
|
|
|
string html = rate.GetFee(md, out str);
|
|
|
if (str != "")
|
|
|
return str;
|
|
|
return html;
|
|
|
|
|
|
}
|
|
|
public class Fedex_GoodsInfo
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
/// 货物商品尺寸 长 (in)英寸
|
|
|
/// </summary>
|
|
|
public decimal? Long { get; set; }
|
|
|
/// <summary>
|
|
|
/// 货物商品尺寸 宽 (in)英寸
|
|
|
/// </summary>
|
|
|
public decimal? Width { get; set; }
|
|
|
/// <summary>
|
|
|
/// 高 (in)英寸
|
|
|
/// </summary>
|
|
|
public decimal? Height { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 重量 (g)克
|
|
|
/// </summary>
|
|
|
public decimal? Weight { get; set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public class Fedex_FeeReuslt
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 仓库 东仓 西仓
|
|
|
/// </summary>
|
|
|
public string StoreName { get; set; }
|
|
|
/// <summary>
|
|
|
/// 渠道名称
|
|
|
/// </summary>
|
|
|
public string PostName { get; set; }
|
|
|
/// <summary>
|
|
|
/// 预估费用
|
|
|
/// </summary>
|
|
|
public decimal? PostFee { get; set; }
|
|
|
|
|
|
|
|
|
}
|
|
|
public bool IsReusable
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} |