Exemplo n.º 1
0
        /// <summary>
        /// 校验用户的参团资格
        /// </summary>
        /// <param name="GroupId"></param>
        /// <param name="UserId"></param>
        /// <param name="ProductGroupId"></param>
        /// <returns></returns>
        public async Task <OperationResult <CheckResultModel> > CheckGroupInfoByUserIdAsync(Guid GroupId, Guid UserId,
                                                                                            string ProductGroupId, string pid = default(string))
        {
            if ((GroupId == Guid.Empty || UserId == Guid.Empty) && string.IsNullOrWhiteSpace(ProductGroupId))
            {
                return(OperationResult.FromError <CheckResultModel>(ErrorCode.ParameterError, "参数不正确"));
            }

            var result = new CheckResultModel();

            if (!string.IsNullOrWhiteSpace(pid) && !(await GroupBuyingManager.CheckProductOnSale(pid)))
            {
                result.Code = 12;
                result.Info = "产品库已下架";
                return(OperationResult.FromResult(result));
            }
            if (GroupId == Guid.Empty && !string.IsNullOrWhiteSpace(ProductGroupId))
            {
                result = await GroupBuyingManager.CheckProductGroupInfoById(ProductGroupId, UserId, pid);
            }
            else
            {
                result = await GroupBuyingManager.CheckGroupInfoByUserId(GroupId, UserId, ProductGroupId, pid);
            }

            return(OperationResult.FromResult(result));
        }