Esempio n. 1
0
        public SingleBonusDetailOM GetSingleBonusDetail(int im)
        {
            var pfDAC  = new ProfitDetailDAC();
            var detail = pfDAC.GetBonusDetailById(im);
            var coin   = new CryptocurrencyDAC().GetById(detail.CryptoId);
            var code   = coin.Code;

            string statusStr = "";

            if (detail.Status == InviteStatusType.IssuedActive)
            {
                statusStr = Resources.DepositConfirmed;
            }
            else if (detail.Status == InviteStatusType.IssuedFrozen)
            {
                statusStr = Resources.DepositPending;
            }

            //暂时只考虑一种状况
            return(new SingleBonusDetailOM()
            {
                Type = SingleBonusDetailOM.BonusType.BonusIncome,
                TypeStr = Resources.BonusIncome,
                TradeDescription = Resources.BonusDescription,
                BonusFrom = Resources.BonusComeFrom,
                Status = detail.Status,
                StatusStr = statusStr,
                CryptoCode = code,
                Timestamp = detail.Timestamp.ToUnixTime().ToString(),
                OrderNo = detail.OrderNo,
                Amount = detail.CryptoAmount.ToString(coin.DecimalPlace)
            });
        }
        public void PushInviteSuccess(long id)
        {
            var pfDAC     = new ProfitDetailDAC();
            var accountId = pfDAC.GetAccountId(id);

            var regId = RedisHelper.StringGet($"FiiiPay:Notice:UserId:{accountId}");

            var    lang        = RedisHelper.StringGet(REDIS_LANGUAGE_DBINDEX, $"FiiiPay:Language:{accountId}") ?? "en";
            string titleKey    = "奖励FIII";
            string subTitleKey = "奖励子标题";

            if (!(_resourcePropertyNames.Contains(titleKey) && _resourcePropertyNames.Contains(subTitleKey)))
            {
                throw new Exception("没有找到资源");
            }
            var title    = ResourceHelper.FiiiPay.GetResource(titleKey, new CultureInfo(lang));
            var subTitle = ResourceHelper.FiiiPay.GetResource(subTitleKey, new CultureInfo(lang));

            string noticeId = "";

            MessagesComponent.AddMessage(accountId, UserType.User, id.ToString(), FiiiPayPushType.TYPE_INVITE_REWARD, titleKey, subTitleKey, "FIII", title, subTitle, out noticeId);

            RegPush(FiiiPayPushType.TYPE_INVITE_REWARD, new List <string> {
                regId
            }, id, title, subTitle, noticeId);
            LogHelper.Info($"--------{lang}------{title}----------{subTitle}");
        }
Esempio n. 3
0
        public int GetCurrentRank(SystemPlatform platform, UserAccount account)
        {
            var totalProfitAmount = new ProfitDetailDAC().GetUserBonusTotalAmount(account, (int)platform);

            if (totalProfitAmount == 0m)
            {
                return(-1);
            }
            return(new InviteRecordDAC().GetUserRanking(account.Id, (int)platform));
        }
Esempio n. 4
0
        /// <summary>
        /// 获取分红的详细信息
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public FiiiposProfitDetailRecordOM FiiiposMoreDetail(FiiiposBonusRecordIM im, UserAccount account)
        {
            var iDAC  = new InviteRecordDAC();
            var pfDAC = new ProfitDetailDAC();
            var data  = iDAC.GetDetailByAccountId(im.MerchantId);

            return(new FiiiposProfitDetailRecordOM()
            {
                Data = pfDAC.GetFiiiposBonusRecords(data.Id, account).Select(item => new FiiiposProfitDetailRecordOM.BonusDetail()
                {
                    CryptoAmount = item.CryptoAmount.ToString(8),
                    Timestamp = item.Timestamp.ToUnixTime().ToString()
                }).ToList(),
                MerchantName = im.MerchantName,
                TotalAmount = im.TotalCryptoAmount.ToString(8)
            });
        }
        public void PushInviteSuccess(long id)
        {
            var pfDAC     = new ProfitDetailDAC();
            var accountId = pfDAC.GetAccountId(id);

            var    regId       = RedisHelper.StringGet($"{FiiiPOS_APP_Notice_MerchantId}:{accountId}");
            var    lang        = RedisHelper.StringGet(REDIS_LANGUAGE_DBINDEX, $"{FiiiPOS_APP_Language_MerchantId}:{accountId}") ?? "en";
            string titleKey    = "奖励FIII";
            string subTitleKey = "奖励子标题";
            var    title       = ResourceHelper.FiiiPos.GetResource(titleKey, new CultureInfo(lang));
            var    subTitle    = ResourceHelper.FiiiPos.GetResource(subTitleKey, new CultureInfo(lang));

            string noticeId = "";

            MessagesComponent.AddMessage(accountId, UserType.User, id.ToString(), FiiiPayPushType.TYPE_INVITE_REWARD, titleKey, subTitleKey, "FIII", title, subTitle, out noticeId);

            RegPush(FiiiPayPushType.TYPE_INVITE_REWARD, new List <string> {
                regId
            }, id, title, subTitle, noticeId);
            LogHelper.Info($"--------{lang}------{title}----------{subTitle}");
        }
