|
|
@@ -10,6 +10,7 @@ import com.google.common.collect.Maps;
|
|
|
import com.google.common.collect.Sets;
|
|
|
import com.ruoyi.common.annotation.Excel;
|
|
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
|
|
+import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
import com.ruoyi.common.enums.ExamType;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
@@ -234,7 +235,7 @@ public class DzCardsServiceImpl implements IDzCardsService
|
|
|
newOpen.setEndDate(DateUtils.addDays(DateUtils.getNowDate(), 14)); // TODO MF 卡默认有效期
|
|
|
newOpen.setSchoolId(schoolId);
|
|
|
newOpen.setIsReopen(0);
|
|
|
- newOpen.setStatus(RequestStatus.Pass.getVal());
|
|
|
+ newOpen.setStatus(RequestStatus.Accept.getVal());
|
|
|
dzCardsOpenMapper.insertDzCardsOpen(newOpen);
|
|
|
// TODO MF 检查已经使用的或无效的
|
|
|
CardCriteria cond = new CardCriteria();
|
|
|
@@ -257,46 +258,57 @@ public class DzCardsServiceImpl implements IDzCardsService
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Boolean requestOpenCard(Long schoolId, Long agentId, String beginNo, String endNo) {
|
|
|
-
|
|
|
- DzCardsOpen newOpen = new DzCardsOpen();
|
|
|
- newOpen.setAgentId(agentId);
|
|
|
- newOpen.setStartNo(beginNo);
|
|
|
- newOpen.setEndNo(endNo);
|
|
|
- newOpen.setEndDate(DateUtils.addDays(DateUtils.getNowDate(), 14)); // TODO MF 卡默认有效期
|
|
|
- newOpen.setSchoolId(schoolId);
|
|
|
- newOpen.setIsReopen(0);
|
|
|
- newOpen.setStatus(RequestStatus.Wait.getVal());
|
|
|
- dzCardsOpenMapper.insertDzCardsOpen(newOpen);
|
|
|
+ public Boolean requestOpenCard(DzCardsOpen dzCardsOpen) {
|
|
|
+ SysUser sysUser = SecurityUtils.getLoginUser().getUser();
|
|
|
+ if(UserTypeEnum.Agent.equals(sysUser.getUserType())) {
|
|
|
+ dzCardsOpen.setAgentId(sysUser.getUserTypeId());
|
|
|
+ } else {
|
|
|
+ dzCardsOpen.setAgentId(0L);
|
|
|
+ }
|
|
|
+ dzCardsOpen.setStatus(RequestStatus.Submit.getVal());
|
|
|
+ dzCardsOpen.setEndDate(DateUtils.addDays(DateUtils.getNowDate(), 14));
|
|
|
+ dzCardsOpen.setIsReopen(0);
|
|
|
+ dzCardsOpenMapper.insertDzCardsOpen(dzCardsOpen);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void confirmOpenCard(Long openId, Long userId) {
|
|
|
- DzCardsOpen open = dzCardsOpenMapper.selectDzCardsOpenById(openId);
|
|
|
- if(!open.getStatus().equals(RequestStatus.Wait.getVal())) {
|
|
|
- throw new ValidationException("无效状态");
|
|
|
+ public Boolean confirmOpenCard(DzCardsOpen dzCardsOpen, SysUser sysUser) {
|
|
|
+ DzCardsOpen exist = dzCardsOpenMapper.selectDzCardsOpenById(dzCardsOpen.getId());
|
|
|
+ if(UserTypeEnum.Agent.equals(sysUser.getUserType()) && !exist.getAgentId().equals(dzCardsOpen.getAgentId())) {
|
|
|
+ throw new ValidationException("不可修改他人申请");
|
|
|
}
|
|
|
- CardCriteria cond = new CardCriteria();
|
|
|
- cond.setStartNo(open.getStartNo());
|
|
|
- cond.setEndNo(open.getEndNo());
|
|
|
- List<DzCards> cards = dzCardsMapper.selectListByCond(cond);
|
|
|
- if(cards.stream().filter(t -> !t.getPayStatus().equals(PayStatus.UnPay.getVal())).count() > 0) {
|
|
|
- throw new ValidationException("重复打开已开卡: " + open.getStartNo() + "-" + open.getEndNo());
|
|
|
+ if(RequestStatus.Accept.getVal().equals(exist.getStatus())) {
|
|
|
+ throw new ValidationException("不可修改已经通过的申请");
|
|
|
}
|
|
|
- DzCards dzCards = new DzCards();
|
|
|
- cards.stream().forEach(c -> {
|
|
|
- dzCards.setCardId(c.getCardId());
|
|
|
- dzCards.setPayTime(DateUtils.getNowDate());
|
|
|
- dzCards.setPayStatus(PayStatus.Paid.getVal());
|
|
|
- dzCards.setStatus(CardStatus.Paid.getVal());
|
|
|
- dzCardsMapper.updateDzCards(dzCards);
|
|
|
- });
|
|
|
- DzCardsOpen up = new DzCardsOpen();
|
|
|
- up.setId(openId);
|
|
|
- up.setStatus(RequestStatus.Pass.getVal());
|
|
|
- dzCardsOpenMapper.updateDzCardsOpen(up);
|
|
|
+ if(!RequestStatus.Submit.getVal().equals(exist.getStatus())) {
|
|
|
+ throw new ValidationException("状态无效");
|
|
|
+ }
|
|
|
+ DzCardsOpen upOpen = new DzCardsOpen();
|
|
|
+ upOpen.setId(dzCardsOpen.getId());
|
|
|
+ upOpen.setStatus(RequestStatus.Accept.getVal().equals(dzCardsOpen.getStatus()) ? RequestStatus.Accept.getVal() : RequestStatus.Reject.getVal());
|
|
|
+ upOpen.setAuditDesc(dzCardsOpen.getAuditDesc());
|
|
|
+
|
|
|
+ if(RequestStatus.Accept.getVal().equals(upOpen.getStatus())) {
|
|
|
+ CardCriteria cond = new CardCriteria();
|
|
|
+ cond.setStartNo(exist.getStartNo());
|
|
|
+ cond.setEndNo(exist.getEndNo());
|
|
|
+ List<DzCards> cards = dzCardsMapper.selectListByCond(cond);
|
|
|
+ if(cards.stream().filter(t -> !t.getPayStatus().equals(PayStatus.UnPay.getVal())).count() > 0) {
|
|
|
+ throw new ValidationException("重复打开已开卡: " + exist.getStartNo() + "-" + exist.getEndNo());
|
|
|
+ }
|
|
|
+ DzCards dzCards = new DzCards();
|
|
|
+ cards.stream().forEach(c -> {
|
|
|
+ dzCards.setCardId(c.getCardId());
|
|
|
+ dzCards.setPayTime(DateUtils.getNowDate());
|
|
|
+ dzCards.setPayStatus(PayStatus.Paid.getVal());
|
|
|
+ dzCards.setStatus(CardStatus.Paid.getVal());
|
|
|
+ dzCardsMapper.updateDzCards(dzCards);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ dzCardsOpenMapper.updateDzCardsOpen(upOpen);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -326,6 +338,7 @@ public class DzCardsServiceImpl implements IDzCardsService
|
|
|
if(cards.stream().filter(t -> t.getPayStatus().equals(PayStatus.Refund.getVal())).count() > 0) {
|
|
|
throw new ValidationException("重复退款: " + StringUtils.join(cardIds, ","));
|
|
|
}
|
|
|
+ up.setDistributeStatus(CardDistributeStatus.Close.getVal());
|
|
|
up.setPayStatus(PayStatus.Refund.getVal());
|
|
|
up.setRefundTime(DateUtils.getNowDate());
|
|
|
} else {
|