Ejemplo n.º 1
0
        /// <summary>
        /// 获取红包列表
        /// </summary>
        /// <param name="uniacid">商户识别ID</param>
        /// <param name="accountID">账户ID</param>
        /// <param name="type">红包动作分类(领取、发出)</param>
        /// <returns></returns>
        public string GetPacketsList(string uniacid, string accountID, PacketsDoType type)
        {
            try
            {
                List <VoicePacketsModel> list = thisData.GetPacketsList(uniacid, new ObjectId(accountID), type);
                var jm = new BaseResponseModel <List <VoicePacketsModel> >()
                {
                    StatusCode = ActionParams.code_ok, JsonData = list
                };
                JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings();
                string[] param = new string[] { "StatusCode", "JsonData", "TextCmd", "PacketsID", "Amount", "CreateTime", "OpenStatus" };
                jsonSerializerSettings.ContractResolver = new LimitPropsContractResolver(param);
                string jsonString = JsonConvert.SerializeObject(jm, jsonSerializerSettings);

                return(jsonString);
            }
            catch (Exception)
            {
                return(JsonResponseModel.ErrorJson);

                throw;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取红包列表
        /// </summary>
        /// <param name="uniacid"></param>
        /// <param name="accountID"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        internal List <VoicePacketsModel> GetPacketsList(string uniacid, ObjectId accountID, PacketsDoType type)
        {
            var account       = GetModelByIDAndUniacID(accountID, uniacid);
            var vpmCollection = mongo.GetMongoCollection <VoicePacketsModel>();

            switch (type)
            {
            case PacketsDoType.send:
                if (account.SendPackets == null)
                {
                    var em = new ExceptionModel()
                    {
                        ExceptionParam = ActionParams.code_null
                    };
                    em.Save();
                    throw em;
                }
                for (int i = 0; i < account.SendPackets.Count; i++)
                {
                    account.SendPackets[i] = vpmCollection.Find(x => x.PacketsID.Equals(account.SendPackets[i].PacketsID)).FirstOrDefault();
                }
                return(account.SendPackets);

            case PacketsDoType.receive:
                if (account.ReceivePackets == null)
                {
                    var em = new ExceptionModel()
                    {
                        ExceptionParam = ActionParams.code_null
                    };
                    em.Save();
                    throw em;
                }
                for (int i = 0; i < account.ReceivePackets.Count; i++)
                {
                    account.ReceivePackets[i] = vpmCollection.Find(x => x.PacketsID.Equals(account.ReceivePackets[i].PacketsID)).FirstOrDefault();
                }
                return(account.ReceivePackets);

            default:
                var e = new ExceptionModel()
                {
                    Content = "获取红包列表type类型未知"
                };
                e.Save();
                throw e;
            }
        }