Esempio n. 6
0
        /// <summary>
        /// 插入记录
        /// </summary>
        /// <param name="inviteCode">邀请码</param>
        /// <param name="accoundId">被邀请人id</param>
        /// /// <param name="type">1:fiiipay 2:fiiipos</param>
        public void InsertRecord(InviteRecordIM im)
        {
            //判断是fiiipos还是fiiipay

            //1 插入数据 invite profit两个表 邀请双方都支持插入数据 钱包 流水进行更新
            // 判断当前邀请人数到达五十 进行推送。。。。。。。。。。。。

            //2 插入数据 invite
            if (!(im.Type == (int)SystemPlatform.FiiiPay || im.Type == (int)SystemPlatform.FiiiPOS))
            {
                throw new ArgumentException("只支持fiiipay和fiiipos邀请");
            }
            var userAccountDAC    = new UserAccountDAC();
            var account           = userAccountDAC.GetByInvitationCode(im.InvitationCode);
            var settingCollection = new MasterSettingDAC().SelectByGroup("InviteReward");
            var cryptoCurrencty   = new CryptocurrencyDAC().GetByCode("FIII");
            var cryptoId          = cryptoCurrencty.Id;

            if (im.Type == (int)SystemPlatform.FiiiPay)
            {
                var iDAC        = new InviteRecordDAC();
                var pfDAC       = new ProfitDetailDAC();
                var uwComponent = new UserWalletComponent();

                var uwDAC  = new UserWalletDAC();
                var uwsDAC = new UserWalletStatementDAC();
                var utDAC  = new UserTransactionDAC();

                var inviteMoney  = decimal.Parse(settingCollection.Where(item => item.Name == "Invite_Reward_Amount").Select(item => item.Value).FirstOrDefault());
                var rewardMoney  = decimal.Parse(settingCollection.Where(item => item.Name == "Over_People_Count_Reward_Amount").Select(item => item.Value).FirstOrDefault());
                var maxCount     = decimal.Parse(settingCollection.Where(item => item.Name == "Max_Reward_Amount").Select(item => item.Value).FirstOrDefault());
                var orderNo1     = CreateOrderno();
                var orderNo2     = CreateOrderno();
                var inviteWallet = uwComponent.GetUserWallet(account.Id, cryptoId);
                if (inviteWallet == null)
                {
                    inviteWallet = uwComponent.GenerateWallet(account.Id, cryptoId);
                }

                var beInvitedWallet = uwComponent.GetUserWallet(im.BeInvitedAccountId, cryptoId);
                if (beInvitedWallet == null)
                {
                    beInvitedWallet = uwComponent.GenerateWallet(im.BeInvitedAccountId, cryptoId);
                }

                int     inviteId;
                long    profitId1    = 0; //邀请人奖励ID
                long    profitId2    = 0; //被邀请人奖励ID
                long    exProfitId1  = 0; //邀请人额外奖励ID
                decimal totalReward  = pfDAC.GetTotalReward(account);
                int     invitedCount = pfDAC.GetInvitedCount(account);

                using (var scope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, new TimeSpan(0, 0, 1, 30)))
                {
                    //插入数据到inviterecord表中
                    inviteId = iDAC.Insert(new InviteRecord()
                    {
                        Type = (InviteType)im.Type, AccountId = im.BeInvitedAccountId, Timestamp = DateTime.UtcNow, InviterCode = im.InvitationCode, InviterAccountId = account.Id
                    });

                    if (totalReward < maxCount)
                    {
                        profitId1 = pfDAC.Insert(new ProfitDetail()
                        {
                            InvitationId = inviteId,
                            CryptoAmount = inviteMoney,
                            AccountId    = account.Id,
                            Status       = InviteStatusType.IssuedFrozen,
                            Type         = ProfitType.InvitePiiiPay,
                            OrderNo      = orderNo1,
                            Timestamp    = DateTime.UtcNow,
                            CryptoId     = cryptoId
                        });

                        utDAC.Insert(new UserTransaction
                        {
                            Id         = Guid.NewGuid(),
                            AccountId  = account.Id,
                            CryptoId   = cryptoCurrencty.Id,
                            CryptoCode = cryptoCurrencty.Code,
                            Type       = UserTransactionType.Profit,
                            DetailId   = profitId1.ToString(),
                            Status     = (byte)InviteStatusType.IssuedFrozen,
                            Timestamp  = DateTime.UtcNow,
                            Amount     = inviteMoney,
                            OrderNo    = orderNo1
                        });

                        uwDAC.IncreaseFrozen(inviteWallet.Id, inviteMoney);

                        uwsDAC.Insert(new UserWalletStatement
                        {
                            WalletId      = inviteWallet.Id,
                            Action        = UserWalletStatementAction.Invite,
                            Amount        = 0,
                            Balance       = inviteWallet.Balance,
                            FrozenAmount  = inviteMoney,
                            FrozenBalance = inviteWallet.FrozenBalance + inviteMoney,
                            Timestamp     = DateTime.UtcNow
                        });

                        // 每当满50人时则可以奖励 采用了插入操作 所以只要满足为49个就可以了
                        if ((invitedCount + 1) % 50 == 0)
                        {
                            var pd50 = new ProfitDetail()
                            {
                                InvitationId = inviteId,
                                CryptoAmount = rewardMoney,
                                AccountId    = account.Id,
                                Status       = InviteStatusType.IssuedFrozen,
                                Type         = ProfitType.Reward,
                                OrderNo      = CreateOrderno(),
                                Timestamp    = DateTime.UtcNow,
                                CryptoId     = cryptoId
                            };
                            exProfitId1 = pfDAC.Insert(pd50);

                            utDAC.Insert(new UserTransaction
                            {
                                Id         = Guid.NewGuid(),
                                AccountId  = account.Id,
                                CryptoId   = cryptoCurrencty.Id,
                                CryptoCode = cryptoCurrencty.Code,
                                Type       = UserTransactionType.Profit,
                                DetailId   = exProfitId1.ToString(),
                                Status     = (byte)InviteStatusType.IssuedFrozen,
                                Timestamp  = DateTime.UtcNow,
                                Amount     = rewardMoney,
                                OrderNo    = pd50.OrderNo
                            });

                            uwDAC.IncreaseFrozen(inviteWallet.Id, rewardMoney);

                            uwsDAC.Insert(new UserWalletStatement
                            {
                                WalletId      = inviteWallet.Id,
                                Action        = UserWalletStatementAction.Invite,
                                Amount        = 0,
                                Balance       = inviteWallet.Balance,
                                FrozenAmount  = rewardMoney,
                                FrozenBalance = inviteWallet.FrozenBalance + inviteMoney + rewardMoney,
                                Timestamp     = DateTime.UtcNow
                            });
                        }
                        profitId2 = pfDAC.Insert(new ProfitDetail()
                        {
                            InvitationId = inviteId,
                            CryptoAmount = inviteMoney,
                            AccountId    = im.BeInvitedAccountId,
                            Type         = ProfitType.BeInvited,
                            Status       = InviteStatusType.IssuedActive,
                            OrderNo      = orderNo2,
                            Timestamp    = DateTime.UtcNow,
                            CryptoId     = cryptoId
                        });
                        utDAC.Insert(new UserTransaction
                        {
                            Id         = Guid.NewGuid(),
                            AccountId  = im.BeInvitedAccountId,
                            CryptoId   = cryptoCurrencty.Id,
                            CryptoCode = cryptoCurrencty.Code,
                            Type       = UserTransactionType.Profit,
                            DetailId   = profitId2.ToString(),
                            Status     = (byte)InviteStatusType.IssuedActive,
                            Timestamp  = DateTime.UtcNow,
                            Amount     = inviteMoney,
                            OrderNo    = orderNo2
                        });
                        uwDAC.Increase(beInvitedWallet.Id, inviteMoney);
                        uwsDAC.Insert(new UserWalletStatement
                        {
                            WalletId      = beInvitedWallet.Id,
                            Action        = UserWalletStatementAction.BeInvite,
                            Amount        = inviteMoney,
                            Balance       = beInvitedWallet.Balance + inviteMoney,
                            FrozenAmount  = 0,
                            FrozenBalance = beInvitedWallet.FrozenBalance,
                            Timestamp     = DateTime.UtcNow
                        });
                    }
                    scope.Complete();
                }

                if (!(im.Type == (int)SystemPlatform.FiiiPay || im.Type == (int)SystemPlatform.FiiiPOS))
                {
                    throw new ArgumentException("只支持fiiipay和fiiipos邀请");
                }

                if (im.Type == (int)SystemPlatform.FiiiPay)
                {
                    UserMSMQ.PubUserInviteSuccessed(profitId2, 0);
                }
                //else if (im.Type == SystemPlatform.FiiiPOS)
                //    MerchantMSMQ.PubUserInviteSuccessed(profitId2, 0);
            }
            //else
            //{
            //    var iDAC = new InviteRecordDAC();
            //    iDAC.Insert(new InviteRecord() { Type = im.Type, AccountId = im.BeInvitedAccountId, Timestamp = DateTime.UtcNow, InviterCode = im.InvitationCode, InviterAccountId = account.Id });
            //}
        }
