zoujiajian 1 éve
szülő
commit
cd7fc53b7f

+ 2 - 0
netflix-dao/src/main/java/com/cyksj/mapper/AccountMapper.java

@@ -26,4 +26,6 @@ public interface AccountMapper extends BaseMapper<Account> {
 	List<ExcelAccountData> getExpiredAccountViewNoPage(@Param("isCorpWx") Boolean isCorpWx, @Param("customerService") String customerService, @Param("goodsId") Long goodsId, @Param("skuId") Long skuId, @Param("account") String account, @Param("renewStatus") Boolean renewStatus, @Param("handleStatus") Boolean handleStatus, @Param("cnAccount") String cnAccount, @Param("usAccount") String usAccount, @Param("userId") Integer userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("now") String now);
 
 	List<AccountView> getExpiredAllAccount();
+
+	Account selectNetflixTempAccount();
 }

+ 13 - 0
netflix-dao/src/main/java/com/cyksj/mapper/NetflixTempAccountUserMapper.java

@@ -0,0 +1,13 @@
+package com.cyksj.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.cyksj.model.entity.NetflixTempAccountUser;
+
+/**
+ * 项目名: yhlxj
+ * 文件名: NetflixTempAccountUserMapper
+ * 创建者: JavaZou
+ * 创建时间:2024/10/28 17:16
+ */
+public interface NetflixTempAccountUserMapper extends BaseMapper<NetflixTempAccountUser> {
+}

+ 1 - 1
netflix-dao/src/main/java/com/cyksj/model/entity/Account.java

@@ -99,7 +99,7 @@ public class Account extends BaseEntity {
     private String preSkuIds;
 
     /**
-     * 类型 1通用 2备用
+     * 类型 1通用 2备用 3临时账号
      */
     private Integer type;
 

+ 20 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/NetflixTempAccountUser.java

@@ -0,0 +1,20 @@
+package com.cyksj.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 项目名: yhlxj
+ * 文件名: NetflixTempAccountUser
+ * 创建者: JavaZou
+ * 创建时间:2024/10/28 17:16
+ */
+@Getter
+@Setter
+public class NetflixTempAccountUser extends BaseEntity{
+	private Long userId;
+
+	private Long relationId;
+
+	private Long accountId;
+}

+ 20 - 1
netflix-dao/src/main/java/com/cyksj/model/excel/ExcelPrepareAccountData.java

@@ -24,4 +24,23 @@ public class ExcelPrepareAccountData {
      */
     @ExcelProperty("银行卡号")
     private String bankCard;
-}
+
+
+    /**
+     * 到期日期
+     */
+    @ExcelProperty("到期日期")
+    private String expiryTime;
+
+    /**
+     * 辅助邮箱
+     */
+    @ExcelProperty("辅助邮箱")
+    private String secondEmail;
+
+    /**
+     * 辅助邮箱
+     */
+    @ExcelProperty("关联邮箱")
+    private String relateEmail;
+}

+ 11 - 0
netflix-dao/src/main/resources/mapper/AccountMapper.xml

@@ -187,4 +187,15 @@
                  left join goods_don g on g.id = a.goods_id
         where s.num >= gt.num
     </select>
+
+    <select id="selectNetflixTempAccount" resultType="com.cyksj.model.entity.Account">
+        select a.*
+        from account a
+        where goods_id = 1
+          and type = 3
+          and (select count(1)
+               from netflix_temp_account_user ntu
+                        inner join groups_relation gr on gr.id = ntu.relation_id and ntu.user_id = gr.user_id
+            wjere ntu.account_id = a.id) &lt; 20
+    </select>
 </mapper>

+ 3 - 0
netflix-service/src/main/java/com/cyksj/service/relation/GroupRelationFrontService.java

@@ -3,6 +3,7 @@ package com.cyksj.service.relation;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.cyksj.model.entity.GoodsDonSku;
 import com.cyksj.model.entity.GroupsRelation;
+import com.cyksj.model.manage.views.AccountView;
 import com.cyksj.model.request.SpecialGoodsTicketReq;
 import com.cyksj.model.request.TicketLoginReq;
 import com.cyksj.model.views.RenewalView;
@@ -70,4 +71,6 @@ public interface GroupRelationFrontService {
 	String getVerifyCode(String account) throws Exception;
 
 	void changeTicket(long userId, Long relationId);
+
+	AccountView getTempAccount(long userId, Long relationId);
 }

+ 36 - 0
netflix-service/src/main/java/com/cyksj/service/relation/impl/GroupRelationFrontServiceImpl.java

