|
@@ -1,27 +1,38 @@
|
|
|
package com.yonge.cooleshow.admin.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.microsvc.toolkit.common.response.paging.PageInfo;
|
|
|
import com.microsvc.toolkit.common.response.paging.QueryInfo;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.TenantActivationCode;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.TenantAlbumPurchase;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
|
|
|
import com.yonge.cooleshow.biz.dal.service.TenantActivationCodeService;
|
|
|
import com.yonge.cooleshow.biz.dal.service.TenantAlbumPurchaseService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.TenantActivationCodeWrapper;
|
|
|
import com.yonge.cooleshow.common.controller.BaseController;
|
|
|
import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
+import com.yonge.cooleshow.tenant.vo.TenantActivationCodeVo;
|
|
|
import com.yonge.toolset.base.exception.BizException;
|
|
|
-import com.yonge.toolset.base.page.PageInfo;
|
|
|
import com.yonge.toolset.mybatis.support.PageUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.text.ParsePosition;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
|
|
|
@Slf4j
|
|
|
@Validated
|
|
@@ -36,32 +47,69 @@ public class TenantActivationCodeController extends BaseController {
|
|
|
@Autowired
|
|
|
private TenantAlbumPurchaseService tenantAlbumPurchaseService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TenantInfoService tenantInfoService;
|
|
|
|
|
|
@ApiOperation(value = "查询分页", notes = "机构激活码- 传入 TenantActivationCodeVo.TenantActivationCodeQuery")
|
|
|
@PostMapping("/page")
|
|
|
+ @PreAuthorize("@pcs.hasPermissions('tenantActivationCode/page')")
|
|
|
public HttpResponseResult<PageInfo<TenantActivationCodeWrapper.TenantActivationCode>> page(
|
|
|
@RequestBody TenantActivationCodeWrapper.TenantActivationCodeQuery query) {
|
|
|
|
|
|
- if (StringUtils.isBlank(query.getOrderNo())) {
|
|
|
- throw new BizException("订单号不能为空");
|
|
|
+ String activationTime = query.getActivationTime();
|
|
|
+ if (StringUtils.isNotEmpty(activationTime)) {
|
|
|
+ Date parse = new SimpleDateFormat("yyyy-MM").parse(activationTime, new ParsePosition(0));
|
|
|
+ query.setActivationStartTime(parse);
|
|
|
+ Calendar instance = Calendar.getInstance();
|
|
|
+ instance.setTime(parse);
|
|
|
+ instance.add(Calendar.MONTH, 1);
|
|
|
+ instance.add(Calendar.DATE, -1);
|
|
|
+ instance.set(Calendar.HOUR_OF_DAY, 23);
|
|
|
+ instance.set(Calendar.MINUTE, 59);
|
|
|
+ instance.set(Calendar.MILLISECOND, 59);
|
|
|
+ query.setActivationEndTime(instance.getTime());
|
|
|
}
|
|
|
- // 查询订单购买的专辑
|
|
|
- TenantAlbumPurchase albumPurchase = tenantAlbumPurchaseService.getByOrderNo(query.getOrderNo());
|
|
|
- if (albumPurchase == null) {
|
|
|
- return succeed(new PageInfo<>());
|
|
|
- }
|
|
|
- query.setActivationStatus(true);
|
|
|
- query.setTenantAlbumPurchaseId(albumPurchase.getId());
|
|
|
- // 查询数据
|
|
|
IPage<TenantActivationCodeWrapper.TenantActivationCode> pages =
|
|
|
tenantActivationCodeService.selectPage(QueryInfo.getPage(query), query);
|
|
|
- PageInfo<TenantActivationCodeWrapper.TenantActivationCode> pageInfo = PageUtil.pageInfo(pages);
|
|
|
+ com.microsvc.toolkit.common.response.paging.PageInfo<TenantActivationCodeWrapper.TenantActivationCode> pageInfo = QueryInfo.pageInfo(pages,
|
|
|
+ pages.getRecords());
|
|
|
|
|
|
if (query.getTenantAlbumPurchaseId() != null) {
|
|
|
- pageInfo.setStatInfo(albumPurchase);
|
|
|
+ TenantActivationCodeWrapper.TenantActivationCode extra =
|
|
|
+ new TenantActivationCodeWrapper.TenantActivationCode();
|
|
|
+ TenantAlbumPurchase purchase = tenantAlbumPurchaseService.getById(query.getTenantAlbumPurchaseId());
|
|
|
+ extra.setActiveQuantity(purchase.getActiveQuantity());
|
|
|
+ pageInfo.setExtra(extra);
|
|
|
}
|
|
|
|
|
|
return succeed(pageInfo);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "激活码发放", notes = "机构激活码- 传入 TenantActivationCodeVo.TenantActivationCodeSend")
|
|
|
+ @PostMapping("/send")
|
|
|
+ @PreAuthorize("@pcs.hasPermissions('tenantActivationCode/send')")
|
|
|
+ public HttpResponseResult<Boolean> send(@Validated @RequestBody TenantActivationCodeVo.TenantActivationCodeSend send) {
|
|
|
+ tenantActivationCodeService.sendActivationCode(send.getTenantId(), send.getTenantAlbumPurchaseId(),
|
|
|
+ send.getActivationCodeList(),
|
|
|
+ send.getStudentIdList());
|
|
|
+ return succeed();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "激活码重发", notes = "机构激活码- 传入 TenantActivationCodeVo.TenantActivationCodeSend")
|
|
|
+ @PostMapping("/resend")
|
|
|
+ @PreAuthorize("@pcs.hasPermissions('tenantActivationCode/resend')")
|
|
|
+ public HttpResponseResult<Boolean> resend(@Validated @RequestBody TenantActivationCodeVo.TenantActivationCodeResend send) {
|
|
|
+ tenantActivationCodeService.resend(send.getCode(), send.getUserId(), send.getTenantId(), send.getTenantAlbumPurchaseId());
|
|
|
+ return succeed();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "激活码发放取消", notes = "传入 激活码的ID")
|
|
|
+ @PostMapping("/sendCancel")
|
|
|
+ @PreAuthorize("@pcs.hasPermissions('tenantActivationCode/sendCancel')")
|
|
|
+ public HttpResponseResult<Boolean> sendCancel(@Validated @RequestBody TenantActivationCodeVo.CodeSend codeSend) {
|
|
|
+ TenantActivationCode activationCode = tenantActivationCodeService.getById(codeSend.getId());
|
|
|
+ TenantInfo tenantInfo = tenantInfoService.getById(codeSend.getTenantId());
|
|
|
+ tenantActivationCodeService.sendCancel(tenantInfo, activationCode);
|
|
|
+ return succeed();
|
|
|
+ }
|
|
|
}
|