Пример #1
0
        public List <MerchantProfile> GetMerchantVerifyListL2(string cellphone, int countryId, int?status, string orderByFiled, bool isDesc, int pageSize, int index, out int totalCount)
        {
            totalCount = 0;
            GetMerchnatVerifyListIM input = new GetMerchnatVerifyListIM();

            input.cellphone    = cellphone;
            input.countryId    = countryId;
            input.status       = status;
            input.orderByFiled = orderByFiled;
            input.isDesc       = isDesc;
            input.pageSize     = pageSize;
            input.index        = index;

            var url   = $"{baseAddress}/GetMerchantVerifyListL2";
            var param = JsonConvert.SerializeObject(input);

            _log.Info("GetMerchantVerifyListL2 url = " + url);
            _log.Info("GetMerchantVerifyListL2 input = " + param);
            _log.Info("GetMerchantVerifyListL2 headers = " + JsonConvert.SerializeObject(headers));

            var result = RestUtilities.PostJson(url, headers, param);

            _log.Info("GetMerchantVerifyListL2 result = " + result);
            var data = JsonConvert.DeserializeObject <ServiceResult <GetMerchnatVerifyListOM> >(result);

            if (data.Code == 0)
            {
                totalCount = data.Data.TotalCount;
                return(data.Data.ResultSet);
            }
            throw new CommonException(10000, data.Message);
        }
Пример #2
0
        public bool ValidateAddress(string cryptoCode, string address)
        {
            var url = $"{URL}/ValidateAddress";

            _log.Info($"URL--{url}");
            var parameters = new
            {
                Address    = address,
                CryptoName = cryptoCode
            };
            var dic = new Dictionary <string, string> {
                { "Authorization", "Bearer " + GenerateToken() }
            };
            var paramString = JsonConvert.SerializeObject(parameters);

            _log.Info($"Parameters--{paramString}");
            var result = RestUtilities.PostJson(url, dic, paramString);

            _log.Info($"Result--{result}");

            var data = JsonConvert.DeserializeObject <ServiceResult <bool?> >(result);

            if (data.Code == 0)
            {
                return(data.Data ?? false);
            }

            throw new CommonException(data.Code, data.Message);
        }
Пример #3
0
        public WalletAddressInfo CreateWallet(string cryptoCode, Guid accountId, AccountTypeEnum accountType, string email = null, string cellphone = null)
        {
            var url = $"{URL}/Wallet/Create";

            _log.Info($"URL--{url}");

            var parameters = new
            {
                CryptoName  = cryptoCode,
                AccountID   = accountId,
                AccountType = accountType,
                Email       = email,
                Cellphone   = cellphone
            };
            var paramString = JsonConvert.SerializeObject(parameters);

            _log.Info($"Parameters--{paramString}");

            var dic = new Dictionary <string, string> {
                { "Authorization", "Bearer " + GenerateToken() }
            };

            var result = RestUtilities.PostJson(url, dic, paramString);

            _log.Info($"Result--{result}");

            var data = JsonConvert.DeserializeObject <ServiceResult <WalletAddressInfo> >(result);

            if (data.Code == 0)
            {
                return(data.Data);
            }
            throw new CommonException(10000, data.Message);
        }
Пример #4
0
        public DepositStatusInfo GetDepositStatus(long requestId)
        {
            var url = $"{URL}/Wallet/Deposit/GetStatus";

            _log.Info($"URL--{url}");

            var parameters = new
            {
                DepositRequestId = requestId
            };

            var dic = new Dictionary <string, string> {
                { "Authorization", "Bearer " + GenerateToken() }
            };
            var paramString = JsonConvert.SerializeObject(parameters);

            _log.Info($"Parameters--{paramString}");
            var result = RestUtilities.PostJson(url, dic, paramString);

            _log.Info($"Result--{result}");

            var data = JsonConvert.DeserializeObject <ServiceResult <DepositStatusInfo> >(result);

            if (data.Code == 0)
            {
                return(data.Data);
            }
            throw new CommonException(10000, data.Message);
        }
