예제 #1
0
        public async Task <IActionResult> GetMemberInfoAsync(string userGuid)
        {
            if (string.IsNullOrWhiteSpace(userGuid))
            {
                return(Failed(ErrorCode.UserData));
            }
            UserBiz userBiz = new UserBiz();
            var     ressult = await userBiz.GetAsync(userGuid);

            if (ressult == null)
            {
                return(Failed(ErrorCode.UserData, "userGuid错误"));
            }
            var response = ressult.ToDto <GetMemberInfoResponseDto>();
            //获取用户消费信息
            var consumer = await userBiz.GetConsumerAsync(userGuid);

            if (consumer != null)
            {
                response.LastBuyDate      = (DateTime?)consumer?.LastBuyDate;
                response.OrderAverage     = (decimal)consumer?.OrderAverage;
                response.OrderQty         = (int)consumer?.OrderQty;
                response.OrderTotalAmount = (decimal)consumer?.OrderTotalAmount;
            }
            //消费者
            var consumer2 = await new ConsumerBiz().GetAsync(userGuid);

            if (consumer2 != null)
            {
                response.Recommended = (await userBiz.GetAsync(consumer2.RecommendGuid))?.UserName;
            }
            var address = new AddressBiz().GetUserDefaultAddress(userGuid);

            response.Address = $"{address?.Province}{address?.City}{address?.Area}{address?.DetailAddress}";
            return(Success(response));
        }