Exemplo n.º 1
0
        /// <summary>
        /// 手续费
        /// </summary>
        /// <returns></returns>
        public static double?GetAddFee(int orderFrom, int orderType, double fee)
        {
            string javafee_uri = Config.JavaApiUri + "business/fee/getFee/";
            string memberId    = Config.JavaAnonymousMemberId;
            string memberPwd   = Config.JavaAnonymousMemberPwd;

            var args = new JavaApiReqArgs <dynamic>()
            {
                dataMap = new
                {
                    memberId  = memberId,
                    orderType = orderType.ToString(),
                    //providerCode = "P0004",
                    amount = fee.ToString()
                }
            };

            double?amount = null; //值为null,代表获取手续费失败

            try
            {
                var resp = HttpApiUtils.ReqJavaApiForObj <dynamic, AddFeeDatamap>(args, javafee_uri, memberId, memberPwd, orderFrom);
                amount = resp.dataMap.amount;//手续费可以负数
            }
            catch (Exception ex)
            {
                ETong.Log.Sdk.LoggerMgr.Error("获取手续费失败!", ex);
            }
            var result = amount;

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 跟据模板、运送方式和省份计算最终的运费
        /// </summary>
        public static string GetDefaultTemplate()
        {
            var url       = Config.JavaApiUri + "product/template/freightTemplate/getDefaultTemplate";
            var memberId  = Config.JavaAnonymousMemberId;
            var memberpwd = Config.JavaAnonymousMemberPwd;

            var args = new JavaApiReqArgs <dynamic>()
            {
                dataMap = new
                {
                    memberId = memberId,
                }
            };
            var result = HttpApiUtils.ReqJavaApiForJson <dynamic>(args, url, memberId, memberpwd);

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 查看订单详细
        /// </summary>
        public static JavaApiRespArgs <OrderInfoDatamap> QueryOrdersById(string orderId)
        {
            var url       = Config.JavaApiUri + "orders/queryOrdersById";
            var memberId  = Config.JavaAnonymousMemberId;
            var memberpwd = Config.JavaAnonymousMemberPwd;

            var args = new JavaApiReqArgs <dynamic>()
            {
                dataMap = new
                {
                    memberId = memberId,
                    orderId  = orderId,
                }
            };
            var result = HttpApiUtils.ReqJavaApiForObj <dynamic, OrderInfoDatamap>(args, url, memberId, memberpwd);

            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 跟据店铺信息列表得到每个店铺的运费信息
        /// </summary>
        /// <param name="orderStoreInfo"></param>
        /// <returns></returns>
        public static string CountTemplateOrder(string areaName, dynamic[] storeInfos)
        {
            var url       = Config.JavaApiUri + "product/template/freightTemplate/countAllTemplateTypeCharge";
            var memberId  = Config.JavaAnonymousMemberId;
            var memberpwd = Config.JavaAnonymousMemberPwd;

            var args = new JavaApiReqArgs <dynamic>()
            {
                dataMap = new
                {
                    memberId   = memberId,
                    areaName   = areaName,
                    storeInfos = storeInfos
                }
            };
            var result = HttpApiUtils.ReqJavaApiForJson <dynamic>(args, url, memberId, memberpwd);

            return(result);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 根据模板ID和城市名称(或城市的ID)查询快递方式列表
        /// </summary>
        public static string GetFreightTypeByTemplateIdAndArea(string goodsId, string templateId, string areaName)
        {
            var url       = Config.JavaApiUri + "product/template/freightTemplate/getFreightTypeByTemplateIdAndArea";
            var memberId  = Config.JavaAnonymousMemberId;
            var memberpwd = Config.JavaAnonymousMemberPwd;

            var args = new JavaApiReqArgs <dynamic>()
            {
                dataMap = new
                {
                    area       = areaName,
                    memberId   = memberId,
                    goodsId    = goodsId,
                    templateId = templateId
                }
            };
            var result = HttpApiUtils.ReqJavaApiForJson <dynamic>(args, url, memberId, memberpwd);

            return(result);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 最终的运费计算接口
        /// </summary>
        public static string CountTemplateCost(string templateId, string areaName, string freightTypeId)
        {
            var url       = Config.JavaApiUri + "product/template/freightTemplate/countTemplateCost";
            var memberId  = Config.JavaAnonymousMemberId;
            var memberpwd = Config.JavaAnonymousMemberPwd;

            var args = new JavaApiReqArgs <dynamic>()
            {
                dataMap = new
                {
                    memberId      = memberId,
                    areaName      = areaName,
                    freightTypeId = freightTypeId,
                    orderCount    = 5,
                    templateId    = templateId
                }
            };
            var result = HttpApiUtils.ReqJavaApiForJson <dynamic>(args, url, memberId, memberpwd);

            return(result);
        }
Exemplo n.º 7
0
        public static JavaApiRespArgs <ChannelCategoryDatamap> GetAllChildCategory(string parentId)
        {
            string url       = Config.JavaApiUri + "channel/category/allChildCategoryMsg";
            var    memberId  = Config.JavaAnonymousMemberId;
            var    memberpwd = Config.JavaAnonymousMemberPwd;
            var    args      = new JavaApiReqArgs <dynamic>()
            {
                dataMap = new
                {
                    requestFrom = 1,
                    categoryId  = parentId,
                }
            };

            Log.Sdk.LoggerMgr.Info("请求参数=>" + ETong.Utility.Converts.Json.Serialize(args));
            var result = HttpApiUtils.ReqJavaApiForObj <dynamic, ChannelCategoryDatamap>(args, url, memberId, memberpwd);

            Log.Sdk.LoggerMgr.Info("返回结果=>" + result);

            return(result);
        }
Exemplo n.º 8
0
        public static JavaApiRespArgs <ChannelGoodsDetailDatamap> GetGoodsDetail(string channel, string goodsId)
        {
            string url       = Config.JavaApiUri + "product/common/queryGoodsDetail";
            var    memberId  = Config.JavaAnonymousMemberId;
            var    memberpwd = Config.JavaAnonymousMemberPwd;
            var    args      = new JavaApiReqArgs <dynamic>()
            {
                dataMap = new
                {
                    channType = "5",//"频道类型Id"(String类型,必填,2为农民兄弟,5为自定义频道)
                    code      = channel,
                    goodsId   = goodsId
                }
            };

            Log.Sdk.LoggerMgr.Info("请求参数=>" + ETong.Utility.Converts.Json.Serialize(args));
            var result = HttpApiUtils.ReqJavaApiForObj <dynamic, ChannelGoodsDetailDatamap>(args, url, memberId, memberpwd);

            Log.Sdk.LoggerMgr.Info("返回结果=>" + result);

            return(result);
        }
Exemplo n.º 9
0
        public static JavaApiRespArgs <ChannelGoodsListDatamap> GetIndexGoods(string channel, int pageSize, int pageNo)
        {
            string url       = Config.JavaApiUri + "channel/goods/indexGoodsPage";
            var    memberId  = Config.JavaAnonymousMemberId;
            var    memberpwd = Config.JavaAnonymousMemberPwd;
            var    args      = new JavaApiReqArgs <dynamic>()
            {
                dataMap = new
                {
                    requestFrom = 1,
                    code        = channel,
                    pageSize    = pageSize,
                    curPage     = pageNo
                }
            };

            Log.Sdk.LoggerMgr.Info("请求参数=>" + ETong.Utility.Converts.Json.Serialize(args));
            var result = HttpApiUtils.ReqJavaApiForObj <dynamic, ChannelGoodsListDatamap>(args, url, memberId, memberpwd);

            Log.Sdk.LoggerMgr.Info("返回结果=>" + result);

            return(result);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 请求java open接口
        /// </summary>
        /// <typeparam name="T">请求参数里的详细数据</typeparam>
        /// <typeparam name="Return">响应参数里的数据</typeparam>
        /// <param name="inputArgs">请求参数</param>
        /// <param name="requestUrl">请求地址</param>
        /// <returns></returns>
        public static JavaApiRespArgs <TReturn> ReqJavaApiForObj <TArgDataMap, TReturn>(JavaApiReqArgs <TArgDataMap> inputArgs, string requestUrl, string memberId, string memberPwd, int orderFrom = 1, string version = "")
        {
            var jsonResult = ReqJavaApiForJson <TArgDataMap>(inputArgs, requestUrl, memberId, memberPwd, orderFrom);

            JavaApiRespArgs <TReturn> result = default(JavaApiRespArgs <TReturn>);

            //先判断有无错误
            if (string.IsNullOrEmpty(jsonResult))
            {
                result.respMsg = "接口返回null";
            }
            else
            {
                result = Utility.Converts.Json.Deserialize <JavaApiRespArgs <TReturn> >(jsonResult);
            }

            return(result);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 请求java open接口
        /// </summary>
        /// <typeparam name="T">请求参数里的详细数据</typeparam>
        /// <typeparam name="Return">响应参数里的数据</typeparam>
        /// <param name="inputArgs">请求参数</param>
        /// <param name="requestUrl">请求地址</param>
        /// <returns></returns>
        public static string ReqJavaApiForJson <TArgDataMap>(JavaApiReqArgs <TArgDataMap> inputArgs, string requestUrl, string memberId, string memberPwd, int orderFrom = 1, string version = "v1")
        {
            //签名准备只用两层参数
            if (string.IsNullOrEmpty(inputArgs.reqTime))
            {
                inputArgs.reqTime = DateTime.Now.ToString("yyyyMMddHHmmss");
            }
            if (string.IsNullOrEmpty(inputArgs.version))
            {
                //inputArgs.version = "v1";
                inputArgs.version = version;
            }
            if (string.IsNullOrEmpty(inputArgs.reqFrom))
            {
                //inputArgs.reqFrom = "1";
                inputArgs.reqFrom = orderFrom.ToString();
            }

            string sign = string.Empty;

            SortedDictionary <string, string> bodySortDic = CaseSortedDictionary.Default;

            bodySortDic.Add("reqTime", inputArgs.reqTime);
            bodySortDic.Add("version", inputArgs.version);
            bodySortDic.Add("reqFrom", inputArgs.reqFrom);

            object temp;

            //string typeName = string.Empty;
            foreach (var p in inputArgs.dataMap.GetType().GetProperties())
            {
                temp = p.GetValue(inputArgs.dataMap);
                //typeName = p.PropertyType.Name.ToLower();
                if (temp is string || temp is int || temp is decimal || temp is double || temp is float || temp is short || temp is long)
                {
                    bodySortDic.Add(p.Name, temp.ToString());
                }
            }

            string formatedPassword = EncryptPwdForJavaApi(memberId, memberPwd, inputArgs.reqTime);

            sign = GenSignForJavaApi(bodySortDic, formatedPassword);

            inputArgs.sign = sign;

            string requestJson = Utility.Converts.Json.Serialize(inputArgs);

            if (logForSignCheck)
            {
                ETong.Log.Sdk.LoggerMgr.Info(requestJson);
            }

            var jsonResult = ETong.Utility.Comunication.HttpHelper.PostRest(requestUrl, requestJson);

            if (logForSignCheck)
            {
                ETong.Log.Sdk.LoggerMgr.Info(jsonResult);
            }

            var result = jsonResult;

            return(result);
        }