|
|
@@ -3,10 +3,12 @@ package com.cyksj.web.controller.manage.group;
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.thread.ThreadUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.extra.servlet.ServletUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import com.alibaba.excel.support.ExcelTypeEnum;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
|
|
@@ -17,13 +19,18 @@ import com.cyksj.common.constant.Constant;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.util.GoogleGenerator;
|
|
|
import com.cyksj.common.util.Jsons;
|
|
|
+import com.cyksj.common.util.StringUtil;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.BusinessType;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
import com.cyksj.mapper.*;
|
|
|
+import com.cyksj.mapper.manage.cms.CmsUserMapper;
|
|
|
+import com.cyksj.mapper.manage.cms.SysLogMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.excel.ExcelGroupRelationData;
|
|
|
+import com.cyksj.model.manage.views.AccountView;
|
|
|
import com.cyksj.model.request.AccountGroupsReq;
|
|
|
+import com.cyksj.model.request.BatchUpdateAccountStatusTripsReq;
|
|
|
import com.cyksj.model.request.ReplaceTripsAccountReq;
|
|
|
import com.cyksj.model.views.CloseGroupsTripsView;
|
|
|
import com.cyksj.model.views.GoodsDonSkuView;
|
|
|
@@ -41,6 +48,7 @@ import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -84,6 +92,10 @@ public class CmsGroupController {
|
|
|
|
|
|
private final NetflixUserAccountStatusRecordMapper netflixUserAccountStatusRecordMapper;
|
|
|
|
|
|
+ private final SysLogMapper sysLogMapper;
|
|
|
+
|
|
|
+ private final CmsUserMapper cmsUserMapper;
|
|
|
+
|
|
|
@GetMapping("/get")
|
|
|
@SaCheckPermission("group:view")
|
|
|
public Result<SearchResult<GroupsTrips>> get(String account, Long userId, String showId, String nickName, String submitAccount, Boolean isEmpty, String orderNo) {
|
|
|
@@ -338,6 +350,54 @@ public class CmsGroupController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult("操作成功");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 通过账号 批量上下架 车队
|
|
|
+ */
|
|
|
+ @PutMapping("/batch/update/account/trips/status")
|
|
|
+ @Transactional(rollbackFor = Throwable.class)
|
|
|
+ public Result<String> batchUpdateAccountTripsStatus(@RequestBody @Validated BatchUpdateAccountStatusTripsReq req) {
|
|
|
+ long adminId = StpUtil.getLoginIdAsLong();
|
|
|
+ Long goodsId = req.getGoodsId();
|
|
|
+ List<String> accounts = req.getAccounts();
|
|
|
+ GroupsTrips.Status updateTripsStatus = req.getStatus();
|
|
|
+ GroupsTrips.Status selectStatus;
|
|
|
+ if (updateTripsStatus == GroupsTrips.Status.validity) {
|
|
|
+ selectStatus = GroupsTrips.Status.down;
|
|
|
+ } else {
|
|
|
+ selectStatus = GroupsTrips.Status.validity;
|
|
|
+ }
|
|
|
+ if (CollUtil.isNotEmpty(accounts)) {
|
|
|
+ List<AccountView> dbAccountViews = beanSearcher.searchAll(AccountView.class, MapUtils.builder().field(AccountView::getAccount, accounts).op(Operator.InList).field(AccountView::getGoodsId, goodsId).field(AccountView::getGtStatus, selectStatus.name()).build());
|
|
|
+ if (CollUtil.isNotEmpty(dbAccountViews)) {
|
|
|
+ CmsUser cmsUser = cmsUserMapper.selectById(adminId);
|
|
|
+ dbAccountViews.forEach(account->{
|
|
|
+ GroupsTrips groupsTrips = groupService.getById(account.getGroupsId());
|
|
|
+ GroupsTrips.Status status = groupsTrips.getStatus();
|
|
|
+ if (status == GroupsTrips.Status.validity) {
|
|
|
+ groupsTrips.setStatus(GroupsTrips.Status.down);
|
|
|
+ //奈飞车队下架 是否存在在检测的用户
|
|
|
+ Long skuId = groupsTrips.getSkuId();
|
|
|
+ if (skuId != null) {
|
|
|
+ GoodsDonSku sku = goodsDonSkuMapper.selectById(skuId);
|
|
|
+ if (sku != null && sku.getGoodsId() == Constant.NETFLIX_GID) {
|
|
|
+ List<Long> relationIds = groupsRelationMapper.selectList(Wrappers.lambdaUpdate(GroupsRelation.class).eq(GroupsRelation::getGroupsId, groupsTrips.getId())).stream().map(GroupsRelation::getId).collect(Collectors.toList());
|
|
|
+ netflixUserAccountStatusRecordMapper.update(null, Wrappers.lambdaUpdate(NetflixUserAccountStatusRecord.class)
|
|
|
+ .set(NetflixUserAccountStatusRecord::getState, 3)
|
|
|
+ .in(NetflixUserAccountStatusRecord::getRelationId, relationIds));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (status == GroupsTrips.Status.down) {
|
|
|
+ groupsTrips.setStatus(GroupsTrips.Status.validity);
|
|
|
+ }
|
|
|
+ groupService.updateById(groupsTrips);
|
|
|
+ recordSysOpLog(groupsTrips.getId(), cmsUser);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 弃用账号
|
|
|
*/
|
|
|
@@ -437,4 +497,19 @@ public class CmsGroupController {
|
|
|
.eq(GroupsRelationAlert::getSkuId, skuId).last("limit 1"));
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(groupsRelationAlert);
|
|
|
}
|
|
|
+
|
|
|
+ private void recordSysOpLog(Long groupsId, CmsUser cmsUser) {
|
|
|
+ try {
|
|
|
+ //添加操作记录
|
|
|
+ SysLog sysLog = new SysLog();
|
|
|
+ sysLog.setOperateIp(ServletUtil.getClientIP(request));
|
|
|
+ sysLog.setOperateLocation(StringUtil.getRealAddressByIP(sysLog.getOperateIp()));
|
|
|
+ sysLog.setModule("过期账号/上下架过期车队");
|
|
|
+ sysLog.setOperateParams(groupsId.toString());
|
|
|
+ sysLog.setOperator(cmsUser != null ? cmsUser.getNickname() : "批量修改车队状态");
|
|
|
+ sysLogMapper.insert(sysLog);
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|