|
|
@@ -28,6 +28,7 @@ import com.cyksj.model.excel.*;
|
|
|
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.request.AccountPrepareReq;
|
|
|
import com.cyksj.model.response.ExpiredAccountRep;
|
|
|
import com.cyksj.model.response.OrderDonAccountRep;
|
|
|
import com.cyksj.model.views.*;
|
|
|
@@ -962,6 +963,64 @@ public class CmsAccountController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(repeat);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 导入备用账号模板
|
|
|
+ */
|
|
|
+ @GetMapping("/export/prepare/template")
|
|
|
+ public void getPrepareTemplate(HttpServletResponse response) {
|
|
|
+ EasyExcelUtils.createTemplateExcel(response, ExcelPrepareAccountData.class, "导入备用账号模板", "导入备用账号模板", ExcelTypeEnum.XLSX, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量导入备用账号
|
|
|
+ */
|
|
|
+ @PostMapping("/batch/import/prepare")
|
|
|
+ public Result<String> batchImportPrepare(Long goodsId, String preSkuIds, MultipartFile file) throws IOException {
|
|
|
+ if (goodsId == null) {
|
|
|
+ throw BusinessRuntimeException.getInstance("请选择对应平台");
|
|
|
+ }
|
|
|
+ if (goodsId == 26) {
|
|
|
+ if (StrUtil.isEmpty(preSkuIds)) {
|
|
|
+ throw BusinessRuntimeException.getInstance("请选择对应规格id");
|
|
|
+ }
|
|
|
+ String[] split = preSkuIds.split(",");
|
|
|
+ preSkuIds = Arrays.stream(split).distinct().collect(Collectors.joining(","));
|
|
|
+ }
|
|
|
+ final String f_skuIds = preSkuIds;
|
|
|
+ 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.setPreSkuIds(f_skuIds);
|
|
|
+ insert.setType(2);
|
|
|
+ insert.setStartTime(DateTime.now());
|
|
|
+ insert.setExpiryTime(DateUtil.offsetMonth(DateTime.now(), 1));
|
|
|
+ //账号是否已经添加过
|
|
|
+ if (!insert.getAccount().contains("客服")) {
|
|
|
+ if (accountCommonService.checkIsDupAccount(insert.getGoodsId(), insert.getAccount())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ insert.setType(2);
|
|
|
+ accountService.save(insert);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }).sheet().doRead();
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 新增预备账号
|
|
|
*/
|