public async Task <ResponseMessage> HumanBlackCallback([FromBody] ExamineResponse examineResponse)
        {
            Logger.Trace($"新增人事信息回调(HumanBlackCallback):\r\n请求参数为:\r\n" + (examineResponse != null ? JsonHelper.ToJson(examineResponse) : ""));

            ResponseMessage response = new ResponseMessage();

            if (examineResponse == null)
            {
                response.Code = ResponseCodeDefines.ModelStateInvalid;
                Logger.Trace($"新增人事信息回调(HumanBlackCallback)模型验证失败:\r\n{response.Message ?? ""},\r\n请求参数为:\r\n" + (examineResponse != null ? JsonHelper.ToJson(examineResponse) : ""));
                return(response);
            }
            try
            {
                response.Code = ResponseCodeDefines.SuccessCode;
                if (examineResponse.ExamineStatus == ExamineStatus.Examined)
                {
                    await _humanInfoBlackManager.UpdateExamineStatus(examineResponse.SubmitDefineId, ExamineStatusEnum.Approved);
                }
                else if (examineResponse.ExamineStatus == ExamineStatus.Reject)
                {
                    await _humanInfoBlackManager.UpdateExamineStatus(examineResponse.SubmitDefineId, ExamineStatusEnum.Reject);
                }
            }
            catch (Exception e)
            {
                response.Code    = ResponseCodeDefines.ServiceError;
                response.Message = e.ToString();
                Logger.Trace($"新增人事信息回调(HumanBlackCallback)报错:\r\n{e.ToString()},\r\n请求参数为:\r\n" + (examineResponse != null ? JsonHelper.ToJson(examineResponse) : ""));
            }
            return(response);
        }
        public async Task <ResponseMessage> UpdateRecordContractCallback([FromBody] ExamineResponse examineResponse)
        {
            Logger.Warn($" 加推、报备规则、佣金方案、楼栋批次、优惠政策审核回调接口(UpdateRecordSubmitCallback):\r\n请求参数为:\r\n" + (examineResponse != null ? JsonHelper.ToJson(examineResponse) : ""));

            ResponseMessage response = new ResponseMessage();

            if (!ModelState.IsValid)
            {
                response.Code    = ResponseCodeDefines.ModelStateInvalid;
                response.Message = ModelState.GetAllErrors();
                Logger.Warn($"房源动态审核回调(UpdateRecordSubmitCallback)报错:\r\n{response.Message ?? ""},\r\n请求参数为:\r\n" + (examineResponse != null ? JsonHelper.ToJson(examineResponse) : ""));

                return(response);
            }
            try
            {
                //await _updateRecordManager.UpdateRecordSubmitCallback(examineResponse);
            }
            catch (Exception e)
            {
                response.Code    = ResponseCodeDefines.ServiceError;
                response.Message = e.ToString();
                Logger.Error($"房源动态审核回调(UpdateRecordSubmitCallback)报错:\r\n{response.Message ?? ""},\r\n请求参数为:\r\n" + (examineResponse != null ? JsonHelper.ToJson(examineResponse) : ""));
            }
            return(response);
        }
