Ejemplo n.º 1
0
        public IHttpActionResult payreal([FromBody] payExInfo_DTO value)
        {
            API_Message   message = new API_Message();
            payExInfo_DTO dto     = new payExInfo_DTO();

            dto = value;
            Guid payguid = Guid.NewGuid();

            message.MessageCode = "1";
            //string test = JsonConvert.SerializeObject(value);
            //int len = test.Length;
            string reStr = "";

            if (ModelState.IsValid)
            {
                try
                {
                    //WebClient client = new WebClient();
                    //client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
                    //byte[] reByte = client.UploadData("https://swapptest.singlewindow.cn/ceb2grab/grab/realTimeDataUpload", Encoding.UTF8.GetBytes("payExInfoStr=" + WebUtility.UrlEncode(JsonConvert.SerializeObject(value))));
                    //reStr = Encoding.UTF8.GetString(reByte);
                    //_ILog4netHelper.WriteLog_Info<PayController>(reStr, null, "payreal", null);
                    //message.ErrorMsg = reStr;

                    dto.payguid = payguid;
                    //value.payExchangeInfoHead.guid = payguid;
                    //dto.payExchangeInfoHead = new List<payExchangeInfoHead>() { value.payExchangeInfoHead };
                    dto.payExchangeInfoHead = value.payExchangeInfoHead;
                    dto.payExchangeInfoHead.ForEach(t => t.guid = payguid);
                    dto.payExchangeInfoLists = value.payExchangeInfoLists;
                    dto.serviceTime          = value.serviceTime;
                    dto.payExchangeInfoLists.ForEach(t => t.listguid = payguid);
                    dto.sessionID  = value.sessionID;
                    dto.certNo     = value.certNo;
                    dto.signValue  = value.signValue;
                    dto.is_success = value.is_success;
                    dto.type       = 1;
                    _ILog4netHelper.WriteLog_Info <PayController>(JsonConvert.SerializeObject(dto), null, "支付信息-from ecmall", null);
                    _IpayExInfoRepository.payExInfo_Save(dto);
                    if (value.is_success == "1")
                    {
                        payExInfoOmsViewModel model = new payExInfoOmsViewModel();
                        model.Orderno = dto.payExchangeInfoLists != null ? dto.payExchangeInfoLists[0].orderNo:"";
                        model.PaymentMethodSystemName = value.payment_type;
                        model.PayTransactionId        = dto.payExchangeInfoHead[0].payTransactionId;
                        _IRabbitMQHelper.Publish <PayController>(JsonConvert.SerializeObject(model));
                    }
                }
                catch (Exception ex)
                {
                    message.MessageCode = "2";
                    _ILog4netHelper.WriteLog_Info <PayController>(reStr, null, "支付信息-from ecmall", ex);
                }
            }
            else
            {
                message.MessageCode = "2";
                _ILog4netHelper.WriteLog_Waring <PayController>(reStr, null, "支付信息-from ecmall", null);
            }
            return(Json(message));
        }
Ejemplo n.º 2
0
        public IHttpActionResult realTimeDataUp([FromBody] payExInfo value)
        {
            API_Message   message = new API_Message();
            payExInfo_DTO dto     = new payExInfo_DTO();
            Guid          payguid = Guid.NewGuid();

            dto.payguid = payguid;
            string reStr = "";

            try
            {
                dto.payExchangeInfoHead = new List <payExchangeInfoHead>()
                {
                    value.payExchangeInfoHead
                };
                dto.payExchangeInfoLists = value.payExchangeInfoLists;
                dto.serviceTime          = value.serviceTime;
                dto.payExchangeInfoLists.ForEach(t => t.listguid = payguid);
                dto.sessionID = value.sessionID;
                dto.certNo    = value.certNo;
                dto.signValue = value.signValue;
                dto.type      = 2;
                _IpayExInfoRepository.payExInfo_Save(dto);
                message.MessageCode = "1";
                string test = JsonConvert.SerializeObject(value);
                int    len  = test.Length;
            }
            catch (Exception ex)
            {
                message.MessageCode = "2";
                message.ErrorMsg    = ex.InnerException.Message.ToString();
            }
            if (ModelState.IsValid)
            {
                try
                {
                    //using (HttpClient client = new HttpClient())
                    //{
                    //    client.BaseAddress = new Uri("https://swapptest.singlewindow.cn/ceb2grab/grab/realTimeDataUpload");
                    //    var content = new FormUrlEncodedContent(new[] { new KeyValuePair<string, string>("payExInfoStr", JsonConvert.SerializeObject(value).ToString())});
                    //    var result = client.PostAsync("", content).Result;
                    //    reStr = result.Content.ReadAsStringAsync().Result;
                    //}
                    //value.signValue = "ptWZR+klQ4JlP1jXiA329RLqoJUxmyqQ4XVqZ7m+GTSwYRRur9R1s3NwG31+vG+ZPV89jHlyuMJ1vreNDea5bVUqJDxx3u083pTNHjiYyPyQjPO7C6Gagum5olUV4Z2hk0WcUMge0sDPkNkjrr1oOM/W19LxVUqEOkLVEr755RA=";
                    WebClient client = new WebClient();
                    client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
                    //https://customs.chinaport.gov.cn/ceb2grab/grab/realTimeDataUpload    //海关正式的地址
                    //https://swapptest.singlewindow.cn/ceb2grab/grab/realTimeDataUpload   //海关联调的地址
                    byte[] reByte = client.UploadData("https://customs.chinaport.gov.cn/ceb2grab/grab/realTimeDataUpload ", "POST", Encoding.UTF8.GetBytes("payExInfoStr=" + WebUtility.UrlEncode(JsonConvert.SerializeObject(value))));
                    reStr = Encoding.UTF8.GetString(reByte);
                    _ILog4netHelper.WriteLog_Info <customrealpayController>(reStr, null, "realTimeDataUp", null);
                    _ILog4netHelper.WriteLog_Info <customrealpayController>("customs.chinaport.gov.cn/ceb2grab/grab/realTimeDataUpload 海关正式的地址", null, "realTimeDataUp", null);
                    message.ErrorMsg = reStr;
                }
                catch (Exception ex)
                {
                    message.MessageCode = "2";
                    _ILog4netHelper.WriteLog_Info <customrealpayController>(reStr, null, "realTimeDataUp", ex);
                }
            }
            else
            {
                message.MessageCode = "2";
                _ILog4netHelper.WriteLog_Waring <customrealpayController>(reStr, null, "realTimeDataUp", null);
            }
            return(Json(message));
        }