|
|
@@ -51,17 +51,31 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
|
|
|
ambInvest.setOperator(TokenManager.getAdminId());
|
|
|
ambInvest.setComment(in.getComment());
|
|
|
ambInvestMapper.insertSelective(ambInvest);
|
|
|
- AmbInvestLog log=new AmbInvestLog();
|
|
|
- log.setAmbInvestId(ambInvest.getId());
|
|
|
- log.setComment(in.getComment());
|
|
|
- log.setOperator(TokenManager.getAdminId());
|
|
|
- log.setStatus(1);
|
|
|
- ambInvestLogMapper.insertSelective(log);
|
|
|
- String str="["+myAmb.getName()+"]管理员发起了对["+other.getName()+"]"+"的金额投资,请及时确认!";
|
|
|
- asyncUtils.addNoticAndEmail(myAmb.getAccountant(), NoticeStatus.AMB_INVEST_START.getCode(),str );
|
|
|
+ addAmbInvestLog(in, ambInvest);
|
|
|
+ if (in.getStatus()==1)addNoticAndEmail(1,myAmb,other);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
+ private void addNoticAndEmail(Integer i,AmbSystem myAmb,AmbSystem other) {
|
|
|
+ StringBuffer str=new StringBuffer();
|
|
|
+ Integer notceType=0;
|
|
|
+ String aid="";
|
|
|
+ if (i==1){
|
|
|
+ aid=myAmb.getAccountant();
|
|
|
+ str=str.append("[").append(myAmb.getName()).append("]负责人发起了对[").append(other.getName()).append("]"+"的金额投资,请及时确认!");
|
|
|
+ notceType=NoticeStatus.AMB_INVEST_START.getCode();
|
|
|
+ }else if (i==2){
|
|
|
+ str=str.append("发起的对[").append(other.getName()).append("]"+"的金额投资,已通过审核!");
|
|
|
+ notceType=NoticeStatus.AMB_INVEST_YES.getCode();
|
|
|
+ aid=myAmb.getLeader();
|
|
|
+ }else if (i==3){
|
|
|
+ str=str.append("发起的对[").append(other.getName()).append("]"+"的金额投资,已拒绝,请及时修改!");
|
|
|
+ notceType=NoticeStatus.AMB_INVEST_NO.getCode();
|
|
|
+ aid=myAmb.getLeader();
|
|
|
+ }
|
|
|
+ asyncUtils.addNoticAndEmail(aid,notceType ,str.toString());
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public boolean checkMyAmb(Long myAmbId) {
|
|
|
AmbSystem myAmb = ambSystemMapper.selectByPrimaryKey(myAmbId);
|
|
|
@@ -85,4 +99,56 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
|
|
|
public List<OutInvestLog> InvestLog(String id) {
|
|
|
return ambInvestLogMapper.selectByAmbInvestId(id);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int updateInvestTransfer(InputAmbInvest in) {
|
|
|
+ AmbSystem myAmb = ambSystemMapper.selectByPrimaryKey(in.getMyAmbId());
|
|
|
+ AmbSystem other=ambSystemMapper.selectByPrimaryKey(in.getOtherAmbId());
|
|
|
+ AmbInvest ambInvest=new AmbInvest();
|
|
|
+ ambInvest.setId(in.getId());
|
|
|
+ if (in.getOtherAmbId()!=null)ambInvest.setAcceptAmbId(in.getOtherAmbId());
|
|
|
+ if (in.getAmount()!=null)ambInvest.setAmount(in.getAmount());
|
|
|
+ if (in.getStatus()!=null)ambInvest.setStatus(in.getStatus());
|
|
|
+ if (in.getComment()!=null)ambInvest.setComment(in.getComment());
|
|
|
+ ambInvest.setOperator(TokenManager.getAdminId());
|
|
|
+ ambInvestMapper.updateByPrimaryKeySelective(ambInvest);
|
|
|
+ addAmbInvestLog(in, ambInvest);
|
|
|
+ if (in.getStatus()==1)addNoticAndEmail(1,myAmb,other);
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public int updateExamineTransfer(InputAmbInvest in) {
|
|
|
+ AmbInvest ambInvest = ambInvestMapper.selectByPrimaryKey(in.getId());
|
|
|
+ AmbSystem myAmb = ambSystemMapper.selectByPrimaryKey(ambInvest.getInitiateAmbId());
|
|
|
+ AmbSystem other=ambSystemMapper.selectByPrimaryKey(ambInvest.getAcceptAmbId());
|
|
|
+ AmbInvest newAmbInvest=new AmbInvest();
|
|
|
+ newAmbInvest.setId(in.getId());
|
|
|
+ newAmbInvest.setStatus(in.getStatus());
|
|
|
+ if (in.getStatus()==2){
|
|
|
+ AmbSystem newMy=new AmbSystem();
|
|
|
+ newMy.setId(myAmb.getId());
|
|
|
+ newMy.setSurplus(myAmb.getSurplus().subtract(ambInvest.getAmount()));
|
|
|
+ newMy.setForeign(myAmb.getForeign().add(ambInvest.getAmount()));
|
|
|
+ AmbSystem newOther=new AmbSystem();
|
|
|
+ newOther.setId(other.getId());
|
|
|
+ newOther.setReceived(other.getReceived().add(ambInvest.getAmount()));
|
|
|
+ ambSystemMapper.updateByPrimaryKeySelective(newMy);
|
|
|
+ ambSystemMapper.updateByPrimaryKeySelective(newOther);
|
|
|
+ }
|
|
|
+ ambInvestMapper.updateByPrimaryKeySelective(newAmbInvest);
|
|
|
+ addAmbInvestLog(in, ambInvest);
|
|
|
+ addNoticAndEmail(in.getStatus(),myAmb,other);
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addAmbInvestLog(InputAmbInvest in, AmbInvest ambInvest) {
|
|
|
+ AmbInvestLog log = new AmbInvestLog();
|
|
|
+ log.setAmbInvestId(ambInvest.getId());
|
|
|
+ log.setComment(in.getComment());
|
|
|
+ log.setOperator(TokenManager.getAdminId());
|
|
|
+ log.setStatus(in.getStatus());
|
|
|
+ ambInvestLogMapper.insertSelective(log);
|
|
|
+ }
|
|
|
}
|