Пример #5
0
        /// <summary>
        /// 发送邮件
        /// </summary>
        /// <param name="recipients">收件人,支持多收件人,使用逗号分割</param>
        /// <param name="subject">标题</param>
        /// <param name="content">内容</param>
        /// <returns>是否成功</returns>
        public bool Send(string recipients, string subject, string content)
        {
            var    model      = new { Recipients = recipients, Subject = subject, Content = content, Merchant = "FiiiLab", SendLevel = 5 };
            string url        = ConfigurationManager.AppSettings["FP_EMAIL_API__URL"];
            string emailToken = ConfigurationManager.AppSettings["Email_Token"];

            RestUtilities.PostJson($"{url}/api/Message/PostEmail", new Dictionary <string, string> {
                { "bearer", emailToken }
            }, JsonConvert.SerializeObject(model));
            return(true);
        }
Пример #6
0
        public bool UpdateLicenseInfo(MerchantLicenseInfo model)
        {
            var url    = $"{baseAddress}/UpdateLicenseInfo";
            var result = RestUtilities.PostJson(url, headers, JsonConvert.SerializeObject(model));
            var data   = JsonConvert.DeserializeObject <ServiceResult <bool> >(result);

            if (data.Code == 0)
            {
                return(data.Data);
            }
            throw new CommonException(10000, data.Message);
        }
Пример #7
0
        public bool Delete(MerchantProfile profile)
        {
            var url    = $"{baseAddress}/RemoveMerchant";
            var result = RestUtilities.PostJson(url, headers, JsonConvert.SerializeObject(profile));
            var data   = JsonConvert.DeserializeObject <ServiceResult <bool> >(result);

            if (data.Code == 0)
            {
                return(data.Data);
            }
            throw new CommonException(10000, data.Message);
        }
Пример #8
0
        internal bool ModifyAddress1(MerchantProfile profile)
        {
            var url      = $"{baseAddress}/ModifyAddress1";
            var paramStr = JsonConvert.SerializeObject(profile);
            var result   = RestUtilities.PostJson(url, headers, paramStr);

            _log.Info($"url: {url},param: {paramStr},  result: {result}");

            var data = JsonConvert.DeserializeObject <ServiceResult <bool> >(result);

            if (data.Code == 0)
            {
                return(data.Data);
            }
            throw new CommonException(10000, data.Message);
        }
Пример #9
0
        public bool UpdatePhoneNumber(Guid id, string cellphone)
        {
            UpdatePhoneNumberIM input = new UpdatePhoneNumberIM()
            {
                Id = id, Cellphone = cellphone
            };
            var url    = $"{baseAddress}/UpdatePhoneNumber";
            var result = RestUtilities.PostJson(url, headers, JsonConvert.SerializeObject(input));
            var data   = JsonConvert.DeserializeObject <ServiceResult <bool> >(result);

            if (data.Code == 0)
            {
                return(data.Data);
            }
            throw new CommonException(10000, data.Message);
        }
Пример #10
0
        public UserVerifiedStatus GetVerifiedStatus(Guid id)
        {
            var url = $"{baseAddress}/GetVerifiedStatus";
            var obj = new
            {
                Id = id
            };
            var result = RestUtilities.PostJson(url, headers, JsonConvert.SerializeObject(obj));
            var data   = JsonConvert.DeserializeObject <ServiceResult <UserVerifiedStatus> >(result);

            if (data.Code == 0)
            {
                return(data.Data);
            }
            throw new CommonException(10000, data.Message);
        }
Пример #11
0
        public MerchantProfile GetById(Guid id)
        {
            var url = $"{baseAddress}/GetById";
            var obj = new
            {
                Id = id
            };
            var result = RestUtilities.PostJson(url, headers, JsonConvert.SerializeObject(obj));
            var data   = JsonConvert.DeserializeObject <ServiceResult <MerchantProfile> >(result);

            if (data.Code == 0)
            {
                return(data.Data);
            }
            throw new CommonException(10000, data.Message);
        }