@@ -25,6 +25,7 @@ import com.cyksj.mapper.manage.distribute.UserPlatSkuDistributeRateMapper;
 import com.cyksj.mapper.renew.RenewUpgradePackageMapper;
 import com.cyksj.mapper.sys.SysEmailMapper;
 import com.cyksj.model.entity.*;
+import com.cyksj.model.manage.views.AccountView;
 import com.cyksj.model.request.SpecialGoodsTicketReq;
 import com.cyksj.model.request.TicketLoginReq;
 import com.cyksj.model.views.*;
@@ -52,6 +53,7 @@ import com.ejlchina.searcher.util.MapUtils;
 import com.github.rholder.retry.*;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -160,6 +162,8 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 
 	private final GroupsRelationChangeService changeTickerRelation;
 
+	private final NetflixTempAccountUserMapper netflixTempAccountUserMapper;
+
 	@Override
 	public SearchResult<RenewalView> getMyTicket(long userId, Boolean isLoginPopularize, String customId, String account, String orderNo) {
 		User u = userMapper.selectById(userId);
@@ -1034,6 +1038,38 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 		}
 	}
 
+	@Override
+	public AccountView getTempAccount(long userId, Long relationId) {
+		List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
+		RenewalView renewalView = beanSearcher.searchFirst(RenewalView.class, MapUtils.builder()
+				.field(RenewalView::getRelationId, relationId)
+				.field(RenewalView::getUserId, userIdList).op(Operator.InList)
+				.field(RenewalView::getExpiryTime, DateTime.now()).op(Operator.GreaterThan)
+				.build());
+		if (renewalView == null) {
+			throw BusinessRuntimeException.getInstance("车票不存在");
+		}
+		NetflixTempAccountUser netflixTempAccountUser = netflixTempAccountUserMapper.selectOne(Wrappers.lambdaQuery(NetflixTempAccountUser.class)
+				.eq(NetflixTempAccountUser::getRelationId, relationId)
+				.in(NetflixTempAccountUser::getUserId, userIdList)
+				.last("limit 1"));
+		AccountView accountView = new AccountView();
+		Account account;
+		if (netflixTempAccountUser == null) {
+			account = accountMapper.selectNetflixTempAccount();
+			netflixTempAccountUser = new NetflixTempAccountUser();
+			netflixTempAccountUser.setAccountId(account.getId());
+			netflixTempAccountUser.setRelationId(relationId);
+			netflixTempAccountUser.setUserId(renewalView.getUserId());
+			netflixTempAccountUserMapper.insert(netflixTempAccountUser);
+		} else {
+			account = accountMapper.selectById(netflixTempAccountUser.getAccountId());
+		}
+		accountView.setAccount(account.getAccount());
+		accountView.setPassword(account.getPassword());
+		return accountView;
+	}
+
 	private DistributePosterGoodsDetailView setGoodsPoster(RenewalView ticket, User user, List<Long> userIds) {
 		DistributePosterGoodsDetailView distributePosterGoodsDetailView = beanSearcher.searchFirst(DistributePosterGoodsDetailView.class, MapUtils.flatBuilder(request.getParameterMap())
 				.field(DistributePosterGoodsFrontView::getGoodsId, ticket.getGoodsId()).build());

+ 11 - 0
netflix-web/src/main/java/com/cyksj/web/controller/group/GroupRelationController.java

@@ -28,6 +28,7 @@ import com.cyksj.mapper.manage.form.QuestionnairePromotionMapper;
 import com.cyksj.model.dto.DoubleVerifyDto;
 import com.cyksj.model.dto.QuestionnaireView;
 import com.cyksj.model.entity.*;
+import com.cyksj.model.manage.views.AccountView;
 import com.cyksj.model.manage.views.GroupsRelationView;
 import com.cyksj.model.request.*;
 import com.cyksj.model.response.GptStandbyResp;
@@ -1092,4 +1093,14 @@ public class GroupRelationController {
         });
         return GatewayResponse.SUCCESS.newBuilder().toResult();
     }
+
+    /**
+     * 查看临时账号
+     */
+    @GetMapping("/get/temp/account/{relationId}")
+    public Result<AccountView> getTempAccount(@PathVariable Long relationId) {
+        long userId = StpUserUtil.getLoginIdAsLong();
+        AccountView accountView = groupRelationFrontService.getTempAccount(userId, relationId);
+        return GatewayResponse.SUCCESS.newBuilder().toResult(accountView);
+    }
 }

+ 133 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/account/AccountTempController.java

