public HttpResponseMessage Get([FromUri] GetBjdItemRequest request)
        {
            logInfo.Info(string.Format("获取报价单信息接口请求串:{0}", Request.RequestUri));
            var item = new BaojiaItemViewModel();

            if (!ModelState.IsValid)
            {
                item.BusinessStatus = -10000;
                string msg = ModelState.Values.Where(a => a.Errors.Count == 1).Aggregate(string.Empty, (current, a) => current + (a.Errors[0].ErrorMessage + ";   "));
                item.StatusMessage = "输入参数错误," + msg;
                return(item.ResponseToJson());
            }
            try
            {
                var response = _bjdService.GetBjdInfo(request, Request.GetQueryNameValuePairs());
                item.BusinessStatus = 1;
                if (request.Test == 1)
                {//调试用
                    response.Baodanxinxi = null;
                }
                if (response.Baodanxinxi != null && response.Baodanxinxi.Id > 0)
                {
                    item = response.Baodanxinxi.ConvertToViewModel(response.Baodanxianzhong, response.ClaimDetail, response.Savequote, response.AgentDetail, response.Activitys);
                }
                else if (request.JieKouUrl == 0)
                {//JieKouUrl为防止南北方都没数据循环调用
                    //南北方机房互相调用
                    var    jifangConfig = ConfigurationManager.AppSettings["JiFangUrl"];
                    string jifangUrl    = string.Empty;
                    if (jifangConfig != null)
                    {
                        jifangUrl = jifangConfig.ToString();
                    }
                    if (!string.IsNullOrEmpty(jifangUrl))
                    {
                        string geturl = string.Format("{0}/api/Bjd/Get?JieKouUrl=1&Bxid={1}", jifangUrl, request.Bxid);
                        string result = HttpWebAsk.HttpGet(geturl);
                        item = result.FromJson <BaojiaItemViewModel>();
                        return(item.ResponseToJson());
                    }
                }
                logInfo.Info(string.Format("获取报价单信息接口返回值:{0}", item.ToJson()));
            }
            catch (Exception ex)
            {
                item.BusinessStatus = -10003;
                item.StatusMessage  = "服务器发生异常";
                logError.Info("获取报价单信息单发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }

            return(item.ResponseToJson());
        }
Пример #2
0
        /// <summary>
        /// 只推送到期通知
        /// </summary>
        /// <param name="licenseNo"></param>
        /// <param name="businessExpireDate"></param>
        /// <param name="forceExpireDate"></param>
        /// <param name="nextBusinessStartDate"></param>
        /// <param name="nextForceExpireDate"></param>
        /// <param name="source"></param>
        /// <param name="childAgent">子集agent</param>
        /// <param name="agentId">顶级agent</param>
        /// <param name="buid"></param>
        /// <param name="isRead"></param>
        /// <returns>0未推送1已推送</returns>
        public long AddNoticexb(int cityCode, string licenseNo, string businessExpireDate, string forceExpireDate, string nextBusinessStartDate, string nextForceExpireDate, int source, int childAgent, int agentId, long buid, int isRead = 0)
        {
            //交强险剩余天数
            int forceDays = 0;
            //不符合90内插入条件的不执行插入
            bool isInTime = IsInTime(cityCode, businessExpireDate, forceExpireDate, out forceDays);

            if (!isInTime)
            {
                return(0);
            }
            var model = new CompositeBuIdLicenseNo
            {
                BuId      = buid,
                LicenseNo = licenseNo,
                Days      = forceDays
            };
            var list = new List <CompositeBuIdLicenseNo> {
                model
            };
            var sendModel = new DuoToNoticeViewModel
            {
                AgentId     = childAgent,
                Data        = list,
                BuidsString = buid.ToString()
            };
            var sendList = new List <DuoToNoticeViewModel> {
                sendModel
            };
            string url  = string.Format("{0}/api/Message/SendDuetToNotice", _messageCenterHost);
            var    data = sendList.ToJson();

            _logAppInfo.Info(string.Format("消息发送SendDuetToNotice请求串: url:{0}/api/Message/SendDuetToNotice ; data:{1}", _messageCenterHost, data));
            string resultMessage = HttpWebAsk.HttpClientPostAsync(data, url);

            _logAppInfo.Info(string.Format("消息发送SendDuetToNotice返回值:{0}", resultMessage));

            //using (var client = new HttpClient())
            //{
            //    var datas = CommonHelper.ReverseEachProperties(sendList);
            //    var postData = new FormUrlEncodedContent(datas);
            //    //请求串
            //    var clientResult =
            //        client.PostAsync(string.Format("{0}/api/Message/SendDuetToNotice", _messageCenterHost), postData);
            //    _logAppInfo.Info(string.Format("消息发送SendDuetToNotice请求串: url:{0}/api/Message/SendDuetToNotice ; data:{1}", _messageCenterHost, datas));
            //    //请求返回值
            //    var responseContent = clientResult.Result.Content;
            //    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/json"));
            //    _logAppInfo.Info(string.Format("消息发送SendDuetToNotice返回值:{0}", responseContent.ReadAsStringAsync().Result));
            //}
            return(1);
        }
        public int NotifyMessageCenter(long msgId, string msgUrl, int status)
        {
            log.Info(string.Format("消息发送NotifyMessageCenter: msgId:{0},msgUrl:{1},status:{2}", msgId, msgUrl, status));
            string ret     = string.Empty;
            int    errCode = 0;

            try
            {
                HttpWebAsk.Post(msgUrl + "/UpdateMessageStatus", string.Format("msgId={0}&status={1}", msgId, (int)status), out ret);
            }
            catch (Exception)
            {
                errCode = -1;
            }
            return(errCode);
        }
        public MessageResult SendToMessageCenter(string data, string msgUrl, string queueName = "")
        {
            MessageResult message  = new MessageResult();
            string        url      = string.Format("{0}/SetBusinessMessage", msgUrl);
            string        postData = string.Format("data={0}&queueName={1}", data, queueName);
            string        result;

            try
            {
                int ret = HttpWebAsk.Post(url, postData, out result);
                message = result.FromJson <MessageResult>();
                log.Info(string.Format("消息发送SendToMessageCenter: data:{0},url:{1},响应结果:{2}", postData, url, result));
            }
            catch (Exception ex)
            {
                log.Info("消息发送SendToMessageCenter: data:" + postData + ",url:" + url + "\n 异常信息:" + ex.StackTrace + " \n " + ex.Message);
                throw new Exception("消息发送异常", new MessageException());
            }
            return(message);
        }
Пример #5
0
        /// <summary>
        /// 获取待发送信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <string> MessageShorById(string userId)
        {
            string request = "{ 'UserId':" + userId + "}";
            string url     = $"{_urlModel.BihuApi}/api/Message/MessageExistById";
            string result  = await HttpWebAsk.HttpClientPostAsync(request, url);

            JObject resultResponse = JsonConvert.DeserializeObject(result) as JObject;

            if (resultResponse["Code"].ToString() != "1")
            {
                _logger.LogError("请求获取人员推送信息出错,用户id:" + userId + Environment.NewLine + result);
                return("");
            }
            string value = resultResponse["Data"]["Value"].ToString();

            if (value == "[]")
            {
                return("");
            }
            value = value.Replace("\r\n", "");
            return(value);
        }
        public BaseResponse EditAgentUKey(EditAgentUKeyRequest request, IEnumerable <KeyValuePair <string, string> > pairs)
        {
            BaseResponse response = new BaseResponse();

            try
            {
                IBxAgent agentModel = GetAgentModelFactory(request.Agent);

                if (!agentModel.AgentCanUse())
                {
                    response.Status = HttpStatusCode.Forbidden;
                    return(response);
                }
                if (request.ReqSource == 1)
                {//对外的接口才做这一层校验
                    var validateUrl = string.Format("UserCode={0}&UkeyId={1}&OldPassWord={2}&NewPassWord={3}&Agent={4}", request.UserCode, request.UkeyId, request.OldPassWord, request.NewPassWord, request.Agent);
                    if (!ValidatePostReqest(validateUrl, agentModel.SecretKey, request.SecCode))
                    {
                        response.Status = HttpStatusCode.Forbidden;
                        return(response);
                    }
                }
                //查询ukey信息
                var ukeyModel = _iagentAgentUKeyRepository.GetModel(request.UkeyId);
                if (ukeyModel == null)
                {
                    response.ErrCode = -1;
                    response.ErrMsg  = "未查到Ukey信息";
                    return(response);
                }
                //请求中心修改密码接口
                string strUrl  = string.Format("{0}/api/ChangePassWord/ChangePwd", _baoxianCenter);
                string oldPwd  = request.ReqSource == 1 ? request.OldPassWord : string.Empty;
                var    objPost = new
                {
                    UserCode    = request.UserCode,
                    UkeyId      = request.UkeyId,
                    OldPassWord = oldPwd,
                    NewPassWord = request.NewPassWord
                };
                StringBuilder postData = new StringBuilder();
                postData.Append("UserCode=").Append(request.UserCode)
                .Append("&UkeyId=").Append(request.UkeyId)
                .Append("&OldPassWord="******"&NewPassWord="******"&ReqSource=").Append(request.ReqSource);
                string result = string.Empty;
                int    i      = HttpWebAsk.Post(strUrl, postData.ToString(), out result);
                logInfo.Info("调用中心修改密码接口Url:" + strUrl + ";请求参数为:" + objPost.ToJson() + ";返回结果为:" + result);
                if (!string.IsNullOrWhiteSpace(result))
                {
                    var ret = result.FromJson <UKeyEdit>();
                    if (ret.ErrCode == 0)
                    {//修改成功
                        response.Status = HttpStatusCode.OK;
                        //如果修改成功,则保存用户名
                        if (string.IsNullOrEmpty(ukeyModel.InsuranceUserName))
                        {
                            ukeyModel.InsuranceUserName = request.UserCode;
                            int u = _iagentAgentUKeyRepository.UpdateModel(ukeyModel);
                            logInfo.Info(string.Format("修改保司密码成功,数据库修改{0}条记录。", u));
                        }
                    }
                    else
                    {
                        //修改失败
                        response.ErrCode = -1;
                        response.ErrMsg  = ret.ErrMsg;
                    }
                }
            }
            catch (Exception ex)
            {
                response        = new BaseResponse();
                response.Status = HttpStatusCode.ExpectationFailed;
                logError.Info("修改保司密码请求发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException + ",返回对象信息:" + request.ToJson());
            }
            return(response);
        }
        public SmsResultViewModel SendSms(SmsRequest request, IEnumerable <KeyValuePair <string, string> > pairs)
        {
            var response = new SmsResultViewModel();

            //参数校验
            //获取顶级经纪人信息
            bx_agent agentModel = _agentRepository.GetAgent(request.Agent);
            //获取当前经纪人信息
            bx_agent curagentModel = _agentRepository.GetAgent(request.CurAgent);

            if (agentModel == null || curagentModel == null)
            {
                response.Status = HttpStatusCode.Forbidden;
                return(response);
            }
            if (!ValidateReqest(pairs, agentModel.SecretKey, request.SecCode))
            {
                response.Status = HttpStatusCode.Forbidden;
                return(response);
            }
            if ((int)request.BusinessType == 3 && string.IsNullOrWhiteSpace(request.LicenseNo))
            {
                response.Status = HttpStatusCode.UnsupportedMediaType;
                return(response);
            }

            bool isByTopAgent   = IsPayByTopAgent(request.CurAgent); //true为走顶级代理人账户,否则走当前账户
            int  sendAgent      = 0;                                 //以哪个代理人id创建
            int  messagePayType = 0;

            //当前代理人是顶级代理人可以充值
            if (isByTopAgent)
            {//顶级
                sendAgent      = request.Agent;
                messagePayType = agentModel.MessagePayType.HasValue?agentModel.MessagePayType.Value:0;
            }
            else
            {//当前代理
                sendAgent      = request.CurAgent;
                messagePayType = curagentModel.MessagePayType.HasValue ? curagentModel.MessagePayType.Value : 0;
            }

            //获取代理人的短信信息
            var smsAcount = _smsContentRepository.Find(sendAgent);

            if (smsAcount == null)
            {
                response.MessagePayType = messagePayType;
                response.Status         = HttpStatusCode.NoContent;
                return(response);
            }
            string posturl  = string.Format("{0}/{1}", _smsCenter, _smsCenterSendSmsMethod);
            string postData = string.Format("account={0}&password={1}&mobile={2}&smscontent={3}&businessType={4}",
                                            smsAcount.sms_account, smsAcount.sms_password, request.Mobile, request.SmsContent, (int)request.BusinessType);
            string result;

            try
            {
                int ret = HttpWebAsk.Post(posturl, postData, out result);
                //result = "{\"ResponseType\":\"SubmitSms\",\"TradeTime\":\"2016-05-19 19:35:03\",\"ResultCode\":0,\"Message\":\"提交成功!\"}";
                if (!string.IsNullOrEmpty(result))
                {
                    var smsResult = result.FromJson <SmsResultModel>();
                    if (smsResult.ResultCode == 0)
                    {
                        //调取后台接口,将短信发送内容保存到bx_sms_account_content
                        string getData = string.Format("agent_id={0}&sent_mobile={1}&content={2}&agent_name={3}&sent_type={4}&&businessType={5}&license_no={6}",
                                                       sendAgent, request.Mobile, request.SmsContent, curagentModel.AgentName, request.SentType, (int)request.BusinessType, request.LicenseNo);
                        string getUrl = _smsSqlInterfaceUrl + getData;
                        logInfo.Info(string.Format("短信内容入库请求串:{0}", getUrl));
                        //string getResult = HttpWebAsk.HttpGet(getUrl);
                        string insertsms = string.Empty;
                        int    insertret = HttpWebAsk.Post(_smsSqlInterfaceUrl, getData, out insertsms);
                        logInfo.Info(string.Format("短信内容入库返回结果:{0}", insertsms));

                        response.BusinessStatus = 1;
                        response.MessagePayType = messagePayType;
                        response.StatusMessage  = "短信发送成功";
                        response.SmsResultModel = smsResult;
                    }
                    else
                    {
                        response.BusinessStatus = 0;
                        response.MessagePayType = messagePayType;
                        response.StatusMessage  = smsResult.Message;
                    }
                }
                else
                {
                    response.BusinessStatus = 0;
                    response.MessagePayType = messagePayType;
                    response.StatusMessage  = "短信发送失败";
                }
            }
            catch (Exception ex)
            {
                response = new SmsResultViewModel();
                response.MessagePayType = messagePayType;
                response.Status         = HttpStatusCode.ExpectationFailed;
                logError.Info("短信请求发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }
            return(response);
        }