李昊 4 years ago
parent
commit
ed4ee8cee2

+ 72 - 0
gx_api/GxPress/Api/GxPress.Api/WebControllers/WebBlacklistController.cs

@@ -0,0 +1,72 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using GxPress.Auth;
+using GxPress.Entity;
+using GxPress.Repository.Interface;
+using GxPress.Request.BlacklistUser;
+using GxPress.Service.Interface.IM;
+using GxPress.Service.Interface.OftenContact;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+
+namespace GxPress.Api.WebControllers
+{
+    /// <summary>
+    /// 用户黑名单
+    /// </summary>
+    [Route("api/web/blacklist")]
+    [ApiController]
+    [Authorize]
+    public class WebBlacklistController : ControllerBase
+    {
+        private readonly ILogger<WebBlacklistController> _logger;
+        private readonly IBlacklistUserRepository _blacklistUserRepository;
+        private readonly ILoginContext _loginContext;
+        private readonly IOftenContactService _oftenContactService;
+        private readonly IIMService _imService;
+
+        public WebBlacklistController(ILogger<WebBlacklistController> logger,
+            IBlacklistUserRepository blacklistUserRepository, ILoginContext loginContext,
+            IOftenContactService oftenContactService, IIMService imService)
+        {
+            _logger = logger;
+            _blacklistUserRepository = blacklistUserRepository;
+            _loginContext = loginContext;
+            _oftenContactService = oftenContactService;
+            _imService = imService;
+        }
+
+        /// <summary>
+        /// 获取黑名单
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost("list")]
+        public async Task<IEnumerable<BlacklistUser>> GetBlacklistUser()
+        {
+            var request = new BlacklistUserSearchRequest { UserId = _loginContext.AccountId };
+            return await _blacklistUserRepository.GetBlacklistUserAsync(request);
+        }
+
+        /// <summary>
+        /// 添加黑名单
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [HttpPost("add")]
+        public async Task<bool> Insert(BlacklistUserInRequest request)
+        {
+            return await _imService.AddBlacklistUserAsync(_loginContext.AccountId, request.UserId);
+        }
+        /// <summary>
+        /// 删除黑名单
+        /// </summary>
+        /// <param name="blackUserId"></param>
+        /// <returns></returns>
+        [HttpDelete("{blackUserId}")]
+        public async Task<bool> Delete(int blackUserId)
+        {
+            return await _imService.ReMoveBlacklistUserAsync(blackUserId, _loginContext.AccountId);
+        }
+    }
+}

+ 17 - 0
gx_api/GxPress/Service/GxPress.Service.Implement/Order/OrderService.cs

@@ -62,6 +62,7 @@ namespace GxPress.Service.Implement.Order
                         if ((VipCardTypeConst)vipEquity.VipType == VipCardTypeConst.Year)
                             user.EndTime = DateTime.Now.AddYears(1);
                         user.AccumulativePrice = user.AccumulativePrice + order.Price;
+                        user.TypeId = vipEquity.VipType;
                         await userRepository.UpdateAsync(user);
                     }
                     if (user.IsVip)
@@ -96,7 +97,23 @@ namespace GxPress.Service.Implement.Order
             order.Price = decimal.Parse(sArray["total_amount"].ToString());
             order.TransactionId = sArray["trade_no"].ToString();
             order.IsVip = user.IsVip;
+            order.IsSuccess = true;
             order.PayWay = 2;
+            //如果是用户增加
+            if (order.OrderType == 2)
+            {
+                var vipEquity = await vipEquityRepository.GetAsync(order.MediaId);
+                user.IsVip = true;
+                if ((VipCardTypeConst)vipEquity.VipType == VipCardTypeConst.Month)
+                    user.EndTime = DateTime.Now.AddMonths(1);
+                if ((VipCardTypeConst)vipEquity.VipType == VipCardTypeConst.Season)
+                    user.EndTime = DateTime.Now.AddMonths(3);
+                if ((VipCardTypeConst)vipEquity.VipType == VipCardTypeConst.Year)
+                    user.EndTime = DateTime.Now.AddYears(1);
+                user.AccumulativePrice = user.AccumulativePrice + order.Price;
+                user.TypeId = vipEquity.VipType;
+                await userRepository.UpdateAsync(user);
+            }
             return await orderRepository.UpdateAsync(order);
         }
     }