Example #1
0
        /// <summary>
        /// 获取众筹股东列表
        /// </summary>
        /// <param name="crowdfundingId">众筹Id</param>
        /// <param name="userName">用户姓名</param>
        /// <param name="userCode">用户账号</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">每页数量</param>
        public GetUserCrowdfundingsDTO GetUserCrowdfundingsExt(System.Guid crowdfundingId, string userName, string userCode, int pageIndex, int pageSize)
        {
            GetUserCrowdfundingsDTO getUserCrowdfundingsDTO = new GetUserCrowdfundingsDTO();

            try
            {
                var result = (from query in UserCrowdfunding.ObjectSet()
                              where query.CrowdfundingId == crowdfundingId && query.CurrentShareCount > 0 && (string.IsNullOrEmpty(userName) ? true : query.UserName.Contains(userName.Trim())) &&
                              (string.IsNullOrEmpty(userCode) ? true : query.UserCode.Contains(userCode.Trim()))
                              select new Jinher.AMP.BTP.Deploy.CustomDTO.UserCrowdfundingDTO
                {
                    Id = query.Id,
                    AppId = query.AppId,
                    CrowdfundingId = query.CrowdfundingId,
                    OrderCount = query.OrderCount,
                    UserId = query.UserId,
                    UserCode = query.UserCode,
                    UserName = query.UserName,
                    Money = query.OrdersMoney,
                    CurrentShareCount = query.CurrentShareCount,
                    TotalDividend = query.TotalDividend,
                    RealGetDividend = query.RealGetDividend,
                    SubTime = query.SubTime,
                    ModifiedOn = query.ModifiedOn
                }

                              ).OrderByDescending(q => q.SubTime);


                var list = result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList();

                if (list != null && list.Count > 0)
                {
                    getUserCrowdfundingsDTO.List  = list;
                    getUserCrowdfundingsDTO.Total = result.Count();
                }
                else
                {
                    getUserCrowdfundingsDTO.Total = 0;
                }

                return(getUserCrowdfundingsDTO);
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("获取众筹列表服务异常。crowdfundingId:{0},userName:{1},userCode:{2},pageIndex:{3},pageSize:{4}", crowdfundingId, userName, userCode, pageIndex, pageSize), ex);
                return(null);
            }
        }
        /// <summary>
        /// 领取红包
        /// </summary>
        /// <param name="userRedEnvelopeId"></param>
        /// <returns></returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO DrawRedEnvelopeExt(Guid userRedEnvelopeId)
        {
            ContextSession contextSession = ContextFactory.CurrentThreadContext;

            Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO result = new ResultDTO();

            UserRedEnvelope query = null;

            lock (getRedLock)
            {
                //用户分红表
                query = UserRedEnvelope.ObjectSet().Where(q => q.Id == userRedEnvelopeId).FirstOrDefault();

                if (query == null)
                {
                    result.ResultCode = 1;
                    result.Message    = "没有红包可领";
                    return(result);
                }
                else if (query.State == 0 && DateTime.Now > query.DueDate)
                {
                    result.ResultCode = 1;
                    result.Message    = "红包已过期";
                    return(result);
                }
                else if (query.State == 1)
                {
                    result.ResultCode = 1;
                    result.Message    = "红包已领";
                    return(result);
                }
                int num = UpdateRedState(query, 1);
                if (num > 0)
                {
                    result.ResultCode = 0;
                    result.Message    = "领取红包成功";
                }
                else
                {
                    result.ResultCode = 1;
                    result.Message    = "领取红包失败";
                    return(result);
                }
            }

            MultiPayeeTradeByPasswordArg arg = new MultiPayeeTradeByPasswordArg();
            ReturnInfoDTO gReturnDTO         = new ReturnInfoDTO();

            arg.PayeeComments = new List <string>();
            arg.PayorComments = new List <string>();
            arg.AppId         = query.AppId;
            arg.Payees        = new List <Tuple <Guid, bool> >();
            arg.Payees.Add(new Tuple <Guid, bool>(query.UserId, true));
            arg.BizSystem = "BTP";
            arg.BizId     = query.Id;
            arg.Golds     = new List <long> {
                query.GoldCount
            };
            arg.PayorPassword = CustomConfig.ShareGoldAccout.BTPShareAccountPwd;
            //众销
            if (query.RedEnvelopeType == 0)
            {
                arg.PayorId = CustomConfig.ShareGoldAccout.BTPShareGoldAccount;
                arg.UsageId = CustomConfig.ShareGoldAccout.BTPGlodUsageId;
                arg.BizType = "BTP_ShareDividend_Auto";
                arg.PayorComments.Add("电商分享红包支出");
                arg.PayeeComments.Add("电商分享红包收益");
            }
            else
            {
                //众筹
                arg.PayorId = CustomConfig.CrowdfundingAccount.BTPCrowdfundingAcount;
                arg.UsageId = CustomConfig.CrowdfundingAccount.BTPCrowdfundingUsageId;
                arg.BizType = "BTP_CrowdfundingDividend";
                arg.PayorComments.Add("电商众筹分红支出");
                arg.PayeeComments.Add("电商众筹分红收益");

                //计算用户已得分红
                var uc = UserCrowdfunding.ObjectSet().Where(q => q.AppId == query.AppId && q.UserId == query.UserId).FirstOrDefault();

                uc.RealGetDividend += query.GoldCount;
                uc.EntityState      = EntityState.Modified;
                contextSession.SaveObject(uc);
            }
            try
            {
                gReturnDTO = Jinher.AMP.BTP.TPS.Finance.Instance.MultiPayeeTradeByPassword(arg);
            }
            catch (Exception ex)
            {
                int num = UpdateRedState(query, 0);
                LogHelper.Error(string.Format("获取我的红包UserRedEnvelopeSV-DrawRedEnvelopeExt-MultiPayeeTrade,参数redEnvelopeId:{0},红包状态恢复{1}", userRedEnvelopeId, (num > 0 ? "成功" : "失败")), ex);
                result.ResultCode = 1;
                result.Message    = "调用金币接口失败";
                return(result);
            }

            if (gReturnDTO == null || !gReturnDTO.IsSuccess)
            {
                int num = UpdateRedState(query, 0);
                result.ResultCode = 1;
                result.Message    = "分享红包支付失败";

                LogHelper.Error(string.Format("调用金币MultiPayeeTradeByPassword方法失败,code:{0},错误消息:{1},参数redEnvelopeId:{2},红包状态恢复{3}", gReturnDTO.Code, gReturnDTO.Info, userRedEnvelopeId, (num > 0 ? "成功" : "失败")));

                return(result);
            }
            return(result);
        }