Esempio n. 7
0
        public SaveResult SaveProfileVerify(int AdminId, string AdminName, UserProfile profile)
        {
            var oldProfile  = GetUserProfile(profile.UserAccountId.Value);
            var userAccount = FiiiPayDB.UserAccountDb.GetById(profile.UserAccountId);

            userAccount.L1VerifyStatus = profile.L1VerifyStatus.Value;
            if (oldProfile == null)
            {
                return(new SaveResult(false, "Data error"));
            }

            var profileSDK = new UserProfileAgent();
            int count      = profileSDK.GetCountByIdentityDocNo(profile.UserAccountId.Value, oldProfile.IdentityDocNo);

            if (profile.L1VerifyStatus == VerifyStatus.Certified && count > 6)
            {
                return(new SaveResult(false, "This identty document has been used for 7 accounts, cannot be verified "));
            }
            long profitId   = 0; //被邀请人奖励ID
            long exProfitId = 0; //邀请人额外奖励ID

            bool result = profileSDK.UpdateL1Status(profile.UserAccountId.Value, profile.L1VerifyStatus.Value, profile.L1Remark);

            if (result)
            {
                FiiiPayDB.UserAccountDb.Update(userAccount);
            }
            else
            {
                profileSDK.UpdateL1Status(profile.UserAccountId.Value, oldProfile.L1VerifyStatus.Value, oldProfile.L1Remark);
            }

            if (result && profile.L1VerifyStatus == VerifyStatus.Certified)
            {
                var invite = FiiiPayDB.DB.Queryable <InviteRecords>().Where(t => t.AccountId == profile.UserAccountId.Value).First();
                if (invite != null)
                {
                    var inviteProfit = FiiiPayDB.DB.Queryable <ProfitDetails>().Where(t => t.AccountId == invite.InviterAccountId && t.InvitationId == invite.Id && t.Type == ProfitType.InvitePiiiPay).First();
                    var rewardProfit = FiiiPayDB.DB.Queryable <ProfitDetails>().Where(t => t.AccountId == invite.InviterAccountId && t.Status == InviteStatusType.IssuedFrozen && t.Type == ProfitType.Reward).OrderBy(t => t.Timestamp).First();

                    profitId = inviteProfit.Id;
                    var uwComponent = new UserWalletBLL();
                    var uwsDAC      = new UserWalletStatementDAC();
                    var uwDAC       = new UserWalletDAC();
                    var pfDAC       = new ProfitDetailDAC();
                    var utDAC       = new UserTransactionDAC();

                    int invitedCount = pfDAC.GetInvitedAndActiveCount(invite.InviterAccountId);

                    var cryptoId     = new CryptocurrencyDAC().GetByCode("FIII").Id;
                    var inviteWallet = uwComponent.GetUserWallet(invite.InviterAccountId, cryptoId);
                    if (inviteWallet == null)
                    {
                        inviteWallet = uwComponent.GenerateWallet(invite.InviterAccountId, cryptoId);
                    }

                    var inviteMoney = inviteProfit.CryptoAmount;

                    var adoResult = FiiiPayDB.DB.Ado.UseTran(() =>
                    {
                        try
                        {
                            //解冻奖励
                            uwDAC.Unfreeze(inviteWallet.Id, inviteMoney);
                            //插入奖励流水
                            uwsDAC.Insert(new UserWalletStatement
                            {
                                WalletId  = inviteWallet.Id,
                                Action    = UserWalletStatementAction.Invite,
                                Amount    = inviteMoney,
                                Balance   = inviteWallet.Balance + inviteMoney,
                                Timestamp = DateTime.UtcNow
                            });
                            //修改奖励状态为已激活
                            pfDAC.UpdateStatus(inviteProfit.Id, InviteStatusType.IssuedActive);
                            utDAC.UpdateStatus(UserTransactionType.Profit, inviteProfit.Id.ToString(), invite.InviterAccountId, (byte)InviteStatusType.IssuedActive);

                            // 每当满50人时则可以奖励 采用了插入操作 所以只要满足为49个就可以了
                            if ((invitedCount + 1) % 50 == 0)
                            {
                                exProfitId      = rewardProfit.Id;
                                var rewardMoney = rewardProfit.CryptoAmount;
                                //解冻满50人的额外奖励
                                uwDAC.Unfreeze(inviteWallet.Id, rewardMoney);
                                //插入满50人的额外奖励流水
                                uwsDAC.Insert(new UserWalletStatement
                                {
                                    WalletId  = inviteWallet.Id,
                                    Action    = UserWalletStatementAction.Reward,
                                    Amount    = rewardMoney,
                                    Balance   = inviteWallet.Balance + rewardMoney,
                                    Timestamp = DateTime.UtcNow
                                });
                                //修改奖励状态为已激活
                                pfDAC.UpdateStatus(rewardProfit.Id, InviteStatusType.IssuedActive);
                                utDAC.UpdateStatus(UserTransactionType.Profit, rewardProfit.Id.ToString(), invite.InviterAccountId, (byte)InviteStatusType.IssuedActive);
                            }
                        }
                        catch (Exception e)
                        {
                            log.Info(profile.UserAccountId + "    --------- " + e.ToString());
                        }
                    });
                    result = adoResult.Data;
                }
            }

            if (result && (profile.L1VerifyStatus == VerifyStatus.Certified || profile.L1VerifyStatus == VerifyStatus.Disapproval))
            {
                var recordId = FiiiPayDB.VerifyRecordDb.InsertReturnIdentity(new VerifyRecords()
                {
                    AccountId  = profile.UserAccountId.Value,
                    Username   = userAccount.Cellphone,
                    Body       = profile.L1Remark,
                    Type       = profile.L1VerifyStatus == VerifyStatus.Certified ? VerifyRecordType.UserLv1Verified : VerifyRecordType.UserLv1Reject,
                    CreateTime = DateTime.UtcNow
                });
                if (profile.L1VerifyStatus == VerifyStatus.Certified)
                {
                    RabbitMQSender.SendMessage("UserKYC_LV1_VERIFIED", recordId);
                }
                else if (profile.L1VerifyStatus == VerifyStatus.Disapproval)
                {
                    RabbitMQSender.SendMessage("UserKYC_LV1_REJECT", recordId);
                }
            }

            if (result && profitId > 0)
            {
                RabbitMQSender.SendMessage("UserInviteSuccessed", profitId);
            }
            if (result && exProfitId > 0)
            {
                RabbitMQSender.SendMessage("UserInviteSuccessed", profitId);
            }
            ActionLog actionLog = new ActionLog();

            actionLog.IPAddress  = GetClientIPAddress();
            actionLog.AccountId  = AdminId;
            actionLog.CreateTime = DateTime.UtcNow;
            actionLog.ModuleCode = typeof(UserProfileBLL).FullName + ".SaveProfileVerify";
            actionLog.Username   = AdminName;
            actionLog.LogContent = string.Format("verify user profile.accountId:{0},verifystatus:{1}", profile.UserAccountId, profile.L1VerifyStatus.ToString());
            new ActionLogBLL().Create(actionLog);

            return(new SaveResult(result));
        }