示例#3
0
        public async Task <GatewayInterface.Dto.ResponseMessage> SubmitShopsCallback(ExamineResponse examineResponse)
        {
            using (var scope = ApplicationContext.Current.Provider.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                var response = await scope.ServiceProvider.GetRequiredService <ShopsController>().SubmitShopsCallback(Mapper.Map <XYHShopsPlugin.Dto.ExamineResponse>(examineResponse));

                return(Mapper.Map <GatewayInterface.Dto.ResponseMessage>(response));
            }
        }
        public async Task ShopsHotCallbackAsync(ExamineResponse examineResponse)
        {
            var updaterecord = await Context.UpdateRecords.FirstOrDefaultAsync(a => a.Id == examineResponse.SubmitDefineId);

            if (updaterecord == null)
            {
                throw new Exception("未找到动态记录");
            }
            var building = await Context.BuildingShopInfos.FirstOrDefaultAsync(a => a.Id == examineResponse.ContentId);

            if (building == null)
            {
                throw new Exception("未找到楼盘");
            }
            if (examineResponse.ExamineStatus == ExamineStatus.Examined)
            {
                updaterecord.ExamineStatus = Models.ExamineStatusEnum.Approved;
                BuildingShopsUpdateModel buildingShopsUpdateModel = JsonConvert.DeserializeObject <BuildingShopsUpdateModel>(updaterecord.UpdateContent);
                var list  = buildingShopsUpdateModel.ShopList.Select(a => a.Id);
                var shops = (from shop in Context.ShopBaseInfos.AsNoTracking()
                             join b1 in Context.Shops.AsNoTracking() on shop.Id equals b1.Id into b2
                             from b in b2.DefaultIfEmpty()
                             where b.BuildingId == updaterecord.ContentId
                             select shop).ToList();
                for (int i = 0; i < shops.Count; i++)
                {
                    if (list.Contains(shops[i].Id))
                    {
                        shops[i].IsHot = true;
                    }
                    else
                    {
                        shops[i].IsHot = false;
                    }
                }
                Context.Update(updaterecord);
                Context.UpdateRange(shops);
            }
            else if (examineResponse.ExamineStatus == ExamineStatus.Reject)
            {
                updaterecord.ExamineStatus = Models.ExamineStatusEnum.Reject;
                Context.Update(updaterecord);
            }
            else
            {
                throw new Exception("审核状态不正确");
            }
            try
            {
                Context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
        public async Task BuildingNoCallbackAsync(ExamineResponse examineResponse)
        {
            var updaterecord = await Context.UpdateRecords.FirstOrDefaultAsync(a => a.Id == examineResponse.SubmitDefineId);

            if (updaterecord == null)
            {
                throw new Exception("未找到动态记录");
            }
            var builindnos = Context.BuildingNos.Where(a => a.BuildingId == examineResponse.ContentId);

            if (examineResponse.ExamineStatus == ExamineStatus.Examined)
            {
                updaterecord.ExamineStatus = Models.ExamineStatusEnum.Approved;
                if (await builindnos.CountAsync() > 0)
                {
                    Context.RemoveRange(builindnos);
                }
                List <BuildingNoCreateRequest> list = JsonConvert.DeserializeObject <List <BuildingNoCreateRequest> >(updaterecord.UpdateContent);
                List <BuildingNo> nolist            = new List <BuildingNo>();
                foreach (var item in list)
                {
                    nolist.Add(new BuildingNo
                    {
                        Id             = Guid.NewGuid().ToString(),
                        BuildingId     = examineResponse.ContentId,
                        Storied        = item.Storied,
                        OpenDate       = item.OpenDate,
                        DeliveryDate   = item.DeliveryDate,
                        UserId         = updaterecord.UserId,
                        OrganizationId = updaterecord.OrganizationId,
                        CreateUser     = updaterecord.UserId,
                        CreateTime     = DateTime.Now
                    });
                }
                Context.Update(updaterecord);
                Context.AddRange(nolist);
            }
            else if (examineResponse.ExamineStatus == ExamineStatus.Reject)
            {
                updaterecord.ExamineStatus = Models.ExamineStatusEnum.Reject;
                Context.Update(updaterecord);
            }
            else
            {
                throw new Exception("审核状态不正确");
            }
            try
            {
                Context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
示例#6
0
        public async Task UpdateRecordSubmitCallback(ExamineResponse examineResponse, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (examineResponse == null)
            {
                throw new ArgumentNullException(nameof(ExamineResponse));
            }
            switch (examineResponse.ContentType)
            {
            case "ShopsHot":
                await Store.ShopsHotCallbackAsync(examineResponse);

                break;

            case "ShopsAdd":
                await Store.ShopsAddCallbackAsync(examineResponse);

                break;

            case "ReportRule":
                await Store.ReportRuleCallbackAsync(examineResponse);

                break;

            case "CommissionType":
                await Store.CommissionTypeCallbackAsync(examineResponse);

                break;

            case "BuildingNo":
                await Store.BuildingNoCallbackAsync(examineResponse);

                break;

            case "DiscountPolicy":
                await Store.DiscountPolicyCallbackAsync(examineResponse);

                break;

            case "Price":
                await Store.PriceCallbackAsync(examineResponse);

                break;

            default:
                throw new NotImplementedException("未实现该内容类型的回调处理:" + examineResponse.ContentType);
            }
        }
        public async Task ShopsAddCallbackAsync(ExamineResponse examineResponse)
        {
            var updaterecord = await Context.UpdateRecords.FirstOrDefaultAsync(a => a.Id == examineResponse.SubmitDefineId);

            if (updaterecord == null)
            {
                throw new Exception("未找到动态记录");
            }
            var building = await Context.BuildingShopInfos.FirstOrDefaultAsync(a => a.Id == examineResponse.ContentId);

            if (building == null)
            {
                throw new Exception("未找到楼盘");
            }
            if (examineResponse.ExamineStatus == ExamineStatus.Examined)
            {
                updaterecord.ExamineStatus = Models.ExamineStatusEnum.Approved;
                BuildingShopsUpdateModel buildingShopsUpdateModel = JsonConvert.DeserializeObject <BuildingShopsUpdateModel>(updaterecord.UpdateContent);
                var list  = buildingShopsUpdateModel.ShopList.Select(a => a.Id);
                var shops = await Context.ShopBaseInfos.Where(a => list.Contains(a.Id)).ToListAsync();

                for (int i = 0; i < shops.Count; i++)
                {
                    shops[i].SaleStatus = "2";
                }
                Context.Update(updaterecord);
                Context.UpdateRange(shops);
            }
            else if (examineResponse.ExamineStatus == ExamineStatus.Reject)
            {
                updaterecord.ExamineStatus = Models.ExamineStatusEnum.Reject;
                Context.Update(updaterecord);
            }
            else
            {
                throw new Exception("审核状态不正确");
            }
            try
            {
                Context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
        public async Task PriceCallbackAsync(ExamineResponse examineResponse)
        {
            var updaterecord = await Context.UpdateRecords.FirstOrDefaultAsync(a => a.Id == examineResponse.SubmitDefineId);

            if (updaterecord == null)
            {
                throw new Exception("未找到动态记录");
            }
            var shops = await Context.ShopBaseInfos.FirstOrDefaultAsync(a => a.Id == examineResponse.ContentId);

            if (shops == null)
            {
                throw new Exception("未找到商铺");
            }
            if (examineResponse.ExamineStatus == ExamineStatus.Examined)
            {
                updaterecord.ExamineStatus = Models.ExamineStatusEnum.Approved;
                ShopPriceUpdateModel shopPriceUpdateModel = JsonConvert.DeserializeObject <ShopPriceUpdateModel>(updaterecord.UpdateContent);
                shops.GuidingPrice = shopPriceUpdateModel.GuidingPrice;
                shops.TotalPrice   = shopPriceUpdateModel.TotalPrice;
                shops.Price        = shopPriceUpdateModel.TotalPrice / (decimal)(shops.BuildingArea.HasValue ? shops.HouseArea.Value : 1);
                Context.Update(updaterecord);
                Context.Update(shops);
            }
            else if (examineResponse.ExamineStatus == ExamineStatus.Reject)
            {
                updaterecord.ExamineStatus = Models.ExamineStatusEnum.Reject;
                Context.Update(updaterecord);
            }
            else
            {
                throw new Exception("审核状态不正确");
            }
            try
            {
                Context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
        public async Task DiscountPolicyCallbackAsync(ExamineResponse examineResponse)
        {
            var updaterecord = await Context.UpdateRecords.FirstOrDefaultAsync(a => a.Id == examineResponse.SubmitDefineId);

            if (updaterecord == null)
            {
                throw new Exception("未找到动态记录");
            }
            var buildingShop = await Context.BuildingShopInfos.FirstOrDefaultAsync(a => a.Id == examineResponse.ContentId);

            if (buildingShop == null)
            {
                throw new Exception("未找到楼盘");
            }
            if (examineResponse.ExamineStatus == ExamineStatus.Examined)
            {
                updaterecord.ExamineStatus = Models.ExamineStatusEnum.Approved;
                DiscountPolicyUpdateModel discountPolicyUpdateModel = JsonConvert.DeserializeObject <DiscountPolicyUpdateModel>(updaterecord.UpdateContent);
                buildingShop.PreferentialPolicies = discountPolicyUpdateModel.PreferentialPolicies;
                Context.Update(updaterecord);
                Context.Update(buildingShop);
            }
            else if (examineResponse.ExamineStatus == ExamineStatus.Reject)
            {
                updaterecord.ExamineStatus = Models.ExamineStatusEnum.Reject;
                Context.Update(updaterecord);
            }
            else
            {
                throw new Exception("审核状态不正确");
            }
            try
            {
                Context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
        public async Task CommissionTypeCallbackAsync(ExamineResponse examineResponse)
        {
            var updaterecord = await Context.UpdateRecords.FirstOrDefaultAsync(a => a.Id == examineResponse.SubmitDefineId);

            if (updaterecord == null)
            {
                throw new Exception("未找到动态记录");
            }
            var building = await Context.Buildings.FirstOrDefaultAsync(a => a.Id == examineResponse.ContentId);

            if (building == null)
            {
                throw new Exception("未找到楼盘");
            }
            if (examineResponse.ExamineStatus == ExamineStatus.Examined)
            {
                updaterecord.ExamineStatus = Models.ExamineStatusEnum.Approved;
                CommissionTypeUpdateModel commissionTypeUpdateModel = JsonConvert.DeserializeObject <CommissionTypeUpdateModel>(updaterecord.UpdateContent);
                building.CommissionPlan = commissionTypeUpdateModel.CommissionPlan;
                Context.Update(updaterecord);
                Context.Update(building);
            }
            else if (examineResponse.ExamineStatus == ExamineStatus.Reject)
            {
                updaterecord.ExamineStatus = Models.ExamineStatusEnum.Reject;
                Context.Update(updaterecord);
            }
            else
            {
                throw new Exception("审核状态不正确");
            }
            try
            {
                Context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
        public async Task <ResponseMessage> SubmitShopsCallback([FromBody] ExamineResponse examineResponse)
        {
            ResponseMessage response = new ResponseMessage();

            if (!ModelState.IsValid)
            {
                response.Code    = ResponseCodeDefines.ModelStateInvalid;
                response.Message = ModelState.GetAllErrors();
                return(response);
            }
            try
            {
                var shops = await _shopsManager.FindByIdAsync("", examineResponse.ContentId);

                if (shops == null)
                {
                    response.Code    = ResponseCodeDefines.NotFound;
                    response.Message = "商铺不存在:" + examineResponse.ContentId;
                    return(response);
                }
                if (examineResponse.ExamineStatus == ExamineStatus.Examined)
                {
                    await _shopsManager.SubmitAsync(examineResponse.ContentId, Dto.ExamineStatusEnum.Approved);
                }
                else if (examineResponse.ExamineStatus == ExamineStatus.Reject)
                {
                    await _shopsManager.SubmitAsync(examineResponse.ContentId, Dto.ExamineStatusEnum.Reject);
                }
            }
            catch (Exception e)
            {
                response.Code    = ResponseCodeDefines.ServiceError;
                response.Message = e.ToString();
                Logger.Error($"审核中心回调接口(SubmitShopsCallback)报错:\r\n{e.ToString()}");
            }
            return(response);
        }
        public async Task <ResponseMessage> SubmitContractCallback([FromBody] ExamineResponse examineResponse)
        {
            Logger.Trace($"合同提交审核中心回调(SubmitContractCallback):\r\n请求参数为:\r\n" + (examineResponse != null ? JsonHelper.ToJson(examineResponse) : ""));

            ResponseMessage response = new ResponseMessage();

            if (examineResponse == null)
            {
                response.Code = ResponseCodeDefines.ModelStateInvalid;
                Logger.Trace($"合同提交审核中心回调(SubmitContractCallback)模型验证失败:\r\n{response.Message ?? ""},\r\n请求参数为:\r\n" + (examineResponse != null ? JsonHelper.ToJson(examineResponse) : ""));
                return(response);
            }
            try
            {
                var building = await _contractInfoManager.FindByIdAsync(examineResponse.ContentId);

                response.Code = ResponseCodeDefines.SuccessCode;
                if (building == null)
                {
                    response.Code    = ResponseCodeDefines.NotFound;
                    response.Message = "合同不存在:" + examineResponse.ContentId;
                    Logger.Trace($"合同提交审核中心回调(SubmitBuildingCallback)失败:合同不存在,\r\n请求参数为:\r\n" + (examineResponse != null ? JsonHelper.ToJson(examineResponse) : ""));
                    return(response);
                }

                if (examineResponse.ExamineStatus == ExamineStatus.Examined)
                {
                    var modifyre = await _contractInfoManager.OperModifyInfoAsync(examineResponse.SubmitDefineId, examineResponse.ContentId, ExamineStatusEnum.Approved);

                    if (modifyre.Type == ContractInfoManager.ModifyContract)
                    {
                        await _contractInfoManager.ModifyContractAfterCheckAsync(modifyre.ID, modifyre.ContractID, modifyre.Ext1, ExamineStatusEnum.Approved);
                    }
                    else if (modifyre.Type == ContractInfoManager.AddAnnexContract)
                    {
                        List <FileInfoRequest> fileInfoRequests = JsonHelper.ToObject <List <FileInfoRequest> >(modifyre.Ext1);
                        List <string>          deleteList       = JsonHelper.ToObject <List <string> >(modifyre.Ext5);
                        //List<NWF> listnf = JsonHelper.ToObject<List<NWF>>(modifyre.Ext2);
                        UserInfo user = JsonHelper.ToObject <UserInfo>(modifyre.Ext3);
                        List <FileInfoCallbackRequest> filCallBackReq = new List <FileInfoCallbackRequest>();

                        int nindex = 0;
                        foreach (var item in fileInfoRequests)
                        {
                            try
                            {
                                //NameValueCollection nameValueCollection = new NameValueCollection();
                                //nameValueCollection.Add("appToken", "app:nwf");
                                //Logger.Info("nwf协议");
                                //string response2 = await _restClient.Post(ApplicationContext.Current.NWFUrl, listnf.ElementAt(nindex++), "POST", nameValueCollection);
                                //Logger.Info("返回:\r\n{0}", response2);


                                await _fileScopeManager.CreateAsync(user, modifyre.Ext4, modifyre.ContractID, modifyre.ID, item);

                                //response.Message = response2;
                            }
                            catch (Exception e)
                            {
                                response.Code     = ResponseCodeDefines.PartialFailure;
                                response.Message += $"文件:{item.FileGuid}处理出错,错误信息:{e.ToString()}。\r\n";
                                Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})批量上传文件信息(UploadFiles)报错:\r\n{e.ToString()},请求参数为:\r\n,(dest){modifyre.Ext4 ?? ""},(contractId){ modifyre.ContractID ?? ""}," + (fileInfoRequests != null ? JsonHelper.ToJson(fileInfoRequests) : ""));
                            }
                        }
                        try
                        {
                            await _fileInfoManager.CreateListAsync(user.Id, fileInfoRequests, HttpContext.RequestAborted);

                            await _fileScopeManager.DeleteContractFileListAsync(user.Id, modifyre.ContractID, deleteList, HttpContext.RequestAborted);
                        }
                        catch (Exception e)
                        {
                            response.Code    = ResponseCodeDefines.ServiceError;
                            response.Message = e.ToString();
                            Logger.Trace($"合同文件添加或删除失败,审核中心回调(SubmitBuildingCallback)报错:\r\n{e.ToString()},\r\n请求参数为:\r\n" + fileInfoRequests != null ? JsonHelper.ToJson(fileInfoRequests) : "\r\n" + deleteList != null ? JsonHelper.ToJson(deleteList) : "");
                        }
                    }
                    else if (modifyre.Type == ContractInfoManager.UpdateComplementContract)
                    {
                        UserInfo User = JsonHelper.ToObject <UserInfo>(modifyre.Ext1);
                        List <ContractComplementRequest> request = JsonHelper.ToObject <List <ContractComplementRequest> >(modifyre.Ext2);
                        await _contractInfoManager.AddComplementAsync(User, modifyre.ContractID, modifyre.ID, "TEST", request);
                    }
                }
                else if (examineResponse.ExamineStatus == ExamineStatus.Reject)
                {
                    await _contractInfoManager.SubmitAsync(examineResponse.SubmitDefineId, ExamineStatusEnum.Reject);
                }
            }
            catch (Exception e)
            {
                response.Code    = ResponseCodeDefines.ServiceError;
                response.Message = e.ToString();
                Logger.Trace($"合同提交审核中心回调(SubmitBuildingCallback)报错:\r\n{e.ToString()},\r\n请求参数为:\r\n" + examineResponse != null ? JsonHelper.ToJson(examineResponse) : "");
            }
            return(response);
        }
        public async Task <ResponseMessage <ExamineStatusEnum> > CustomerDealCallback([FromBody] ExamineResponse examineResponse)
        {
            Logger.Trace($"新增成交信息审核中心回调(CustomerrDealCallback):\r\n请求参数为:\r\n" + (examineResponse != null ? JsonHelper.ToJson(examineResponse) : ""));

            var response = new ResponseMessage <ExamineStatusEnum>();

            if (!ModelState.IsValid)
            {
                response.Code    = ResponseCodeDefines.ModelStateInvalid;
                response.Message = ModelState.GetAllErrors();
                Logger.Error($"新增成交信息审核中心回调(CustomerrDealCallback)模型验证失败:\r\n{response.Message ?? ""},\r\n请求参数为:\r\n" + (examineResponse != null ? JsonHelper.ToJson(examineResponse) : ""));
                return(response);
            }
            try
            {
                var customerDeal = await _customerDealManager.FindByIdSimpleAsync(examineResponse.SubmitDefineId);

                if (customerDeal == null)
                {
                    response.Code    = ResponseCodeDefines.NotFound;
                    response.Message = "成交信息不存在:" + examineResponse.SubmitDefineId;
                    Logger.Error($"新增成交信息审核中心回调(SubmitBuildingCallback)失败:成交信息不存在,\r\n请求参数为:\r\n" + (examineResponse != null ? JsonHelper.ToJson(examineResponse) : ""));
                    return(response);
                }
                if (examineResponse.ExamineStatus == ExamineStatus.Examined)
                {
                    await _customerDealManager.UpdateStatusDealAsync(examineResponse.Ext7, examineResponse.Ext8, examineResponse.SubmitDefineId);

                    response.Extension = ExamineStatusEnum.Approved;
                }
                else if (examineResponse.ExamineStatus == ExamineStatus.Reject)
                {
                    await _customerDealManager.UpdateStatusDealAsync(examineResponse.SubmitDefineId);

                    response.Extension = ExamineStatusEnum.Reject;
                }
                if (response == null)
                {
                    response.Code    = ResponseCodeDefines.PartialFailure;
                    response.Message = "保存信息失败";
                }
                else
                {
                    if (!string.IsNullOrEmpty(customerDeal.Salesman) && !string.IsNullOrEmpty(customerDeal.Customer))
                    {
                        var customer = await _customerInfoManager.FindByIdAsync(customerDeal.Salesman, customerDeal.Customer);

                        //发送通知消息
                        SendMessageRequest sendMessageRequest = new SendMessageRequest();
                        sendMessageRequest.MessageTypeCode = "CustomerDeal";
                        MessageItem messageItem = new MessageItem();
                        messageItem.UserIds = new List <string> {
                            customerDeal.Salesman
                        };
                        messageItem.MessageTypeItems = new List <TypeItem> {
                            new TypeItem {
                                Key = "PHONE", Value = customer.MainPhone
                            },
                            new TypeItem {
                                Key = "NAME", Value = customer.CustomerName
                            },
                            new TypeItem {
                                Key = "BUILDINGNAME", Value = string.IsNullOrEmpty(customerDeal.BuildingName)?customerDeal.ShopName:""
                            },
                            new TypeItem {
                                Key = "TIME", Value = DateTime.Now.ToString("MM-dd hh:mm")
                            }
                        };
                        sendMessageRequest.MessageList = new List <MessageItem> {
                            messageItem
                        };
                        try
                        {
                            MessageLogger.Info("发送通知消息协议:\r\n{0}", JsonHelper.ToJson(sendMessageRequest));
                            _restClient.Post(ApplicationContext.Current.MessageServerUrl, sendMessageRequest, "POST", new NameValueCollection());
                        }
                        catch (Exception e)
                        {
                            MessageLogger.Error("发送通知消息出错:\r\n{0}", e.ToString());
                        }
                    }
                }
            }
            catch (Exception e)
            {
                response.Code    = ResponseCodeDefines.ServiceError;
                response.Message = "服务器错误:" + e.ToString();
                Logger.Error($"新增成交信息回调(SubmitBuildingCallback)报错:\r\n{e.ToString()},\r\n请求参数为:\r\n" + examineResponse != null ? JsonHelper.ToJson(examineResponse) : "");
            }
            return(response);
        }
        public async Task ReportRuleCallbackAsync(ExamineResponse examineResponse)
        {
            var updaterecord = await Context.UpdateRecords.FirstOrDefaultAsync(a => a.Id == examineResponse.SubmitDefineId);

            if (updaterecord == null)
            {
                throw new Exception("未找到动态记录");
            }
            if (examineResponse.ExamineStatus == ExamineStatus.Examined)
            {
                var buildingRule = await Context.BuildingRules.FirstOrDefaultAsync(a => a.Id == examineResponse.ContentId);

                updaterecord.ExamineStatus = Models.ExamineStatusEnum.Approved;
                ReportRuleUpdateModel reportRuleUpdateModel = JsonConvert.DeserializeObject <ReportRuleUpdateModel>(updaterecord.UpdateContent);
                if (buildingRule == null)
                {
                    buildingRule                     = new BuildingRule();
                    buildingRule.Id                  = examineResponse.ContentId;
                    buildingRule.AdvanceTime         = reportRuleUpdateModel.AdvanceTime;
                    buildingRule.BeltProtectDay      = reportRuleUpdateModel.BeltProtectDay;
                    buildingRule.IsCompletenessPhone = reportRuleUpdateModel.IsCompletenessPhone;
                    buildingRule.LiberatingEnd       = reportRuleUpdateModel.LiberatingEnd;
                    buildingRule.LiberatingStart     = reportRuleUpdateModel.LiberatingStart;
                    buildingRule.Mark                = reportRuleUpdateModel.Mark;
                    buildingRule.MaxCustomer         = reportRuleUpdateModel.MaxCustomer;
                    buildingRule.ReportedTemplate    = reportRuleUpdateModel.ReportedTemplate;
                    buildingRule.ReportTime          = reportRuleUpdateModel.ReportTime;
                    buildingRule.ValidityDay         = reportRuleUpdateModel.ValidityDay;
                    buildingRule.IsUse               = reportRuleUpdateModel.IsUse;
                    Context.Update(updaterecord);
                    Context.Add(buildingRule);
                }
                else
                {
                    buildingRule.AdvanceTime         = reportRuleUpdateModel.AdvanceTime;
                    buildingRule.BeltProtectDay      = reportRuleUpdateModel.BeltProtectDay;
                    buildingRule.IsCompletenessPhone = reportRuleUpdateModel.IsCompletenessPhone;
                    buildingRule.LiberatingEnd       = reportRuleUpdateModel.LiberatingEnd;
                    buildingRule.LiberatingStart     = reportRuleUpdateModel.LiberatingStart;
                    buildingRule.Mark             = reportRuleUpdateModel.Mark;
                    buildingRule.MaxCustomer      = reportRuleUpdateModel.MaxCustomer;
                    buildingRule.ReportedTemplate = reportRuleUpdateModel.ReportedTemplate;
                    buildingRule.ReportTime       = reportRuleUpdateModel.ReportTime;
                    buildingRule.ValidityDay      = reportRuleUpdateModel.ValidityDay;
                    buildingRule.IsUse            = reportRuleUpdateModel.IsUse;
                    Context.Update(updaterecord);
                    Context.Update(buildingRule);
                }
            }
            else if (examineResponse.ExamineStatus == ExamineStatus.Reject)
            {
                updaterecord.ExamineStatus = Models.ExamineStatusEnum.Reject;
                Context.Update(updaterecord);
            }
            else
            {
                throw new Exception("审核状态不正确");
            }
            try
            {
                Context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
        public async Task <ResponseMessage <ExamineStatusEnum> > SubmitBuildingCallback([FromBody] ExamineResponse examineResponse)
        {
            Logger.Trace($"楼盘提交审核中心回调(SubmitBuildingCallback):\r\n请求参数为:\r\n" + (examineResponse != null ? JsonHelper.ToJson(examineResponse) : ""));

            ResponseMessage <ExamineStatusEnum> response = new ResponseMessage <ExamineStatusEnum>();

            if (!ModelState.IsValid)
            {
                response.Code    = ResponseCodeDefines.ModelStateInvalid;
                response.Message = ModelState.GetAllErrors();
                Logger.Error($"楼盘提交审核中心回调(SubmitBuildingCallback)模型验证失败:\r\n{response.Message ?? ""},\r\n请求参数为:\r\n" + (examineResponse != null ? JsonHelper.ToJson(examineResponse) : ""));
                return(response);
            }
            try
            {
                var building = await _buildingsManager.FindByIdAsync("", examineResponse.ContentId);

                if (building == null)
                {
                    response.Code    = ResponseCodeDefines.NotFound;
                    response.Message = "楼盘不存在:" + examineResponse.ContentId;
                    Logger.Error($"楼盘提交审核中心回调(SubmitBuildingCallback)失败:楼盘不存在,\r\n请求参数为:\r\n" + (examineResponse != null ? JsonHelper.ToJson(examineResponse) : ""));
                    return(response);
                }
                if (examineResponse.ExamineStatus == ExamineStatus.Examined)
                {
                    await _buildingsManager.SubmitAsync(examineResponse.ContentId, Dto.ExamineStatusEnum.Approved);

                    response.Extension = ExamineStatusEnum.Approved;
                }
                else if (examineResponse.ExamineStatus == ExamineStatus.Reject)
                {
                    await _buildingsManager.SubmitAsync(examineResponse.ContentId, Dto.ExamineStatusEnum.Reject);

                    response.Extension = ExamineStatusEnum.Reject;
                }
            }
            catch (Exception e)
            {
                response.Code    = ResponseCodeDefines.ServiceError;
                response.Message = e.ToString();
                Logger.Error($"楼盘提交审核中心回调(SubmitBuildingCallback)报错:\r\n{e.ToString()},\r\n请求参数为:\r\n" + examineResponse != null ? JsonHelper.ToJson(examineResponse) : "");
            }
            return(response);
        }
        public async Task <ResponseMessage> BuildingsOnSiteCallback([FromBody] ExamineResponse examineResponse)
        {
            Logger.Trace($"指派驻场回调(BuildingsOnSiteCallback):\r\n请求参数为:\r\n" + (examineResponse != null ? JsonHelper.ToJson(examineResponse) : ""));

            ResponseMessage response = new ResponseMessage();

            if (!ModelState.IsValid)
            {
                response.Code    = ResponseCodeDefines.ModelStateInvalid;
                response.Message = ModelState.GetAllErrors();
                Logger.Warn("模型验证失败:\r\n{0}", response.Message ?? "");
                return(response);
            }
            if (examineResponse.ContentType != "BuildingsOnSite")
            {
                response.Code    = ResponseCodeDefines.ServiceError;
                response.Message = "该回调实现不支持BuildingsOnSite的内容类型";
                Logger.Warn("指派驻场业务层回调失败:\r\n{0}", response.Message ?? "");
                return(response);
            }
            try
            {
                var onsite = JsonHelper.ToObject <BuildingsOnSiteRequest>(examineResponse.Content);
                if (examineResponse.ExamineStatus == ExamineStatus.Examined)
                {
                    await _buildingsManager.SaveResidentUserAsync("", onsite);

                    //发送通知消息
                    SendMessageRequest sendMessageRequest = new SendMessageRequest();
                    sendMessageRequest.MessageTypeCode = "BuildingsOnSite";
                    MessageItem messageItem = new MessageItem();
                    messageItem.UserIds = new List <string>();
                    if (!string.IsNullOrEmpty(onsite.ResidentUser1))
                    {
                        messageItem.UserIds.Add(onsite.ResidentUser1);
                    }
                    if (!string.IsNullOrEmpty(onsite.ResidentUser2))
                    {
                        messageItem.UserIds.Add(onsite.ResidentUser2);
                    }
                    if (!string.IsNullOrEmpty(onsite.ResidentUser3))
                    {
                        messageItem.UserIds.Add(onsite.ResidentUser3);
                    }
                    if (!string.IsNullOrEmpty(onsite.ResidentUser4))
                    {
                        messageItem.UserIds.Add(onsite.ResidentUser4);
                    }
                    messageItem.MessageTypeItems = new List <TypeItem> {
                        new TypeItem {
                            Key = "NAME", Value = onsite.Name
                        },
                        new TypeItem {
                            Key = "TIME", Value = DateTime.Now.ToString("MM-dd hh:mm")
                        }
                    };
                    sendMessageRequest.MessageList = new List <MessageItem> {
                        messageItem
                    };
                    try
                    {
                        MessageLogger.Info("发送通知消息协议:\r\n{0}", JsonHelper.ToJson(sendMessageRequest));
                        _restClient.Post(ApplicationContext.Current.MessageServerUrl, sendMessageRequest, "POST", new NameValueCollection());
                    }
                    catch (Exception e)
                    {
                        MessageLogger.Error("发送通知消息出错:\r\n{0}", e.ToString());
                    }
                }
            }
            catch (Exception e)
            {
                response.Code    = ResponseCodeDefines.ServiceError;
                response.Message = e.ToString();
                Logger.Error("指派驻场回调失败:\r\n{0}", e.ToString());
            }
            return(response);
        }