public void OnException(ExceptionContext context) { _logger.LogError(context.Exception, "请管理员解决"); //if (env.IsDevelopment()) if (context.Exception.GetType() == typeof(AdminSystemDomainException)) { string errorMessage = " "; if (context.Exception.InnerException != null && context.Exception.InnerException.GetType() == typeof(FluentValidation.ValidationException)) { var validationE = context.Exception.InnerException as FluentValidation.ValidationException; foreach (var temp in validationE.Errors) { errorMessage += temp.ErrorMessage + ","; } } context.Result = new ObjectResult(ResultData <string> .CreateResultDataFail( context.Exception.Message + "," + errorMessage.Substring(0, errorMessage.Length - 1))); } else { context.Result = new ObjectResult(ResultData <string> .CreateResultDataFail(context.Exception.Message)); } context.HttpContext.Response.StatusCode = (int)HttpStatusCode.OK; context.ExceptionHandled = true; }
/// <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 ?? "调用极速达取消接口失败")); }
/// <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)); }
public async Task <ResultData <string> > Handle(SendValidateCodeCommand request, CancellationToken cancellationToken) { if (string.IsNullOrWhiteSpace(request.Mobile)) { return(ResultData <string> .CreateResultDataFail("手机号码不能为空")); } var user = await this._applicationUserRepository.GetUserByMobileAsync(request.Mobile); if (user == null) { return(ResultData <string> .CreateResultDataFail("该手机号码不是系统用户,请联系系统管理员")); } user.SendSms(); await _applicationUserRepository.UnitOfWork.SaveEntitiesAsync(); return(ResultData <string> .CreateResultDataSuccess("成功")); }
/// <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("调用订单更新为已签收失败")); }
public async Task <ResultData <string> > Handle(LoginCommand request, CancellationToken cancellationToken) { if (string.IsNullOrWhiteSpace(request.Mobile) || string.IsNullOrWhiteSpace(request.ValidateCode)) { return(ResultData <string> .CreateResultDataFail("手机号码或验证码不能为空")); } var user = await _applicationUserRepository.GetUserByMobileAsync(request.Mobile); if (user == null) { return(ResultData <string> .CreateResultDataFail("不存在改手机号码")); } if (request.ValidateCode != user.SmsCode || user.IsUseSms) { return(ResultData <string> .CreateResultDataFail("验证码不符合或者已使用,请重新发送验证码")); } //已使用验证码 设置为失效 user.UseSms(); var claim = new Claim[] { new Claim("Mobile", request.Mobile), new Claim("UserId", user.UserId), new Claim("DeptCode", user.DeptCode), new Claim("TrueName", user.TrueName), }; await _applicationUserRepository.UnitOfWork.SaveEntitiesAsync(); var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("Hello-key-----wyt")); var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); var token = new JwtSecurityToken("self", "selfA", claim, DateTime.Now, DateTime.Now.AddMinutes(30), creds); return(ResultData <string> .CreateResultDataSuccess("成功", new JwtSecurityTokenHandler().WriteToken(token))); }
public async Task <ResultData <string> > Handle(SignReceiveOrderCommand request, CancellationToken cancellationToken) { if (string.IsNullOrWhiteSpace(request.JsdOrderCode)) { return(ResultData <string> .CreateResultDataFail("JsdOrderId 字段不能为空")); } if (string.IsNullOrWhiteSpace(request.Mobile)) { return(ResultData <string> .CreateResultDataFail("下单人手机号码不能为空")); } if (string.IsNullOrWhiteSpace(request.ReceiveCode)) { return(ResultData <string> .CreateResultDataFail("签收码不能为空")); } var jsdOrder = await _jsdOrderRepository.GetJsdByJsdOrderCodeAsync(request.JsdOrderCode); if (jsdOrder == null) { return(ResultData <string> .CreateResultDataFail("该订单未找到")); } if (jsdOrder.Status != "0" && jsdOrder.Status != "1") { return(ResultData <string> .CreateResultDataFail("订单只能在派单中或者派送才能签收")); } //先查询验证合法性 var queryResult = await _httpOmsService.QueryReceiveCodeAsync(new Models.HttpQueryReceiveCodeParameter() { serial = jsdOrder.OrderCode, receiveCode = request.ReceiveCode }); if (!queryResult.IsSuccess()) { return(queryResult); } jsdOrder.SignReceive(request.Mobile, _identityService.GetUserId(), _identityService.GetTrueName(), request.Imeis, request.ReceiveCode); //调用签收接口 var checkResult = await _httpOmsService.CheckReceiveCodeAsync(new Models.HttpCheckReceiveCodeParameter() { serial = jsdOrder.OrderCode, receiveCode = request.ReceiveCode, status = "1" }); if (!checkResult.IsSuccess()) { return(checkResult); } var UpdateOrderSignResult = await _httpOmsService.UpdateOrderSign(new Models.HttpUpdateOrderSignParameter() { OrderCode = jsdOrder.OrderCode }); if (!UpdateOrderSignResult.IsSuccess()) { this._logger.LogWarning($"签收更新订单接口失败 订单号:{jsdOrder.OrderCode} 原因:{UpdateOrderSignResult.resultMessage}"); } else { this._logger.LogInformation($"签收更新订单接口成功 订单号:{jsdOrder.OrderCode} "); } //更新数据库 await _jsdOrderRepository.UnitOfWork.SaveEntitiesAsync(); return(ResultData <string> .CreateResultDataSuccess("成功")); }