|
|
@@ -9,6 +9,7 @@ import com.zhongshu.card.client.model.school.*;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
|
import com.github.microservice.net.ResultMessage;
|
|
|
import com.zhongshu.card.client.service.school.CardInfoService;
|
|
|
+import com.zhongshu.card.client.type.CardCancelState;
|
|
|
import com.zhongshu.card.client.type.CardOperationType;
|
|
|
import com.zhongshu.card.client.type.school.CardState;
|
|
|
import com.zhongshu.card.server.core.dao.school.CardInfoDao;
|
|
|
@@ -23,6 +24,7 @@ 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.orgManager.OrganizationManagerServiceImpl;
|
|
|
import com.zhongshu.card.server.core.service.user.UserAccountServiceImpl;
|
|
|
import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -73,6 +75,9 @@ public class CardInfoServiceImpl extends SuperService implements CardInfoService
|
|
|
@Autowired
|
|
|
UserAccountServiceImpl userAccountService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ OrganizationManagerServiceImpl organizationManagerService;
|
|
|
+
|
|
|
/**
|
|
|
* 添加或修改卡片信息
|
|
|
*
|
|
|
@@ -81,13 +86,16 @@ public class CardInfoServiceImpl extends SuperService implements CardInfoService
|
|
|
*/
|
|
|
@Override
|
|
|
public ResultContent addCardInfo(CardInfoParam param) {
|
|
|
+ checkParamOid(param);
|
|
|
initDefaultUserParam(param);
|
|
|
if (StringUtils.isEmpty(param.getCode())) {
|
|
|
return ResultContent.buildFail("code不能为空");
|
|
|
}
|
|
|
String oid = param.getOid();
|
|
|
+
|
|
|
String code = param.getCode();
|
|
|
CardInfo cardInfo = new CardInfo();
|
|
|
+
|
|
|
CardInfo temp = cardInfoDao.findByCode(code);
|
|
|
if (StringUtils.isNotEmpty(param.getId())) {
|
|
|
cardInfo = cardInfoDao.findTopById(param.getId());
|
|
|
@@ -102,7 +110,8 @@ public class CardInfoServiceImpl extends SuperService implements CardInfoService
|
|
|
return ResultContent.buildFail(String.format("卡号已存在:%s", code));
|
|
|
}
|
|
|
}
|
|
|
- BeanUtils.copyProperties(param, cardInfo, "cardState");
|
|
|
+ BeanUtils.copyProperties(param, cardInfo, "cardState", "isCanceled");
|
|
|
+
|
|
|
if (cardInfo.getCardState() == null) {
|
|
|
cardInfo.setCardState(CardState.Enable);
|
|
|
}
|
|
|
@@ -110,11 +119,16 @@ public class CardInfoServiceImpl extends SuperService implements CardInfoService
|
|
|
Organization organization = organizationDao.findTopByOid(oid);
|
|
|
cardInfo.setOrganization(organization);
|
|
|
}
|
|
|
+ OidAboutInfo oidAboutInfo = organizationManagerService.getOidAboutInfo(oid);
|
|
|
UserAccount account = userCountDao.findTopByUserId(param.getUserId());
|
|
|
cardInfo.setUserAccount(account);
|
|
|
cardInfo.setUserId(account.getUserId());
|
|
|
cardInfo.setUserName(account.getName());
|
|
|
cardInfo.setPhone(account.getPhone());
|
|
|
+
|
|
|
+ cardInfo.setProjectOid(oidAboutInfo.getProjectOid());
|
|
|
+ cardInfo.setAboutOid(oidAboutInfo.getOid());
|
|
|
+ cardInfo.setAboutAuthType(oidAboutInfo.getAuthType());
|
|
|
cardInfoDao.save(cardInfo);
|
|
|
|
|
|
return ResultContent.buildSuccess();
|
|
|
@@ -129,13 +143,22 @@ public class CardInfoServiceImpl extends SuperService implements CardInfoService
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public ResultContent bindCardFromPool(String poolId, String userId) {
|
|
|
+ if (StringUtils.isEmpty(userId)) {
|
|
|
+ return ResultContent.buildFail("userId不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(poolId)) {
|
|
|
+ return ResultContent.buildFail("poolId不能为空");
|
|
|
+ }
|
|
|
// 卡池数据
|
|
|
CardInfoPool cardInfoPool = cardInfoPoolDao.findTopById(poolId);
|
|
|
if (ObjectUtils.isEmpty(cardInfoPool)) {
|
|
|
return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, poolId));
|
|
|
}
|
|
|
- if (StringUtils.isEmpty(userId)) {
|
|
|
- userId = getCurrentUserId();
|
|
|
+ if (cardInfoPool.getIsUsed() != null && cardInfoPool.getIsUsed()) {
|
|
|
+ return ResultContent.buildFail(String.format("卡片已使用:%s", cardInfoPool.getCode()));
|
|
|
+ }
|
|
|
+ if (cardInfoPool.getCardCancelState() != null && cardInfoPool.getCardCancelState() != CardCancelState.Common) {
|
|
|
+ return ResultContent.buildFail(String.format("卡片:%s", cardInfoPool.getCardCancelState().getRemark()));
|
|
|
}
|
|
|
// 用户信息
|
|
|
UserAccount account = userCountDao.findTopByUserId(userId);
|
|
|
@@ -144,7 +167,6 @@ public class CardInfoServiceImpl extends SuperService implements CardInfoService
|
|
|
}
|
|
|
|
|
|
String code = cardInfoPool.getCode();
|
|
|
- String projectOid = cardInfoPool.getProjectOid();
|
|
|
CardInfo cardInfo = cardInfoDao.findByCode(code);
|
|
|
if (ObjectUtils.isNotEmpty(cardInfo)) {
|
|
|
return ResultContent.buildFail(String.format("卡号已存在:%s", code));
|
|
|
@@ -155,8 +177,12 @@ public class CardInfoServiceImpl extends SuperService implements CardInfoService
|
|
|
cardInfo.setName(cardInfoPool.getName());
|
|
|
cardInfo.setCode(cardInfoPool.getCode());
|
|
|
cardInfo.setCardType(cardInfoPool.getCardType());
|
|
|
+
|
|
|
cardInfo.setProjectOid(cardInfoPool.getProjectOid());
|
|
|
cardInfo.setSchoolOid(cardInfoPool.getSchoolOid());
|
|
|
+ cardInfo.setAboutAuthType(cardInfoPool.getAboutAuthType());
|
|
|
+ cardInfo.setAboutOid(cardInfoPool.getAboutOid());
|
|
|
+
|
|
|
cardInfo.setCardState(CardState.Enable);
|
|
|
cardInfo.setUserAccount(account);
|
|
|
cardInfo.setUserId(userId);
|
|
|
@@ -173,15 +199,38 @@ public class CardInfoServiceImpl extends SuperService implements CardInfoService
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 解绑卡片
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ public ResultContent unBindCard(String id) {
|
|
|
+ CardInfo cardInfo = cardInfoDao.findTopById(id);
|
|
|
+ if (ObjectUtils.isEmpty(cardInfo)) {
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
|
|
|
+ }
|
|
|
+ // 删除用户的卡片
|
|
|
+ cardInfoDao.delete(cardInfo);
|
|
|
+
|
|
|
+ // 恢复卡池的数据
|
|
|
+ CardInfoPool cardInfoPool = cardInfoPoolDao.findTopByCode(cardInfo.getCode());
|
|
|
+ if (ObjectUtils.isNotEmpty(cardInfoPool)) {
|
|
|
+ cardInfoPool.setIsUsed(Boolean.FALSE);
|
|
|
+ cardInfoPoolDao.save(cardInfoPool);
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 得到当前用户所在 学校的所有卡片
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public ResultContent<List<CardInfoModel>> getCurrentUserOrgAll() {
|
|
|
+ public ResultContent<List<CardInfoModel>> getCurrentUserOrgAll(String oid) {
|
|
|
String userId = getCurrentUserId();
|
|
|
- String oid = getCurrentOid();
|
|
|
return ResultContent.buildSuccess(getUserOrgAllCard(userId, oid));
|
|
|
}
|
|
|
|
|
|
@@ -519,7 +568,6 @@ public class CardInfoServiceImpl extends SuperService implements CardInfoService
|
|
|
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));
|
|
|
@@ -535,6 +583,24 @@ public class CardInfoServiceImpl extends SuperService implements CardInfoService
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ResultContent restoreCardCancel(String id) {
|
|
|
+ Assert.hasText(id, "id不能为空");
|
|
|
+ String userId = getCurrentUserId();
|
|
|
+ CardInfo cardInfo = cardInfoDao.findTopById(id);
|
|
|
+ if (ObjectUtils.isEmpty(cardInfo)) {
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
|
|
|
+ }
|
|
|
+ initUpdateEntity(cardInfo);
|
|
|
+
|
|
|
+ // 设置是否作废:否
|
|
|
+ cardInfo.setIsCanceled(Boolean.FALSE);
|
|
|
+ cardInfo.setCancelUserId(userId);
|
|
|
+ cardInfo.setCancelTime(System.currentTimeMillis());
|
|
|
+ cardInfoDao.save(cardInfo);
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
//----------------------------园区卡片操作 end --------------------------
|
|
|
|
|
|
|