Ejemplo n.º 1
0
        /// <summary>
        /// 极速达取消订单
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public async Task <ResultData <string> > CancelOrder(HttpCancelOrderParameter param)
        {
            Dictionary <string, string> dirList = new Dictionary <string, string>();

            dirList.Add("OrderCode", param.OrderCode);
            dirList.Add("cancelBy", param.cancelBy);

            dirList.Add("app_id", "jsd");
            dirList.Add("timestamp", StaticFunction.GetTimestamp(0).ToString() + "000");
            dirList.Add("ecOrderNumber", param.OrderCode);
            var str  = StaticFunction.GetEcoParamSrc(dirList);
            var sign = MD5Utils.MD5Encrypt(eco_app_token + str + eco_app_token).ToUpper();


            dirList.Add("sign", sign);

            var returnStr = await WebAPIHelper.HttpPostAsync(ECOUrl + "/api/order/cancelOrder", JsonConvert.SerializeObject(dirList));

            var result = JsonConvert.DeserializeObject <HttpCancelOrderResult>(returnStr);

            if (result.success)
            {
                this._logger.LogInformation("订单号为:" + param.OrderCode + "取消成功");
                return(ResultData <string> .CreateResultDataSuccess("成功"));
            }
            this._logger.LogWarning("订单号为:" + param.OrderCode + "取消失败,原因:" + (result.errorMsg ?? "调用极速达取消接口失败"));
            return(ResultData <string> .CreateResultDataFail(result.errorMsg ?? "调用极速达取消接口失败"));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 签收核销码(极速达)
        /// 曾南华 20190326
        /// </summary>
        /// <returns></returns>
        public async Task <ResultData <string> > CheckReceiveCodeAsync(HttpCheckReceiveCodeParameter param)
        {
            var str = JsonConvert.SerializeObject(param);

            var returnStr = await WebAPIHelper.HttpPostAsync(OMSUrl + "/orders/web/trade/checkReceiveCode", str);

            var result = JsonConvert.DeserializeObject <HttpReceiveResult>(returnStr);

            if (result.Code == "0")
            {
                return(ResultData <string> .CreateResultDataSuccess("成功"));
            }

            return(ResultData <string> .CreateResultDataFail(result.Msg));
        }
Ejemplo n.º 3
0
        public async Task Handle(SendSmsDomainEvent notification, CancellationToken cancellationToken)
        {
            if (string.IsNullOrEmpty(notification.Content))
            {
                throw new Exception("短信内容不能为空");
            }
            if (string.IsNullOrEmpty(notification.Mobile))
            {
                throw new Exception("短信手机号不能为空");
            }
            string timestamp = WebAPIHelper.ConvertCurrentTimeStamp();
            string dataJson  = JsonConvert.SerializeObject(new { phone = notification.Mobile, content = notification.Content, inner = false });
            string uri       = "/oppo/sms/singleSend";

            IDictionary <string, string> paramsMap = new Dictionary <string, string>();

            paramsMap.Add("smsAppId", AppId);
            paramsMap.Add("smsAppKey", smsAppKey);
            paramsMap.Add("app_id", AppId);
            paramsMap.Add("timestamp", timestamp);
            paramsMap.Add("data", dataJson);
            //生成签名
            string sign = WebAPIHelper.SmsSign(paramsMap, uri, Secret);

            paramsMap.Add("sign", sign);

            //暂用GET方式
            //POST 方式:遇到特殊字符会被转义,导致签名不能通过
            string res = await WebAPIHelper.HttpPostAsync(Url + uri, WebAPIHelper.SmsBuildEncodeUrl(paramsMap), contentType : "application/x-www-form-urlencoded");

            if (!string.IsNullOrWhiteSpace(res))
            {
                HttpSmdModelResult model = JsonConvert.DeserializeObject <HttpSmdModelResult>(res);
                if (model.code != null && model.code == "0")
                {
                    return;
                }
            }

            _logger.LogWarning($"短信发送失败,mobile:{notification.Mobile} 内容“{notification.Content}”");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取极速达订单
        /// </summary>
        /// <returns></returns>
        public async Task <HttpGetJsdOrderPayedDetailResult> GetJsdOrderPayedDetailAsync(DateTime datetime)
        {
            var intertfeceUrl = "/orders/web/ecoSync/orders/getJsdOrderPayedDetail";
            var headurl       = JsdUpdateOrderUrl.Trim('/');

            var dateStr = datetime.ToString("yyyy-MM-dd");

            var requestObj = new
            {
                appid      = "3",
                start_date = dateStr + " 00:00:00",
                end_date   = dateStr + " 23:59:59",
                sign       = MD5Utils.MD5Encrypt(headurl + intertfeceUrl + JsdUpdateOrderAppSecret)
            };

            var returnStr = await WebAPIHelper.HttpPostAsync(headurl + intertfeceUrl, JsonConvert.SerializeObject(requestObj));

            var result = JsonConvert.DeserializeObject <HttpGetJsdOrderPayedDetailResult>(returnStr);

            return(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 更新订单为已签收
        /// 曾南华 20190327
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public async Task <ResultData <string> > UpdateOrderSign(HttpUpdateOrderSignParameter param)
        {
            var intertfeceUrl = "/orders/web/ecoSync/orders/updateOrderSign";
            var headurl       = JsdUpdateOrderUrl.Trim('/');

            var requestObj = new
            {
                appid            = "3",
                order_deliveries = new[]
                {
                    new  {
                        order_no      = param.OrderCode,
                        serial        = "",
                        shipping_id   = "",
                        shipping_name = "",
                        sign_at       = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),
                        status        = "8"
                    },
                },
                sign = MD5Utils.MD5Encrypt(headurl + intertfeceUrl + JsdUpdateOrderAppSecret)
            };


            var returnStr = await WebAPIHelper.HttpPostAsync(headurl + intertfeceUrl, JsonConvert.SerializeObject(requestObj));

            var result = JsonConvert.DeserializeObject <HttpUpdateOrderSignResult>(returnStr);

            if (result != null && result.data != null && result.data.state == "1")
            {
                _logger.LogInformation($"签收更新订单接口成功 订单号{param.OrderCode}");
                return(ResultData <string> .CreateResultDataSuccess("成功"));
            }
            if (result != null && result.data != null && (!string.IsNullOrEmpty(result.data.errorMsg)))
            {
                _logger.LogWarning($"签收更新订单接口失败 订单号{param.OrderCode} 原因:{result.data.errorMsg}");
                return(ResultData <string> .CreateResultDataFail(result.data.errorMsg));
            }
            _logger.LogWarning($"签收更新订单接口失败 订单号{param.OrderCode} ");
            return(ResultData <string> .CreateResultDataFail("调用订单更新为已签收失败"));
        }