Пример #12
0
        public List <MerchantProfile> GetListByIds(List <Guid> ids)
        {
            var url = $"{baseAddress}/GetListByIds";
            var obj = new GuidsIM
            {
                Guids = ids
            };
            var result = RestUtilities.PostJson(url, headers, JsonConvert.SerializeObject(obj));
            var data   = JsonConvert.DeserializeObject <ServiceResult <List <MerchantProfile> > >(result);

            if (data.Code == 0)
            {
                return(data.Data);
            }
            throw new CommonException(10000, data.Message);
        }
Пример #13
0
        internal bool UpdateL2VerifyStatus(Guid id, VerifyStatus verifyStatus, string remark)
        {
            var url = $"{baseAddress}/UpdateL2VerifyStatus";
            UpdateVerifyStatusIM im = new UpdateVerifyStatusIM()
            {
                Id = id, VerifyStatus = verifyStatus, Remark = remark
            };
            var result = RestUtilities.PostJson(url, headers, JsonConvert.SerializeObject(im));
            var data   = JsonConvert.DeserializeObject <ServiceResult <bool> >(result);

            if (data.Code == 0)
            {
                return(data.Data);
            }
            throw new CommonException(10000, data.Message);
        }
Пример #14
0
        public bool SetGenderById(Guid id, int type)
        {
            var url = $"{baseAddress}/SetGenderById";
            var obj = new
            {
                Id   = id,
                Type = type
            };
            var result = RestUtilities.PostJson(url, headers, JsonConvert.SerializeObject(obj));
            var data   = JsonConvert.DeserializeObject <ServiceResult <bool> >(result);

            if (data.Code == 0)
            {
                return(data.Data);
            }
            throw new CommonException(10000, data.Message);
        }
Пример #15
0
        public bool UpdateBirthday(Guid id, DateTime date)
        {
            var url = $"{baseAddress}/UpdateBirthday";
            var obj = new
            {
                Id   = id,
                Date = date
            };
            var result = RestUtilities.PostJson(url, headers, JsonConvert.SerializeObject(obj));
            var data   = JsonConvert.DeserializeObject <ServiceResult <bool> >(result);

            if (data.Code == 0)
            {
                return(data.Data);
            }
            throw new CommonException(10000, data.Message);
        }
Пример #16
0
        internal int GetCountByIdentityDocNo(string IdentityDocNo)
        {
            var url = $"{baseAddress}/GetCountByIdentityDocNo";
            var obj = new
            {
                IdentityDocNo = IdentityDocNo
            };
            var result = RestUtilities.PostJson(url, headers, JsonConvert.SerializeObject(obj));
            var data   = JsonConvert.DeserializeObject <ServiceResult <int> >(result);

            if (data.Code == 0)
            {
                return(data.Data);
            }
            _log.Error($"RPC get by id={IdentityDocNo} result " + result);
            throw new CommonException(10000, data.Message);
        }
Пример #17
0
        public string PostToGateway(string apiName, Dictionary <string, string> dicParams)
        {
            string baseUrl   = ConfigurationManager.AppSettings["Gateway_URL"];
            string clientKey = ConfigurationManager.AppSettings["GatewayClientKey"];
            string secretKey = ConfigurationManager.AppSettings["GatewaySecretKey"];

            string strParams  = JsonConvert.SerializeObject(dicParams);
            string strHttpUrl = $"{baseUrl.TrimEnd('/')}/{apiName.TrimStart('/')}";

            Dictionary <string, string> header = new Dictionary <string, string>();

            header.Add("Content-Type", "application/json");
            header.Add("Authorization", "bearer " + GenerateToken(clientKey, secretKey));

            string result = RestUtilities.PostJson(strHttpUrl, header, strParams);

            return(result);
        }
Пример #18
0
        public string Upload(string fileName, byte[] bytes)
        {
            var url = _router.ServerAddress + "/File/Upload";

            var json = JsonConvert.SerializeObject(new
            {
                FileName = fileName,
                File     = bytes,
                FileType = "img"
            });
            var result = RestUtilities.PostJson(url, GetHeaders(), json);
            var data   = JsonConvert.DeserializeObject <ServiceResult <string> >(result);

            if (data.Code != 0)
            {
                throw new CommonException(ReasonCode.GENERAL_ERROR, data.Message);
            }
            return(data.Data);
        }
