|
|
@@ -2,16 +2,16 @@ package com.zhongshu.card.server.core.service.school;
|
|
|
|
|
|
import com.github.microservice.auth.client.content.ResultState;
|
|
|
import com.github.microservice.auth.client.service.UserService;
|
|
|
-import com.zhongshu.card.client.model.school.CardInfoModel;
|
|
|
-import com.zhongshu.card.client.model.school.CardInfoParam;
|
|
|
-import com.zhongshu.card.client.model.school.CardInfoSimpleModel;
|
|
|
-import com.zhongshu.card.client.model.school.CardLossParam;
|
|
|
+import com.github.microservice.components.data.base.util.PageEntityUtil;
|
|
|
+import com.zhongshu.card.client.model.org.OidAboutInfo;
|
|
|
+import com.zhongshu.card.client.model.org.OrganizationUserModel;
|
|
|
+import com.zhongshu.card.client.model.school.*;
|
|
|
import com.zhongshu.card.client.ret.ResultContent;
|
|
|
import com.zhongshu.card.client.ret.ResultMessage;
|
|
|
import com.zhongshu.card.client.service.school.CardInfoService;
|
|
|
import com.zhongshu.card.client.utils.type.CardOperationType;
|
|
|
import com.zhongshu.card.client.utils.type.school.CardState;
|
|
|
-import com.zhongshu.card.server.core.dao.CardInfoDao;
|
|
|
+import com.zhongshu.card.server.core.dao.school.CardInfoDao;
|
|
|
import com.zhongshu.card.server.core.dao.org.OrganizationDao;
|
|
|
import com.zhongshu.card.server.core.dao.org.UserCountDao;
|
|
|
import com.zhongshu.card.server.core.dao.school.CardInfoPoolDao;
|
|
|
@@ -22,11 +22,15 @@ import com.zhongshu.card.server.core.domain.school.CardInfo;
|
|
|
import com.zhongshu.card.server.core.domain.school.CardInfoLossRecord;
|
|
|
import com.zhongshu.card.server.core.domain.school.CardInfoPool;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
+import com.zhongshu.card.server.core.service.org.OrganizationServiceImpl;
|
|
|
+import com.zhongshu.card.server.core.service.org.UserAccountServiceImpl;
|
|
|
import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.Assert;
|
|
|
@@ -63,6 +67,12 @@ public class CardInfoServiceImpl extends SuperService implements CardInfoService
|
|
|
@Autowired
|
|
|
CardInfoPoolDao cardInfoPoolDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ OrganizationServiceImpl organizationService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ UserAccountServiceImpl userAccountService;
|
|
|
+
|
|
|
/**
|
|
|
* 添加或修改卡片信息
|
|
|
*
|
|
|
@@ -131,6 +141,7 @@ public class CardInfoServiceImpl extends SuperService implements CardInfoService
|
|
|
}
|
|
|
cardInfo = new CardInfo();
|
|
|
initEntity(cardInfo);
|
|
|
+
|
|
|
String userId = getCurrentUserId();
|
|
|
UserAccount account = userCountDao.findTopByUserId(userId);
|
|
|
cardInfo.setName(cardInfoPool.getName());
|
|
|
@@ -393,7 +404,7 @@ public class CardInfoServiceImpl extends SuperService implements CardInfoService
|
|
|
if (ObjectUtils.isEmpty(cardInfo)) {
|
|
|
return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
|
|
|
}
|
|
|
- CardInfoModel model = toModel(cardInfo);
|
|
|
+ CardInfoModel model = toOrgModel(cardInfo);
|
|
|
return ResultContent.buildSuccess(model);
|
|
|
}
|
|
|
|
|
|
@@ -408,6 +419,117 @@ public class CardInfoServiceImpl extends SuperService implements CardInfoService
|
|
|
return ResultContent.buildSuccess(model);
|
|
|
}
|
|
|
|
|
|
+ //----------------------------园区卡片操作 start ------------------------
|
|
|
+
|
|
|
+ public ResultContent<Page<CardInfoPoolModel>> page(CardInfoSearch param, Pageable pageable) {
|
|
|
+ initOidSearchParam(param);
|
|
|
+ String oid = param.getOid();
|
|
|
+ OidAboutInfo aboutInfo = organizationService.getOidAboutOrgInfo(oid);
|
|
|
+ param.setProjectOid(aboutInfo.getProjectOid());
|
|
|
+ param.setSchoolOid(aboutInfo.getSchoolOid());
|
|
|
+ Page<CardInfo> page = cardInfoDao.page(pageable, param);
|
|
|
+ return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toOrgModel));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 卡片ID挂失 (园区管理员操作)
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent lossById(String id) {
|
|
|
+ Assert.hasText(id, "id不能为空");
|
|
|
+ String userId = getCurrentUserId();
|
|
|
+ UserAccount userAccount = userCountDao.findTopByUserId(userId);
|
|
|
+
|
|
|
+ CardInfo cardInfo = cardInfoDao.findTopById(id);
|
|
|
+ if (ObjectUtils.isEmpty(cardInfo)) {
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
|
|
|
+ }
|
|
|
+ if (cardInfo.getCardState() == CardState.Loss) {
|
|
|
+ return ResultContent.buildFail(String.format("卡片已是锁定状态:%s", cardInfo.getCode()));
|
|
|
+ }
|
|
|
+ cardInfo.setCardState(CardState.Loss);
|
|
|
+ initUpdateEntity(cardInfo);
|
|
|
+ cardInfoDao.save(cardInfo);
|
|
|
+
|
|
|
+ CardInfoLossRecord cardInfoLossRecord = new CardInfoLossRecord();
|
|
|
+ cardInfoLossRecord.setCardInfo(cardInfo);
|
|
|
+ // 挂失操作人
|
|
|
+ cardInfoLossRecord.setOperUserAccount(userAccount);
|
|
|
+ cardInfoLossRecord.setOperUserId(userId);
|
|
|
+ // 卡片所属人
|
|
|
+ cardInfoLossRecord.setCardUserId(cardInfo.getUserId());
|
|
|
+ cardInfoLossRecord.setCardUserAccount(cardInfo.getUserAccount());
|
|
|
+ cardInfoLossRecord.setOperationType(CardOperationType.Loss);
|
|
|
+ cardInfoLossRecordDao.save(cardInfoLossRecord);
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 卡片启用 园区操作
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent enableById(String id) {
|
|
|
+ Assert.hasText(id, "id不能为空");
|
|
|
+ String userId = getCurrentUserId();
|
|
|
+ UserAccount userAccount = userCountDao.findTopByUserId(userId);
|
|
|
+
|
|
|
+ CardInfo cardInfo = cardInfoDao.findTopById(id);
|
|
|
+ if (ObjectUtils.isEmpty(cardInfo)) {
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
|
|
|
+ }
|
|
|
+ if (cardInfo.getCardState() == CardState.Enable) {
|
|
|
+ return ResultContent.buildFail(String.format("卡片已是启用状态:%s", cardInfo.getCode()));
|
|
|
+ }
|
|
|
+ cardInfo.setCardState(CardState.Enable);
|
|
|
+ initUpdateEntity(cardInfo);
|
|
|
+ cardInfoDao.save(cardInfo);
|
|
|
+
|
|
|
+ CardInfoLossRecord cardInfoLossRecord = new CardInfoLossRecord();
|
|
|
+ cardInfoLossRecord.setCardInfo(cardInfo);
|
|
|
+
|
|
|
+ cardInfoLossRecord.setOperUserAccount(userAccount);
|
|
|
+ cardInfoLossRecord.setOperUserId(userId);
|
|
|
+
|
|
|
+ cardInfoLossRecord.setCardUserId(cardInfo.getUserId());
|
|
|
+ cardInfoLossRecord.setCardUserAccount(cardInfo.getUserAccount());
|
|
|
+ cardInfoLossRecord.setOperationType(CardOperationType.Enable);
|
|
|
+ cardInfoLossRecordDao.save(cardInfoLossRecord);
|
|
|
+
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 作废卡片(园区操作)
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent cardCancel(String id) {
|
|
|
+ Assert.hasText(id, "id不能为空");
|
|
|
+ String userId = getCurrentUserId();
|
|
|
+ UserAccount userAccount = userCountDao.findTopByUserId(userId);
|
|
|
+ CardInfo cardInfo = cardInfoDao.findTopById(id);
|
|
|
+ if (ObjectUtils.isEmpty(cardInfo)) {
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
|
|
|
+ }
|
|
|
+ if (cardInfo.getIsCanceled() != null && cardInfo.getIsCanceled()) {
|
|
|
+ return ResultContent.buildFail(String.format("卡片已是作废状态:%s", cardInfo.getCode()));
|
|
|
+ }
|
|
|
+ initUpdateEntity(cardInfo);
|
|
|
+ cardInfo.setIsCanceled(Boolean.TRUE);
|
|
|
+ cardInfo.setCancelUserId(userId);
|
|
|
+ cardInfo.setCancelTime(System.currentTimeMillis());
|
|
|
+ cardInfoDao.save(cardInfo);
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ //----------------------------园区卡片操作 end --------------------------
|
|
|
+
|
|
|
+
|
|
|
public CardInfoModel toModel(CardInfo entity) {
|
|
|
CardInfoModel model = null;
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
@@ -417,6 +539,19 @@ public class CardInfoServiceImpl extends SuperService implements CardInfoService
|
|
|
return model;
|
|
|
}
|
|
|
|
|
|
+ public CardInfoModel toOrgModel(CardInfo entity) {
|
|
|
+ CardInfoModel model = null;
|
|
|
+ if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
+ model = new CardInfoModel();
|
|
|
+ BeanUtils.copyProperties(entity, model);
|
|
|
+
|
|
|
+ // 机构用户信息
|
|
|
+ OrganizationUserModel organizationUser = userAccountService.getOrgUserDetail(entity.getSchoolOid(), entity.getUserId());
|
|
|
+ model.setOrganizationUser(organizationUser);
|
|
|
+ }
|
|
|
+ return model;
|
|
|
+ }
|
|
|
+
|
|
|
public CardInfoSimpleModel toSimpleModel(CardInfo entity) {
|
|
|
CardInfoSimpleModel model = null;
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|