/// <summary> /// 更新model /// </summary> /// <param name="model"></param> /// <returns></returns> public async Task <string> AddModelAsync(FaqsQuestionModel model) { using (var conn = MySqlHelper.GetConnection()) { return(await conn.InsertAsync <string, FaqsQuestionModel>(model)); } }
/// <summary> /// 添加答案 /// </summary> /// <returns></returns> public virtual async Task <bool> InsertAsync(FaqsAnswerModel entity, FaqsQuestionModel faqsQuestionModel) { return(await MySqlHelper.TransactionAsync(async (conn, trans) => { await conn.InsertAsync <string, FaqsAnswerModel>(entity); await conn.UpdateAsync(faqsQuestionModel); return true; })); }
/// <summary> /// 更新model /// </summary> /// <param name="model"></param> /// <returns></returns> public async Task <bool> UpdateAsync(FaqsQuestionModel model) { using (var conn = MySqlHelper.GetConnection()) { var result = await conn.UpdateAsync(model); return(result > 0); } }
/// <summary> /// 更新model /// </summary> /// <param name="model"></param> /// <returns></returns> public async Task <bool> UpdateDoubleModelAsync(FaqsQuestionModel model, TransactionFlowingModel transactionFlowingModel) { return(await MySqlHelper.TransactionAsync(async (conn, trans) => { if ((await conn.UpdateAsync(model)) < 1) { return false; } if ((await conn.UpdateAsync(transactionFlowingModel)) < 1) { return false; } return true; })); }
/// <summary> /// 发布问题 /// </summary> /// <param name="scoreModel">发布问题消费积分model</param> /// <param name="questionModel">问题model</param> /// <returns></returns> public async Task <bool> PostQuestionsAsync(ScoreModel scoreModel, FaqsQuestionModel questionModel) { return(await MySqlHelper.TransactionAsync(async (conn, trans) => { if (string.IsNullOrWhiteSpace(await conn.InsertAsync <string, ScoreModel>(scoreModel))) { return false; } if (string.IsNullOrWhiteSpace(await conn.InsertAsync <string, FaqsQuestionModel>(questionModel))) { return false; } return true; })); }
/// <summary> /// 悬赏金额分配 /// </summary> /// <returns></returns> public async Task <bool> FaqsAllotQuestionFee(FaqsQuestionModel item, List <FaqsAnswerModel> answerModelList, List <DoctorEaringsDetailModel> earingsDetailModelList, List <Dictionary <bool, DoctorBalanceModel> > doctorBalanceModelList) { return(await MySqlHelper.TransactionAsync(async (conn, trans) => { if (await conn.UpdateAsync(item) < 1) { return false; } foreach (var answerItem in answerModelList) { if (await conn.UpdateAsync(answerItem) < 1) { return false; } } foreach (var earingsDetailItem in earingsDetailModelList) { if (string.IsNullOrWhiteSpace(await conn.InsertAsync <string, DoctorEaringsDetailModel>(earingsDetailItem))) { return false; } } foreach (var dic in doctorBalanceModelList) { foreach (var dicItem in dic) { if (dicItem.Key) { if (string.IsNullOrWhiteSpace(await conn.InsertAsync <string, DoctorBalanceModel>(dicItem.Value))) { return false; } } else { if (await conn.UpdateAsync(dicItem.Value) < 1) { return false; } } } } return true; })); }
/// <summary> /// 发布问题 /// </summary> /// <param name="scoreModel">发布问题消费积分model</param> /// <param name="questionModel">问题model</param> /// <returns></returns> public async Task <bool> FaqsAutoAllotFeeUpdateAsync(FaqsQuestionModel questionModel, List <DoctorEaringsDetailModel> earingsDetailModelList, DoctorBalanceModel balanceModel) { return(await MySqlHelper.TransactionAsync(async (conn, trans) => { if (string.IsNullOrWhiteSpace(await conn.InsertAsync <string, DoctorBalanceModel>(balanceModel))) { return false; } if (string.IsNullOrWhiteSpace(await conn.InsertAsync <string, FaqsQuestionModel>(questionModel))) { return false; } return true; })); }
public async Task <IActionResult> PostQuestionsAsync([FromBody] PostQuestionsRequestDto requestDto) { var scoreTotal = await new ScoreExBiz().GetTotalScore(UserID, Common.EnumDefine.UserType.Consumer); if (scoreTotal < requestDto.Score) { return(Failed(ErrorCode.UserData, "用户当前积分不足")); } var settingValue = await new FaqsQuestionBiz().GetSettingValueAsync(false); if (requestDto.Score < settingValue) { return(Failed(ErrorCode.FormatError, $"悬赏积分不能少于 {settingValue} 元!")); } var scoreModel = new ScoreModel { ScoreGuid = Guid.NewGuid().ToString("N"), UserGuid = UserID, UserTypeGuid = GD.Common.EnumDefine.UserType.Consumer.ToString(), Variation = requestDto.Score * -1, Reason = "提问消费积分", PlatformType = GD.Common.EnumDefine.PlatformType.CloudDoctor.ToString(), CreatedBy = UserID, LastUpdatedBy = UserID, OrgGuid = string.Empty }; var questionModel = new FaqsQuestionModel { QuestionGuid = Guid.NewGuid().ToString("N"), UserGuid = UserID, RewardIntergral = requestDto.Score, Status = FaqsQuestionModel.QuestionStatusEnum.Solving.ToString(), AnswerNum = 0, Content = requestDto.Content, AttachmentGuidList = JsonConvert.SerializeObject(requestDto.AttachedPictures), CreatedBy = UserID, LastUpdatedBy = UserID, OrgGuid = string.Empty }; var result = await new FaqsQuestionBiz().PostQuestionsAsync(scoreModel, questionModel); return(result ? Success() : Failed(ErrorCode.DataBaseError, "网络连接异常,发布问题出错")); }
public async Task <IActionResult> PostQuestionsByWeChatPayAsync([FromBody] PostQuestionsByWeChatPayAsyncRequest request) { //FAQSWD 问答提现 FAQSWP 问答微信支付 //var transferFlowingModel = await new TransactionFlowingBiz().GetModelByOutTradeNo(requestDto.FaqsTransferFlowing); //if (transferFlowingModel == null || !transferFlowingModel.TransactionStatus.Trim().ToLower().Equals(TransactionStatus.Success.ToString().Trim().ToLower())) //{ // return Failed(ErrorCode.UserData, "对应的流水不是已完成状态,无法提交!"); //} //支付金额 是否 符合要求,最少悬赏金额 var settingValue = await new FaqsQuestionBiz().GetSettingValueAsync(true); if (request.FeeNum < settingValue) { return(Failed(ErrorCode.FormatError, $"悬赏金额不能少于 {settingValue} 元!")); } var questionModel = new FaqsQuestionModel { QuestionGuid = Guid.NewGuid().ToString("N"), UserGuid = UserID, RewardIntergral = Convert.ToInt32(request.FeeNum * 100), RewardType = FaqsQuestionModel.RewardTypeEnum.Money.ToString(), Status = FaqsQuestionModel.QuestionStatusEnum.Solving.ToString(), TransferFlowingGuid = string.Empty,//transferFlowingModel.TransactionFlowingGuid, AnswerNum = 0, Content = request.Content, AttachmentGuidList = JsonConvert.SerializeObject(request.AttachedPictures), CreatedBy = UserID, LastUpdatedBy = UserID, OrgGuid = string.Empty, Enable = false }; var result = await new FaqsQuestionBiz().AddModelAsync(questionModel); return(string.IsNullOrWhiteSpace(result) ? Failed(ErrorCode.DataBaseError, "网络连接异常,发布问题出错") : Success(result)); }
/// <summary> /// 设置回答为最佳答案(金额) /// </summary> /// <param name="model">回答model</param> /// <param name="收益明细">收益明细model</param> /// <returns></returns> public async Task <bool> SetBestAnswerAllotMoneyAsync(FaqsAnswerModel model, DoctorEaringsDetailModel earingsDetailModel, DoctorBalanceModel balanceModel, FaqsQuestionModel questionModel, bool isNewBalanceModel) { return(await MySqlHelper.TransactionAsync(async (conn, trans) => { if (isNewBalanceModel) { if (string.IsNullOrWhiteSpace(await conn.InsertAsync <string, DoctorBalanceModel>(balanceModel))) { return false; } } else { if ((await conn.UpdateAsync(balanceModel)) < 1) { return false; } } if (await conn.UpdateAsync(model) == 0) { return false; } if (await conn.UpdateAsync(questionModel) == 0) { return false; } if (string.IsNullOrWhiteSpace(await conn.InsertAsync <string, DoctorEaringsDetailModel>(earingsDetailModel))) { return false; } return true; })); }
/// <summary> /// 设置回答为最佳答案(积分) /// </summary> /// <param name="model">回答model</param> /// <param name="scoreModel">积分model</param> /// <returns></returns> public async Task <bool> SetBestAnswerAsync(FaqsAnswerModel model, ScoreModel scoreModel, FaqsQuestionModel questionModel) { return(await MySqlHelper.TransactionAsync(async (conn, trans) => { if (await conn.UpdateAsync(model) == 0) { return false; } if (await conn.UpdateAsync(questionModel) == 0) { return false; } if (string.IsNullOrWhiteSpace(await conn.InsertAsync <string, ScoreModel>(scoreModel))) { return false; } return true; })); }