Пример #19
0
        public bool UpdateIdImage(Guid id, Guid frontImage, Guid backImage, Guid handHoldImage)
        {
            var url = $"{baseAddress}/UpdateIdImage";
            var obj = new
            {
                Id            = id,
                FrontImage    = frontImage,
                BackImage     = backImage,
                HandHoldImage = handHoldImage
            };
            var result = RestUtilities.PostJson(url, headers, JsonConvert.SerializeObject(obj));
            var data   = JsonConvert.DeserializeObject <ServiceResult <bool> >(result);

            if (data.Code == 0)
            {
                return(data.Data);
            }
            throw new CommonException(10000, data.Message);
        }
Пример #20
0
        public bool UpdateAddress(Guid merchantId, string postCode, string address1, string address2)
        {
            var url = $"{baseAddress}/UpdateAddress";
            var obj = new
            {
                Id       = merchantId,
                PostCode = postCode,
                Address1 = address1,
                Address2 = address2
            };
            var result = RestUtilities.PostJson(url, headers, JsonConvert.SerializeObject(obj));
            var data   = JsonConvert.DeserializeObject <ServiceResult <bool> >(result);

            if (data.Code == 0)
            {
                return(data.Data);
            }
            throw new CommonException(10000, data.Message);
        }
Пример #21
0
        public bool UpdateMerchantLicense(Guid merchantId, string companyName, string licenseNo, Guid businessLicense)
        {
            var url = $"{baseAddress}/UpdateMerchantLicense";
            var obj = new UpdateMerchantLicenseIM()
            {
                MerchantId      = merchantId,
                CompanyName     = companyName,
                LicenseNo       = licenseNo,
                BusinessLicense = businessLicense
            };
            var result = RestUtilities.PostJson(url, headers, JsonConvert.SerializeObject(obj));

            var data = JsonConvert.DeserializeObject <ServiceResult <bool> >(result);

            if (data.Code == 0)
            {
                return(data.Data);
            }
            throw new CommonException(10000, data.Message);
        }
Пример #22
0
        private UserProfile GetProfileByAccountId(ProfileRouter router, Guid id)
        {
            var url = $"{router.ServerAddress}/User/GetById";

            System.Collections.Generic.Dictionary <string, string> headers = new System.Collections.Generic.Dictionary <string, string>();
            var token = GenerateToken(router);

            headers.Add("Authorization", "Bearer " + token);
            var obj = new
            {
                Id = id
            };
            var result = RestUtilities.PostJson(url, headers, JsonConvert.SerializeObject(obj));
            var data   = JsonConvert.DeserializeObject <ServiceResult <UserProfile> >(result);

            if (data.Code == 0)
            {
                return(data.Data);
            }
            throw new CommonException(10000, data.Message);
        }
Пример #23
0
        public byte[] Delete(string id)
        {
            if (string.IsNullOrEmpty(blob_URL))
            {
                throw new ArgumentException("Blob_URL not found");
            }

            var url   = blob_URL.TrimEnd('/') + "/File/Delete";
            var token = GenerateToken();

            try
            {
                var json = JsonConvert.SerializeObject(new
                {
                    Id = id
                });
                var resultStr = RestUtilities.PostJson(url, new Dictionary <string, string> {
                    { "Authorization", "bearer " + token }
                }, json);

                if (string.IsNullOrWhiteSpace(resultStr))
                {
                    _log.ErrorFormat("Delete master image error. url = {0},id = {1}", url, id);
                    return(null);
                }
                var responseJson = JsonConvert.DeserializeObject <ServiceResult <object> >(resultStr);
                if (responseJson.Code != 0)
                {
                    throw new ApplicationException(responseJson.Message);
                }
                var b = Convert.FromBase64String(responseJson.Data.ToString());
                return(b);
            }
            catch (Exception exception)
            {
                _log.Error(exception);
            }

            return(null);
        }
