public async Task <IActionResult> DeleteQuestionAsync(string questionGuid) { var questionBiz = new FaqsQuestionBiz(); var model = await questionBiz.GetModelAsync(questionGuid); if (!(model?.Enable ?? false)) { return(Failed(ErrorCode.Empty, "当前问题不存在")); } if (string.Equals(model.Status, FaqsQuestionModel.QuestionStatusEnum.Solving.ToString(), StringComparison.OrdinalIgnoreCase)) { return(Failed(ErrorCode.UserData, "积分尚未分配,请选择最佳答案后删除")); } if (model.UserGuid != UserID) { return(Failed(ErrorCode.UserData, "这不是你的提问,不能删除")); } model.Enable = false; model.LastUpdatedBy = UserID; model.LastUpdatedDate = DateTime.Now; var result = await questionBiz.UpdateAsync(model); return(result ? Success() : Failed(ErrorCode.DataBaseError, "网络错误,删除问题失败")); }
public async Task <IActionResult> FAQsWechatPayAsync([FromBody] FAQsWechatPayRequest request) { Common.Helper.Logger.Debug($"FAQsWechatPayRequest-传入参数-UserID-{UserID}-{JsonConvert.SerializeObject(request)}"); var fdPayBiz = new FangDiPayBiz(); var userBiz = new UserBiz(); var userModel = userBiz.GetUser(UserID); if (userModel == null) { return(Failed(ErrorCode.DataBaseError, "无法获取用户信息!")); } //if (string.IsNullOrWhiteSpace(request.Code)) //{ // if (string.IsNullOrWhiteSpace(userModel.WechatOpenid)) // { // return Failed(ErrorCode.DataBaseError, "用户OpenId为空,请传Code参数!"); // } //} //else //{ // var fdResponse = await fdPayBiz.GetOpenID(new GetOpenIDRequestDto { Code = request.Code }); // if (string.IsNullOrWhiteSpace(fdResponse.Open_Id)) // { // return Failed(ErrorCode.DataBaseError, "无法获取用户OpenID!"); // } // Common.Helper.Logger.Debug($"FAQsWechatPayRequest-获取openid-UserID-{UserID}-获取的openid({fdResponse.Open_Id})-用户表的openid({userModel.WechatOpenid})"); // if (string.IsNullOrWhiteSpace(fdResponse.Open_Id) || !userModel.WechatOpenid.Equals(fdResponse.Open_Id)) // { // userModel.WechatOpenid = fdResponse.Open_Id; // await userBiz.UpdateAsync(userModel); // } //} if (string.IsNullOrWhiteSpace(userModel.WechatOpenid)) { return(Failed(ErrorCode.DataBaseError, "用户无OpenID!")); } var questionBiz = new FaqsQuestionBiz(); var questionModel = await questionBiz.GetModelAsync(request.QuestionGuid); if (questionModel == null) { return(Failed(ErrorCode.DataBaseError, "QuestionGuid无法找到数据,请检查!")); } //交易流水数据 var newTFModel = new TransactionFlowingModel { TransactionFlowingGuid = Guid.NewGuid().ToString("N"), //流水号 TransactionNumber = $"FAQSSN_{GetRandomString(10, false, false, true, false, "")}{DateTime.Now.ToString("yyyyMMddHHmmss")}", //微信标识订单流水号 OutTradeNo = $"FAQSPQ_{GetRandomString(10, false, false, true, false, "")}{DateTime.Now.ToString("yyyyMMddHHmmss")}", Channel = "微信支付", ChannelNumber = "2", PayAccount = userModel.WechatOpenid, Amount = questionModel.RewardIntergral, OutRefundNo = string.Empty, TransactionStatus = TransactionStatusEnum.WaitForPayment.ToString(), Remarks = string.Empty, OrgGuid = string.Empty, CreatedBy = UserID, LastUpdatedBy = UserID, }; var isSuccess = await new TransactionFlowingBiz().UpdateFlowingAndQuestionAsync(newTFModel, questionModel); if (!isSuccess) { return(Failed(ErrorCode.DataBaseError, "流水生成失败!")); } //await PayCallBackTestAsync(newTFModel.OutTradeNo); var fdXDResponsed = await fdPayBiz.OrdersPay(new OrdersPayRequestDto { Trade_No = newTFModel.OutTradeNo, Amount = (Convert.ToInt32(newTFModel.Amount)).ToString(), Open_Id = userModel.WechatOpenid }); return(Success(fdXDResponsed)); }