@@ -0,0 +1,133 @@
+package com.cyksj.web.controller.manage.account;
+
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
+import com.alibaba.excel.support.ExcelTypeEnum;
+import com.cyksj.common.exception.BusinessRuntimeException;
+import com.cyksj.dto.Result;
+import com.cyksj.enums.GatewayResponse;
+import com.cyksj.mapper.AccountMapper;
+import com.cyksj.model.entity.Account;
+import com.cyksj.model.excel.ExcelPrepareAccountData;
+import com.cyksj.service.mange.AccountCommonService;
+import com.cyksj.web.util.EasyExcelUtils;
+import com.ejlchina.searcher.BeanSearcher;
+import com.ejlchina.searcher.SearchResult;
+import com.ejlchina.searcher.util.MapUtils;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * 项目名: yhlxj
+ * 文件名: AccountTempController
+ * 创建者: JavaZou
+ * 创建时间:2024/10/28 17:17
+ */
+@Slf4j
+@RequiredArgsConstructor
+@RequestMapping("/manage/account/temp")
+@RestController
+public class AccountTempController {
+	private final BeanSearcher beanSearcher;
+
+	private final HttpServletRequest request;
+
+	private final AccountMapper accountMapper;
+
+	private final AccountCommonService accountCommonService;
+
+	/**
+	 * 新增临时账号
+	 */
+	@PostMapping("/post")
+	public Result<String> post(@RequestBody Account account) {
+		accountMapper.insert(account);
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
+	/**
+	 * 编辑临时账号
+	 */
+	@PutMapping("/post")
+	public Result<String> update(@RequestBody Account account) {
+		accountMapper.updateById(account);
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
+	/**
+	 * 临时账号模板
+	 */
+	@GetMapping("/export/temp/template")
+	public void getPrepareTemplate(HttpServletResponse response) {
+		EasyExcelUtils.createTemplateExcel(response, ExcelPrepareAccountData.class, "临时账号导入模板", "临时账号导入模板", ExcelTypeEnum.XLSX, null);
+	}
+
+	/**
+	 * 批量导入临时账号
+	 */
+	@PutMapping("/import")
+	public Result<String> batchImportPrepare(@RequestParam(defaultValue = "1") Long goodsId, MultipartFile file) throws IOException {
+		if (goodsId == null) {
+			throw BusinessRuntimeException.getInstance("请选择对应平台");
+		}
+		EasyExcel.read(file.getInputStream(), ExcelPrepareAccountData.class, new AnalysisEventListener<ExcelPrepareAccountData>() {
+			@Override
+			public void invoke(ExcelPrepareAccountData data, AnalysisContext analysisContext) {
+				String account = data.getAccount();
+				String password = data.getPassword();
+				if (StrUtil.isEmpty(account) || StrUtil.isEmpty(password)) {
+					return;
+				}
+				Account insert = new Account();
+				insert.setAccount(account.trim());
+				insert.setPassword(password.trim());
+				insert.setGoodsId(goodsId);
+				//临时账号
+				insert.setType(3);
+				insert.setStartTime(DateTime.now());
+				if (data.getExpiryTime() != null) {
+					insert.setExpiryTime(DateUtil.parse(data.getExpiryTime()));
+				} else {
+					insert.setExpiryTime(DateUtil.offsetMonth(DateTime.now(), 1));
+				}
+				insert.setBankCard(data.getBankCard());
+				//辅助邮箱
+				insert.setEmail(data.getSecondEmail());
+				//关联邮箱
+				insert.setRelateEmail(data.getRelateEmail());
+				//账号是否已经添加过
+				if (!insert.getAccount().contains("客服")) {
+					if (accountCommonService.checkIsDupAccount(insert.getGoodsId(), insert.getAccount())) {
+						return;
+					}
+				}
+				accountMapper.insert(insert);
+			}
+
+			@Override
+			public void doAfterAllAnalysed(AnalysisContext analysisContext) {
+
+			}
+		}).sheet().doRead();
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
+	/**
+	 * 临时账号列表
+	 */
+	@PutMapping("/post")
+	public Result<SearchResult<Account>> get() {
+		SearchResult<Account> search = beanSearcher.search(Account.class, MapUtils.flatBuilder(request.getParameterMap()).field(Account::getType, 3).build());
+		return GatewayResponse.SUCCESS.newBuilder().toResult(search);
+	}
+}

+ 0 - 1
netflix-web/src/main/java/com/cyksj/web/controller/manage/account/CmsAccountController.java

@@ -1140,7 +1140,6 @@ public class CmsAccountController {
 						return;
 					}
 				}
-				insert.setType(2);
 				accountService.save(insert);
 			}