Пример #24
0
        /// <summary>
        /// 上传图片,同时生成缩略图
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="bytes"></param>
        /// <returns></returns>
        public Guid[] UploadWithThumbnail(string fileName, byte[] bytes)
        {
            if (string.IsNullOrEmpty(blob_URL))
            {
                throw new ArgumentException("Blob_URL not found");
            }

            var url   = blob_URL.TrimEnd('/') + "/File/UploadWithThumbnail";
            var token = GenerateToken();
            var json  = JsonConvert.SerializeObject(new
            {
                FileName = fileName,
                File     = bytes,
                FileType = "img"
            });
            var result = RestUtilities.PostJson(url, new Dictionary <string, string> {
                { "Authorization", "bearer " + token }
            }, json);
            var data = JsonConvert.DeserializeObject <ServiceResult <Guid[]> >(result);

            return(data.Code == 0 ? data.Data : null);
        }
Пример #25
0
        public List <UserProfile> GetUserProfileListForL2(string cellphone, int country, string orderByFiled, bool isDesc, int?l2VerifyStatus, int pageSize, int index, out int totalCount)
        {
            UserProfileListIM input = new UserProfileListIM();

            input.Cellphone    = cellphone;
            input.Country      = country;
            input.OrderByFiled = orderByFiled;
            input.IsDesc       = isDesc;
            input.VerifyStatus = l2VerifyStatus;
            input.PageSize     = pageSize;
            input.Index        = index;
            var url = $"{baseAddress}/GetUserProfileListForL2";

            var result = RestUtilities.PostJson(url, headers, JsonConvert.SerializeObject(input));
            var data   = JsonConvert.DeserializeObject <ServiceResult <UserProfileListOM> >(result);

            if (data.Code == 0)
            {
                totalCount = data.Data.TotalCount;
                return(data.Data.ResultSet);
            }
            throw new CommonException(10000, data.Message);
        }
Пример #26
0
        public void Notification(string message, bool reNotification = false)
        {
            lock (_lock)
            {
                if (string.IsNullOrWhiteSpace(_notificationUrl))
                {
                    _log.Error("Invalid Noification URL");
                    return;
                }

                var notificationModel = JsonConvert.DeserializeObject <NotificationModel>(message);

                var mallDac = new MallPaymentOrderDAC();
                if (notificationModel.Type == TradeType.Payment)
                {
                    var status = mallDac.HasNotifiation(notificationModel.MallId);

                    if (status)
                    {
                        return;
                    }
                }
                else
                {
                    var status = mallDac.RefundHasNotifiation(notificationModel.MallId);

                    if (status)
                    {
                        return;
                    }
                }

                var sendNotification = JsonConvert.SerializeObject(new
                {
                    notificationModel.OrderId,
                    Type = Enum.GetName(typeof(TradeType), notificationModel.Type),
                    notificationModel.TradeNo,
                    notificationModel.Status
                });

                var result = "";
                try
                {
                    result = RestUtilities.PostJson(_notificationUrl,
                                                    new Dictionary <string, string>
                    {
                        { "FiiiPay", ConfigurationManager.AppSettings.Get("CallbackKey") }
                    }, sendNotification);
                    _log.InfoFormat("Notification {0} params {1},result {2}", notificationModel.OrderId,
                                    sendNotification, result);
                }
                catch (Exception exception)
                {
                    _log.ErrorFormat("Notification error {0}, param {1}", exception.Message, message);

                    mallDac.UpdateNotificationSource(notificationModel.MallId, message);
                }

                if (result.StartsWith("ok"))
                {
                    if (notificationModel.Type == TradeType.Payment)
                    {
                        mallDac.UpdateNotification(notificationModel.MallId);
                    }
                    else if (notificationModel.Type == TradeType.Refund)
                    {
                        mallDac.UpdateRefundNotification(notificationModel.MallId);
                    }
                }
                else
                {
                    if (!reNotification)
                    {
                        mallDac.UpdateNotificationSource(notificationModel.MallId, message);
                    }
                }
            }
        }