|
|
@@ -20,10 +20,12 @@ import com.cyksj.mapper.HomeGroupMapper;
|
|
|
import com.cyksj.mapper.UserTicketClearedRecordMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.excel.ExcelAccountTemplateData;
|
|
|
+import com.cyksj.model.excel.ExcelImportAccountData;
|
|
|
import com.cyksj.model.excel.ExcelManageAccountData;
|
|
|
import com.cyksj.model.manage.request.ReqAccountIncrExpiryTime;
|
|
|
import com.cyksj.model.manage.views.AccountView;
|
|
|
import com.cyksj.model.manage.views.GroupsRelationView;
|
|
|
+import com.cyksj.model.views.GoodsDonSkuView;
|
|
|
import com.cyksj.model.views.UserTicketClearedRecordView;
|
|
|
import com.cyksj.service.mange.CmsAccountService;
|
|
|
import com.cyksj.service.mange.CmsGroupService;
|
|
|
@@ -210,6 +212,67 @@ public class CmsAccountController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取导入账号模板
|
|
|
+ */
|
|
|
+ @GetMapping("/get/account/import/template")
|
|
|
+ public void getImportAccountTemplate(HttpServletResponse response) {
|
|
|
+ EasyExcelUtils.createTemplateExcel(response, ExcelImportAccountData.class, "导入账号模板", "导入账号模板", ExcelTypeEnum.XLSX, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导入账号
|
|
|
+ */
|
|
|
+ @PostMapping("/import/account/issuance")
|
|
|
+ public Result<String> importAccountAndIssuance(Long goodsId, Long skuId, MultipartFile file) throws Exception {
|
|
|
+ GoodsDonSkuView goodsDonSkuView = beanSearcher.searchFirst(GoodsDonSkuView.class, MapUtils.builder().field(GoodsDonSkuView::getGoodsId, goodsId).field(GoodsDonSkuView::getSkuId, skuId).build());
|
|
|
+ if (goodsDonSkuView == null) {
|
|
|
+ throw BusinessRuntimeException.getInstance("所选平台与规格不匹配");
|
|
|
+ }
|
|
|
+ EasyExcel.read(file.getInputStream(), ExcelImportAccountData.class, new AnalysisEventListener<ExcelImportAccountData>() {
|
|
|
+ @SneakyThrows
|
|
|
+ @Override
|
|
|
+ public void invoke(ExcelImportAccountData data, AnalysisContext analysisContext) {
|
|
|
+ String account = data.getAccount(), password = data.getPassword(), startTime = data.getStartTime(), expiryTime = data.getExpiryTime();
|
|
|
+ if (StrUtil.isNotBlank(data.getAccount())) {
|
|
|
+ //账号是否已经添加过
|
|
|
+ if (!account.contains("客服")) {
|
|
|
+ int count = accountService.count(Wrappers.lambdaQuery(Account.class)
|
|
|
+ .eq(Account::getAccount, account)
|
|
|
+ .eq(Account::getGoodsId, goodsId));
|
|
|
+ if (count > 0) {
|
|
|
+ log.info("该平台下:{}已生成该账号:{}", goodsId, account);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Account at = new Account();
|
|
|
+ at.setAccount(account.trim());
|
|
|
+ at.setPassword(password.trim());
|
|
|
+ at.setGoodsId(goodsId);
|
|
|
+ at.setSkuId(skuId);
|
|
|
+ if (StrUtil.isNotBlank(startTime)) {
|
|
|
+ at.setStartTime(DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(expiryTime)) {
|
|
|
+ at.setExpiryTime(DateUtil.parse(expiryTime, "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ }
|
|
|
+ accountService.save(at);
|
|
|
+ //自动配置车队
|
|
|
+ GroupsTrips groupsTrips = new GroupsTrips();
|
|
|
+ groupsTrips.setSkuId(at.getSkuId());
|
|
|
+ groupsTrips.setAccountId(at.getId());
|
|
|
+ cmsGroupService.issuance(groupsTrips);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }).sheet().doRead();
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult("导入账号成功");
|
|
|
+ }
|
|
|
+
|
|
|
@PutMapping("/update")
|
|
|
@SaCheckPermission("account:update")
|
|
|
@Log(module = "平台管理/编辑账号", businessType = BusinessType.PUT, isSaveRequestData = true)
|