| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198 |
- package com.goafanti.organization.service.impl;
- import java.io.UnsupportedEncodingException;
- import java.lang.reflect.InvocationTargetException;
- import java.math.BigDecimal;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.UUID;
- import javax.mail.MessagingException;
- import javax.servlet.http.HttpServletResponse;
- import org.apache.commons.beanutils.BeanUtils;
- import org.apache.commons.collections4.map.HashedMap;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import com.goafanti.admin.bo.AdminListBo;
- import com.goafanti.common.bo.EmailBo;
- import com.goafanti.common.bo.Result;
- import com.goafanti.common.constant.AFTConstants;
- import com.goafanti.common.dao.AdminMapper;
- import com.goafanti.common.dao.CompanyLibraryMapper;
- import com.goafanti.common.dao.FinancialPaymentMapper;
- import com.goafanti.common.dao.OfficialFeePriceMapper;
- import com.goafanti.common.dao.PatentPriceMapper;
- import com.goafanti.common.dao.PaymentLogMapper;
- import com.goafanti.common.dao.PaymentNodeMapper;
- import com.goafanti.common.dao.SoftWritingPriceMapper;
- import com.goafanti.common.dao.TOrderMidMapper;
- import com.goafanti.common.dao.TOrderOutsourceMapper;
- import com.goafanti.common.dao.TOrderPaymentMapper;
- import com.goafanti.common.dao.TOrderTaskMapper;
- import com.goafanti.common.dao.TTaskMidMapper;
- import com.goafanti.common.dao.ThirdPartyCompanyMapper;
- import com.goafanti.common.enums.NoticeStatus;
- import com.goafanti.common.model.Admin;
- import com.goafanti.common.model.CompanyLibrary;
- import com.goafanti.common.model.Notice;
- import com.goafanti.common.model.OfficialFeePrice;
- import com.goafanti.common.model.PatentPrice;
- import com.goafanti.common.model.PaymentLog;
- import com.goafanti.common.model.PaymentNode;
- import com.goafanti.common.model.SoftWritingPrice;
- import com.goafanti.common.model.TOrderPayment;
- import com.goafanti.common.model.TOrderTask;
- import com.goafanti.common.model.TTaskMid;
- import com.goafanti.common.model.ThirdPartyCompany;
- import com.goafanti.common.utils.AsyncUtils;
- import com.goafanti.common.utils.DateUtils;
- import com.goafanti.common.utils.excel.NewExcelUtil;
- import com.goafanti.core.mybatis.BaseMybatisDao;
- import com.goafanti.core.mybatis.page.Pagination;
- import com.goafanti.core.shiro.token.TokenManager;
- import com.goafanti.order.bo.TOrderTaskDetailBo;
- import com.goafanti.order.enums.NewOrderDunType;
- import com.goafanti.order.enums.NewProjectStatus;
- import com.goafanti.organization.bo.InputNodeList;
- import com.goafanti.organization.bo.InputPaymentList;
- import com.goafanti.organization.bo.InputPaymentNode;
- import com.goafanti.organization.bo.InuptFinancialPayment;
- import com.goafanti.organization.bo.NoticeInformationBo;
- import com.goafanti.organization.bo.OutPaymentLog;
- import com.goafanti.organization.bo.OutPaymentNode;
- import com.goafanti.organization.bo.OutThirdPartyCompany;
- import com.goafanti.organization.bo.ProjectTypePuls;
- import com.goafanti.organization.bo.outFinancialPayment;
- import com.goafanti.organization.bo.outNodeList;
- import com.goafanti.organization.bo.outPaymentList;
- import com.goafanti.organization.bo.outPaymentListFinance;
- import com.goafanti.organization.bo.outPaymentListPatent;
- import com.goafanti.organization.bo.outProjectBo;
- import com.goafanti.organization.bo.outOrderPayment;
- import com.goafanti.organization.service.ThirdPartyCompanyService;
- @Service
- public class ThirdPartyCompanyServiceImpl extends BaseMybatisDao<ThirdPartyCompanyMapper> implements ThirdPartyCompanyService {
- @Autowired
- private ThirdPartyCompanyMapper thirdPartyCompanyMapper;
- @Autowired
- private CompanyLibraryMapper companyLibraryMapper;
- @Autowired
- private PaymentNodeMapper paymentNodeMapper;
- @Autowired
- private TOrderPaymentMapper tOrderPaymentMapper;
- @Autowired
- private PaymentLogMapper paymentLogMapper;
- @Autowired
- private AdminMapper adminMapper;
- @Autowired
- private FinancialPaymentMapper financialPaymentMapper;
- @Autowired
- private TOrderTaskMapper tOrderTaskMapper;
- @Autowired
- private SoftWritingPriceMapper softWritingPriceMapper;
- @Autowired
- private OfficialFeePriceMapper officialFeePriceMapper;
- @Autowired
- private PatentPriceMapper patentPriceMapper;
- @Autowired
- private TOrderOutsourceMapper tOrderOutsourceMapper;
- @Autowired
- private TTaskMidMapper tTaskMidMapper;
- @Autowired
- private TOrderMidMapper tOrderMidMapper;
- @Autowired
- private AsyncUtils asyncUtils;
-
- @Override
- public int addCompany(ThirdPartyCompany t,Integer calculation,Integer type) {
-
- CompanyLibrary c=new CompanyLibrary();
- String aid=TokenManager.getAdminId();
- if(calculation==0) {
- List<Integer> list=companyLibraryMapper.selectName(t.getCompanyName(),1,aid);
- if (list.size()<1) {
- c.setCompanyName(t.getCompanyName());
- c.setAid(aid);
- c.setType(1);//类型 0软著 1其他 2专利
- companyLibraryMapper.insertSelectiveGetId(c);
- t.setCid(c.getId());
- }else {
- t.setCid(list.get(0));
- }
- t.setTotalAmount(t.getUnitPrice().multiply(new BigDecimal(t.getQuantity())));
- }
- if (type!=null&&type==1) {
- tOrderTaskMapper.updateAddCostAmount(t.getTid(), t.getTotalAmount());
- tOrderMidMapper.updateAddCostAmount(t.getTid(), t.getTotalAmount());
- }
- thirdPartyCompanyMapper.insertSelective(t);
- return 1;
- }
-
- @Override
- public int updateCompany(ThirdPartyCompany t,Integer calculation) {
- if (calculation==0) {//0其他 1计算
- CompanyLibrary c=new CompanyLibrary();
- String aid=TokenManager.getAdminId();
- List<Integer> list=companyLibraryMapper.selectName(t.getCompanyName(),1,aid);
- if (list.size()<1) {
- c.setCompanyName(t.getCompanyName());
- c.setAid(aid);
- c.setType(1);//0系统 1录入
- companyLibraryMapper.insertSelectiveGetId(c);
- t.setCid(c.getId());
- }else {
- t.setCid(list.get(0));
- }
- t.setTotalAmount(t.getUnitPrice().multiply(new BigDecimal(t.getQuantity())));
- }
- thirdPartyCompanyMapper.updateByPrimaryKeySelective(t);
- return 1;
- }
- @Override
- public List<CompanyLibrary> selectVague(String name,Integer type) {
- String aid = null;
- if(type==null)type=1;
- if (type==1) aid=TokenManager.getAdminId();
- return companyLibraryMapper.selectVague(name,type,aid);
- }
- @Override
- public int addPaymentNode(InputPaymentNode p) {
- if (StringUtils.isNoneBlank(p.getPartyTimes())) {
- p.setPartyTime(DateUtils.StringToDate(p.getPartyTimes(), AFTConstants.YYYYMMDD));
- }
- return paymentNodeMapper.insertSelective(p);
- }
- @Override
- public boolean addNodeCheck(InputPaymentNode p) {
- ThirdPartyCompany t=thirdPartyCompanyMapper.selectByPrimaryKey(p.getCid());
- List<OutPaymentNode> list=paymentNodeMapper.selectByTidAndCid(p.getTid(),p.getCid());
- BigDecimal sum=p.getTotalAmount()==null?new BigDecimal(0):p.getTotalAmount();
- for (OutPaymentNode pn : list) {
- if (p.getId()==null || !pn.getId().equals(p.getId())) {
- sum=sum.add(pn.getTotalAmount());
- }
- }
- if(p.getUnitPrice()==null)p.setUnitPrice(t.getUnitPrice());
- if(p.getTotalAmount()==null)p.setTotalAmount(p.getUnitPrice().multiply(new BigDecimal(p.getQuantity())));
- if(p.getTotalAmount()==null)p.setTotalAmount(new BigDecimal(0));
- if (p.getTotalAmount().compareTo(t.getTotalAmount())>0) {
- return true;
- }
- if (sum.compareTo(t.getTotalAmount())>0) {
- return true;
- }
- return false;
- }
- @Override
- public int updatePaymentNode(InputPaymentNode p) {
- if (StringUtils.isNoneBlank(p.getPartyTimes())) {
- p.setPartyTime(DateUtils.StringToDate(p.getPartyTimes(), AFTConstants.YYYYMMDD));
- }
- if (p.getDunType()!=0) {
- PaymentNode pn=paymentNodeMapper.selectByPrimaryKey(p.getId());
- pn.setPartyTime(null);
- paymentNodeMapper.updateByPrimaryKey(pn);
- }
- return paymentNodeMapper.updateByPrimaryKeySelective(p);
- }
- @Override
- public List<OutThirdPartyCompany> selectCompany(Integer tid) {
- List<OutThirdPartyCompany> list=thirdPartyCompanyMapper.selectByTid(tid);
- if (!TokenManager.hasRole(AFTConstants.FINANCE)&&
- !TokenManager.hasRole(AFTConstants.FINANCE_MANAGER)&&
- !TokenManager.hasRole(AFTConstants.FINANCE_ADMIN)&&
- !TokenManager.hasRole(AFTConstants.OUTSOURCE_AUDITOR)) {
- outProjectBo op =null;
- if(!list.isEmpty()) op=tOrderOutsourceMapper.selectByTid(tid);
- //外包type
- for (OutThirdPartyCompany oc : list) {
- // start_type 0外包 1供应商
- if (oc.getStartType()==1) {
- //project_tyoe 0 正常 1专利 2软著 3审计
- if(op==null)op=new outProjectBo();
- if(op.getProjectType()==null)op.setProjectType(0);
- //patent_type 专利类型 0申请/变更/转让 1买卖
- if((op.getProjectType()==1&&oc.getPatentType()==0)
- || op.getProjectType()==2 ) {
- oc.setUnitPrice("***");
- oc.setTotalAmount("***");
- }
- }
- }
- }
- return list;
- }
- @Override
- public List<OutPaymentNode> selectPaymentNode(Integer tid) {
- List<OutPaymentNode> list=paymentNodeMapper.selectByTid(tid,null);
- return list;
- }
- @Override
- public int deleteCompany(String id) {
- if (id.contains(",")) {
- String []ids =id.split(",");
- for (String s : ids) {
- thirdPartyCompanyMapper.deleteByPrimaryKey(Integer.valueOf(s));
- }
- }else {
- Integer tpcId=Integer.valueOf(id);
- ThirdPartyCompany tpc=thirdPartyCompanyMapper.selectByPrimaryKey(tpcId);
- thirdPartyCompanyMapper.deleteByPrimaryKey(tpcId);
-
- List<outOrderPayment> list=tOrderPaymentMapper.selectList(tpcId, null, null);
- for (outOrderPayment o : list) {
- TOrderPayment t=new TOrderPayment();
- t.setId(o.getId());
- t.setStatus(4);
- tOrderPaymentMapper.updateByPrimaryKeySelective(t);
- }
- paymentNodeMapper.deleteByParam(tpcId,null);
- sumTaskCost(tpc.getTid());
- updateCountByTid(tpc.getId());
- }
- return 1;
- }
- public void sumTaskCost(Integer tid) {
- List<OutThirdPartyCompany>list=thirdPartyCompanyMapper.selectByTid(tid);
- BigDecimal tCount=new BigDecimal(0);
- for (OutThirdPartyCompany op : list) {
- tCount=tCount.add(new BigDecimal(op.getTotalAmount()));
- }
- tTaskMidMapper.updateCostAmount(tid,tCount);
- }
- @Override
- public int deletePaymentNode(String ids) {
- if (ids.contains(",")) {
- String []ids2 =ids.split(",");
- for (String s : ids2) {
- paymentNodeMapper.deleteByPrimaryKey(Integer.valueOf(s));
- }
- }else {
- Integer id=Integer.valueOf(ids);
- paymentNodeMapper.deleteByPrimaryKey(Integer.valueOf(id));
- List<outOrderPayment> list=tOrderPaymentMapper.selectList(null, id, null);
- for (outOrderPayment o : list) {
- TOrderPayment t=new TOrderPayment();
- t.setId(o.getId());
- t.setStatus(4);
- tOrderPaymentMapper.updateByPrimaryKeySelective(t);
- }
-
- }
- return 1;
- }
- @Override
- public int addOrderPayment(TOrderPayment p) {
- p.setStatus(0);
- p.setProcessStatus(1);
- AdminListBo a =adminMapper.getDeptNameByAid(TokenManager.getAdminId());
- p.setAid(a.getId());
- p.setAname(a.getName());
- if (p.getChooseType()==2) {
- TOrderTask t=new TOrderTask();
- t.setId(p.getTid());
- t.setCheckStatus(3);
- tOrderTaskMapper.updateByPrimaryKeySelective(t);
- }
- tOrderPaymentMapper.insertSelectiveGetId(p);
- NoticeInformationBo ni=financialPaymentMapper.selectBypidGetNotice(p.getId());
- addNoticAndSendEmail(ni,a,NoticeStatus.PAYMENT_NODE.getCode());
- PaymentLog pl=new PaymentLog(p.getId(),0,"发起付款:"+p.getRemarks(),a.getId(),a.getName());
- paymentLogMapper.insertSelective(pl);
- return 1;
- }
- @Override
- public outOrderPayment OrderPaymentDetails(Integer id) {
- TOrderPayment tp=tOrderPaymentMapper.selectByPrimaryKey(id);
- Integer type=tp.getChooseType();
- outOrderPayment op=tOrderPaymentMapper.selectByidGetDetails(id);
- op.setChooseType(type);
- ThirdPartyCompany tpc=thirdPartyCompanyMapper.selectByPrimaryKey(tp.getTpcId());
- if(tp.getChooseType()!=2&&tpc!=null&&!op.getCompanyName().equals(tpc.getCompanyName()))op.setCompanyName(op.getCompanyName()+"("+tpc.getCompanyName()+")");
- if (type==0&&tp.getStatus()!=4) {//支付种类 0第三方 1催款 2官费
- op.setInitialQuantity(tpc.getQuantity());
- op.setInitialTotalAmount(tpc.getTotalAmount().toString());
- op.setInitialUnitPrice(tpc.getUnitPrice().toString());
- op.setInitialPaymentAmount(tpc.getPartyAmount().toString());
-
- }else if (type==1&&tp.getStatus()!=4) {
- PaymentNode pn=paymentNodeMapper.selectByPrimaryKey(tp.getNodeId());
- op.setInitialQuantity(pn.getQuantity());
- op.setInitialTotalAmount(pn.getTotalAmount().toString());
- op.setInitialUnitPrice(pn.getUnitPrice().toString());
- op.setInitialPaymentAmount(pn.getPartyAmount().toString());
- }else if (type==2) {
- ProjectTypePuls tt=thirdPartyCompanyMapper.selectByTidGetDtails(tp.getTid());
- op.setInitialQuantity(tt.getQuantity());
- if (tt.getCostReduction()==1) {
- op.setInitialUnitPrice(tt.getProportion85().toEngineeringString());
- }else {
- op.setInitialUnitPrice(tt.getOfficialAmount().toEngineeringString());
- }
- BigDecimal count=new BigDecimal(op.getInitialQuantity()).multiply(new BigDecimal(op.getInitialUnitPrice()));
- op.setInitialTotalAmount(count.toEngineeringString());
- }
- // if (!TokenManager.hasRole(AFTConstants.FINANCE)&&
- // !TokenManager.hasRole(AFTConstants.FINANCE_MANAGER)&&
- // !TokenManager.hasRole(AFTConstants.FINANCE_ADMIN)&&
- // !TokenManager.hasRole(AFTConstants.OUTSOURCE_AUDITOR)) {
- // outProjectBo ob=tOrderOutsourceMapper.selectByTid(tp.getTid());
- // if (ob!=null &&ob.getStartType()!=null&& ob.getStartType()==1) {
- // if((ob.getProjectType()==1&&ob.getPatentType()==0)||(ob.getProjectType()==2)) {
- // op.setInitialUnitPrice("***");
- // op.setInitialTotalAmount("***");
- // }
- // }
- //
- // }
- return op;
- }
- @Override
- public int updateOrderPayment(TOrderPayment p) {
- TOrderPayment tp=new TOrderPayment();
- tp.setId(p.getId());
- tp.setRemarks(p.getRemarks());
- tp.setStatus(p.getStatus());
- tp.setQuantity(p.getQuantity());
- Integer type=NoticeStatus.PAYMENT_NODE.getCode();
- String auditStr="重新发起付款:";
- //状态 0审核 1待支付 2驳回 3已支付 4取消
- if (p.getStatus()==0) {
- tp.setApplicationAmount(p.getApplicationAmount());
- tp.setChooseType(p.getChooseType());
- tp.setPaymentType(p.getPaymentType());
- tp.setPaymentAmount(p.getPaymentAmount());
- tp.setPaymentStatus(p.getPaymentStatus());
- }else if (p.getStatus()==1) {
- type= NoticeStatus.PAYMENT_YES.getCode();
- tp.setApplicationAmount(p.getApplicationAmount());
- auditStr="审核通过:";
- }else if(p.getStatus()==2) {
- type= NoticeStatus.PAYMENT_NO.getCode();
- tp.setApplicationAmount(p.getApplicationAmount());
- auditStr="审核驳回:";
- }else if (p.getStatus()==3) {
- type=NoticeStatus.PAYMENT_COMPLETE.getCode();
- tp.setPaymentAmount(p.getPaymentAmount()!=null?p.getPaymentAmount():p.getApplicationAmount());
-
- confirmPayment(p);
- auditStr="审核完成";
- }else if(p.getStatus()==4) {
- auditStr="付款取消";
- }
- NoticeInformationBo ni=financialPaymentMapper.selectBypidGetNotice(p.getId());
- AdminListBo a =adminMapper.getDeptNameByAid(TokenManager.getAdminId());
- addNoticAndSendEmail(ni,a,type);
- PaymentLog pl=new PaymentLog(p.getId(),p.getStatus(),auditStr+p.getAuditNotes()==null?"":p.getAuditNotes(),a.getId(),a.getName());
- paymentLogMapper.insertSelective(pl);
- return tOrderPaymentMapper.updateByPrimaryKeySelective(tp);
- }
- private void confirmPayment(TOrderPayment p) {
- //如果确定支付
- int flag=0;
- TOrderPayment tp=tOrderPaymentMapper.selectByPrimaryKey(p.getId());
- ThirdPartyCompany tpc=new ThirdPartyCompany();
- if (p.getPaymentAmount()==null||p.getPaymentAmount().compareTo(new BigDecimal(0))==0) {
- p.setPaymentAmount(tp.getApplicationAmount());
- }
- if(tp.getChooseType()==0){
- tpc=thirdPartyCompanyMapper.selectByPrimaryKey(tp.getTpcId());
- }else if (tp.getChooseType()==1) {
- PaymentNode pn=paymentNodeMapper.selectByPrimaryKey(tp.getNodeId());
- BigDecimal count=pn.getTotalAmount();
- BigDecimal party=pn.getPartyAmount();
- party=party.add(p.getPaymentAmount());
- if (party.compareTo(new BigDecimal(0))==0) {
- flag=0;
- }else if (party.compareTo(count)==0) {
- flag=2;
- }else if (party.compareTo(count)==-1) {
- flag=1;
- }
- pn.setStatus(flag);
- pn.setPartyAmount(p.getPaymentAmount());
- paymentNodeMapper.updateByPrimaryKeySelective(pn);
- tpc=thirdPartyCompanyMapper.selectByPrimaryKey(pn.getCid());
- }
- if(tp.getChooseType()!=2){
- tpc.setPartyAmount(tpc.getPartyAmount().add(p.getPaymentAmount()));
- thirdPartyCompanyMapper.updateByPrimaryKeySelective(tpc);
- }
- p.setPaymentAmount(tp.getApplicationAmount());
- financialPaymentMapper.updateOrderCost(p.getId(),p.getPaymentAmount());
- }
- @Override
- public List<OutPaymentLog> selectPaymentLog(Integer id) {
- return paymentLogMapper.selectByPid(id);
- }
- @Override
- public List<outOrderPayment> selectOrderPayment(Integer id) {
- List<outOrderPayment> list=tOrderPaymentMapper.selectByTid(id,null,0);
- // if (!TokenManager.hasRole(AFTConstants.FINANCE)&&
- // !TokenManager.hasRole(AFTConstants.FINANCE_MANAGER)&&
- // !TokenManager.hasRole(AFTConstants.FINANCE_ADMIN)&&
- // !TokenManager.hasRole(AFTConstants.OUTSOURCE_AUDITOR)) {
- // outProjectBo op =null;
- // if(!list.isEmpty()) op=tOrderOutsourceMapper.selectByTid(id);
- // if (op!=null &&op.getStartType()!=null&&op.getStartType()==1) {
- // if((op.getProjectType()==1&&op.getPatentType()==0)||(op.getProjectType()==2)) {
- // for (outOrderPayment oc : list) {
- // if (oc.getChooseType()!=2) {
- // oc.setApplicationAmount("***");
- // }
- // }
- // }
- // }
- // }
- return list;
- }
- @Override
- public int addfinancialPayment(InuptFinancialPayment f) {
- f.setPaymentTime(DateUtils.StringToDate(f.getPaymentTimes(), AFTConstants.YYYYMMDD));
- financialPaymentMapper.insertSelectiveGetId(f);
- return f.getId();
- }
- @Override
- public List<outFinancialPayment> selectfinancialPayment(Integer id) {
- return financialPaymentMapper.selectByPid(id);
- }
- public void addNoticAndSendEmail(NoticeInformationBo in,AdminListBo a,Integer type) {
- String str=NoticeStatus.getValueByCode(type)+": 订单编号 -"+in.getOrderNo()+
- ",客户名称:"+in.getBuyerName()+", 操作人:"+a.getName()+"-"+a.getDepartmentName()+"。";
- Notice n =new Notice();
- EmailBo bo = new EmailBo(NoticeStatus.getValueByCode(type), a.getEmail(), a.getDepartmentName(), a.getName(),
- in.getOrderNo(), in.getSalesmanName());
- n.setId(UUID.randomUUID().toString());
- if (type==NoticeStatus.PAYMENT_NODE.getCode()||type==NoticeStatus.PAYMENT_NODE.getCode()) {
- n.setAid(in.getFinanceId());
- bo.setAddress(in.getFinanceEmail());
- } else if(type==NoticeStatus.PAYMENT_NO.getCode()||type==NoticeStatus.PAYMENT_YES.getCode()
- ||type==NoticeStatus.PAYMENT_COMPLETE.getCode()) {
- n.setAid(in.getTechId());
- bo.setAddress(in.getTechEmail());
- }
-
- n.setNoticeType(type);
- n.setContent(str);
- n.setReaded(0);//未读
- asyncUtils.addNotice(n);
- if(StringUtils.isNotBlank(a.getEmail())) {
- try {
- asyncUtils.send(bo);
- } catch (UnsupportedEncodingException | MessagingException e) {
- e.printStackTrace();
- }
- }
- }
- @Override
- public int checkPayment(TOrderPayment p) {
- //没有填写申请金额的情况下计算金额
- checkGetAmount(p);
- if (p.getChooseType()==2) {
- TOrderTask tot=tOrderTaskMapper.selectByPrimaryKey(p.getTid());
- List<outOrderPayment> list2=tOrderPaymentMapper.selectByTid(p.getTid(),p.getChooseType(),1);
- int x=p.getQuantity();
- for (outOrderPayment out : list2) {
- x+=out.getQuantity();
- }
- if (x>tot.getCommodityQuantity()) {
- return -2;
- }
- }else {
- BigDecimal total=new BigDecimal(0);
- BigDecimal a=p.getApplicationAmount()==null?new BigDecimal(0):p.getApplicationAmount();
- List<outOrderPayment> list=new ArrayList<>();
- //支付种类 0第三方 1催款2官费
- if (p.getChooseType()==0) {
- //首先不能大于第三方
- list=tOrderPaymentMapper.selectList(p.getTpcId(),null,p.getChooseType());
- }else if (p.getChooseType()==1) {
- list=tOrderPaymentMapper.selectList(null,p.getNodeId(),p.getChooseType());
- }
- for (outOrderPayment o : list) {
- a=a.add(new BigDecimal(o.getApplicationAmount()));
- }
- if (p.getChooseType()==0) {
- ThirdPartyCompany t=thirdPartyCompanyMapper.selectByPrimaryKey(p.getTpcId());
- total=t.getTotalAmount();
- }else if (p.getChooseType()==1) {
- PaymentNode n=paymentNodeMapper.selectByPrimaryKey(p.getNodeId());
- total=n.getTotalAmount();
- }
- if (a.compareTo(total) == 1) {
- return -1;
- }
- }
- return 0;
- }
- @Override
- public boolean checkprojectDun(TOrderPayment p) {
- PaymentNode pn=paymentNodeMapper.selectByPrimaryKey(p.getNodeId());
- TOrderTaskDetailBo tt=tOrderTaskMapper.getOrderTaskDetail(p.getTid().toString());
- // 项目状态 0-项目待提交 1-项目已提交,2-项目评审,3-项目立项,4-项目公示,5-项目抽查,6-项目备案,7-项目下证,8-项目验收,
- // 9-项目拨款 10- 项目进度10% 11- 项目进度30% 12- 项目进度70%
- if(pn.getDunType()==1) {
- return false;
- }
- if (pn.getDunType()==0&&pn.getPartyTime().getTime()<new Date().getTime()) {//如果自定义则看触发时间
- return false;
- }else if (NewOrderDunType.CGZH_WC.getCode()==Integer.valueOf(""+pn.getProjectType()+pn.getDunType())
- &&(tt.getProjectStatus()==NewProjectStatus.YWCXZ.getCode())) {
- return false;
- }else if (NewOrderDunType.COMMON_NGS.getCode()==Integer.valueOf(""+pn.getProjectType()+pn.getDunType())
- &&(tt.getProjectStatus()>=NewProjectStatus.YTJ.getCode()&&tt.getProjectStatus()<=NewProjectStatus.YWCXZ.getCode()
- ||tt.getProjectStatus()>=NewProjectStatus.YBH.getCode())) {
- return false;
- }else if (NewOrderDunType.COMMON_XZ.getCode()==Integer.valueOf(""+pn.getProjectType()+pn.getDunType())
- &&(tt.getProjectStatus()==NewProjectStatus.YWCXZ.getCode())) {
- return false;
- } else if (NewOrderDunType.KJXM_LX.getCode()==Integer.valueOf(""+pn.getProjectType()+pn.getDunType())
- &&(tt.getProjectStatus()>=NewProjectStatus.YLX.getCode()&&tt.getProjectStatus()<=NewProjectStatus.LXYBK.getCode())) {
- return false;
- } else if (NewOrderDunType.KJXM_BK.getCode()==Integer.valueOf(""+pn.getProjectType()+pn.getDunType())
- &&(tt.getProjectStatus()<=NewProjectStatus.LXYBK.getCode())) {
- return false;
- } else if (NewOrderDunType.KJJR_BK.getCode()==Integer.valueOf(""+pn.getProjectType()+pn.getDunType())
- &&(tt.getProjectStatus()==NewProjectStatus.YWCXZ.getCode())) {
- return false;
- } else if (NewOrderDunType.RJKF_LX.getCode()==Integer.valueOf(""+pn.getProjectType()+pn.getDunType())
- &&((tt.getProjectStatus()>=NewProjectStatus.YTJ.getCode()&&tt.getProjectStatus()<=NewProjectStatus.YWCXZ.getCode())
- ||tt.getProjectStatus()>=NewProjectStatus.YBH.getCode())) {
- return false;
- } else if (NewOrderDunType.RJKF_WZ.getCode()==Integer.valueOf(""+pn.getProjectType()+pn.getDunType())
- &&(tt.getProjectStatus()==NewProjectStatus.YWCXZ.getCode())) {
- return false;
- } else if (NewOrderDunType.ZSCQ_GS_SL_XZ.getCode()==Integer.valueOf(""+pn.getProjectType()+pn.getDunType())) {
- // 0 正常 1专利 2软著 3审计 4双软 5高新 6商标
- if (tt.getBpType()==1
- &&(tt.getProjectStatus()==NewProjectStatus.YTJ.getCode()&&tt.getProjectStatus()==NewProjectStatus.YWCXZ.getCode()
- ||tt.getProjectStatus()==NewProjectStatus.YBH.getCode())) {
- return false;
- }else if (tt.getBpType()!=1&&(tt.getProjectStatus()==NewProjectStatus.YWCXZ.getCode())){
- return false;
- }
- } else if (NewOrderDunType.ZSCQ_XZ.getCode()==Integer.valueOf(""+pn.getProjectType()+pn.getDunType())
- &&(tt.getProjectStatus()==NewProjectStatus.YWCXZ.getCode())) {
- return false;
- } else if (NewOrderDunType.GX_YGS.getCode()==Integer.valueOf(""+pn.getProjectType()+pn.getDunType())
- &&(tt.getProjectStatus()>=NewProjectStatus.YNGS.getCode()&&tt.getProjectStatus()<=NewProjectStatus.YXZ.getCode())) {
- return false;
- } else if (NewOrderDunType.GX_YXZ.getCode()==Integer.valueOf(""+pn.getProjectType()+pn.getDunType())
- &&(tt.getProjectStatus()==NewProjectStatus.YXZ.getCode())) {
- return false;
- }
-
- return true;
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<outPaymentList> selectPaymentList(InputPaymentList i) {
- Map<String, Object> map =new HashMap<>();
- map.put("aid", TokenManager.getAdminId());
- if (i.getContractNo()!=null)map.put("contractNo", i.getContractNo());
- if (i.getOrderNo()!=null)map.put("orderNo", i.getOrderNo());
- if (i.getUserName()!=null)map.put("userName", i.getUserName());
- if (i.getDepId()!=null)map.put("depId", i.getDepId());
- if (i.getAname()!=null)map.put("aname", i.getAname());
- if (i.getFinanceName()!=null)map.put("financeName", i.getFinanceName());
- if (i.getCname()!=null)map.put("cname", i.getCname());
- if (i.getPname()!=null)map.put("pname", i.getPname());
- if (i.getStatus()!=null)map.put("status", i.getStatus());
- if (TokenManager.hasRole(AFTConstants.FINANCE_MANAGER)) {
- map.put("lvl", 1);
- }else if (TokenManager.hasRole(AFTConstants.FINANCE_ADMIN)||TokenManager.hasRole(AFTConstants.VICE_CEO)||
- TokenManager.hasRole(AFTConstants.CED)||TokenManager.hasRole(AFTConstants.SUPERADMIN)||
- TokenManager.hasRole(AFTConstants.APPROVAL_DECISION)) {
- map.put("lvl", 2);
- }else if (TokenManager.hasRole(AFTConstants.TECH)||TokenManager.hasRole(AFTConstants.TECH_MANAGER)) {
- map.put("lvl", 3);
- }else if(TokenManager.hasRole(AFTConstants.PATENT_AUDITOR))
- {
- map.put("lvl", 4);
- }else {
- map.put("lvl", 0);
- }
- Pagination<outPaymentList> p=(Pagination<outPaymentList>)findPage("selectPaymentList","selectPaymentCount",
- map,i.getPageNo(),i.getPageSize());
- return p;
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<outNodeList> selectPaymentList(InputNodeList i) {
- Map<String, Object> map =new HashMap<>();
- map.put("aid", TokenManager.getAdminId());
- if (i.getContractNo()!=null)map.put("contractNo", i.getContractNo());
- if (i.getOrderNo()!=null)map.put("orderNo", i.getOrderNo());
- if (i.getUserName()!=null)map.put("userName", i.getUserName());
- if (i.getCname()!=null)map.put("cname", i.getCname());
- if (i.getPname()!=null)map.put("pname", i.getPname());
- if (i.getStatus()!=null)map.put("status", i.getStatus());
- if (i.getStartTime()!=null&&i.getEndTime()!=null) {
- map.put("startTime", DateUtils.StringToDate(i.getStartTime(), AFTConstants.YYYYMMDD));
- map.put("endTime", DateUtils.StringToDate(i.getEndTime()+" 23:59:59", AFTConstants.YYYYMMDDHHMMSS));
- }
- if (TokenManager.hasRole(AFTConstants.FINANCE)) {
- map.put("lvl", 1);
- }else if (TokenManager.hasRole(AFTConstants.FINANCE_MANAGER)) {
- map.put("lvl", 2);
- }else if (TokenManager.hasRole(AFTConstants.FINANCE_ADMIN)||TokenManager.hasRole(AFTConstants.VICE_CEO)||
- TokenManager.hasRole(AFTConstants.CED)||TokenManager.hasRole(AFTConstants.SUPERADMIN)||
- TokenManager.hasRole(AFTConstants.APPROVAL_DECISION)) {
- map.put("lvl", 3);
- }else {
- map.put("lvl", 0);
- }
- return (Pagination<outNodeList>)findPage("selectNodeList","selectNodeCount",
- map,i.getPageNo(),i.getPageSize());
- }
- @Override
- public int insertSoftWritingPrice(SoftWritingPrice s) {
- return softWritingPriceMapper.insertSelective(s);
- }
- @Override
- public int updateSoftWritingPrice(SoftWritingPrice s) {
- //
- return softWritingPriceMapper.updateByPrimaryKeySelective(s);
- }
- @Override
- public Integer pushSelectByCid(String companyName,int i) {
- String aid=null;
- if (i==1) {
- aid=TokenManager.getAdminId();
- }
- List<Integer> list=companyLibraryMapper.selectName(companyName,i,aid);
- if (list.size()<1) {
- CompanyLibrary c=new CompanyLibrary();
- c.setCompanyName(companyName);
- c.setType(i);
- companyLibraryMapper.insertSelectiveGetId(c);
- return c.getId();
- }else {
- return list.get(0);
- }
-
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<SoftWritingPrice> listSoftWritingPrice(SoftWritingPrice s, Integer pageNo, Integer pageSize) {
- Map<String, Object> map =new HashMap<>();
- map.put("s", s);
- return (Pagination<SoftWritingPrice>)findPage("softWritingPriceList","softWritingPriceCount",
- map,pageNo,pageSize);
- }
- @Override
- public int deleteSoftWritingPrice(Integer id) {
- SoftWritingPrice sw=softWritingPriceMapper.selectByPrimaryKey(id);
- int i=softWritingPriceMapper.selectCountByCid(sw.getCid());
- if (i==1) {
- companyLibraryMapper.deleteByPrimaryKey(sw.getCid());
- }
- return softWritingPriceMapper.deleteByPrimaryKey(id);
- }
- @Override
- public boolean checkSoftWritingPrice(SoftWritingPrice s) {
- SoftWritingPrice sw=new SoftWritingPrice();
- if(s.getId()!=null)sw=softWritingPriceMapper.selectByPrimaryKey(s.getId());
- if (s.getId()!=null) {
- s.setCid(sw.getCid());
- }
- List<SoftWritingPrice>list=softWritingPriceMapper.checkSoftWritingPrice(s);
- if (list.size()<1) {
- return false;
- }else if (list.size()==1&&s.getId()!=null) {
- for (SoftWritingPrice ss : list) {
- if(ss.getId().equals(s.getId()))return false;
- }
- }
- return true;
- }
- @Override
- public Map<String ,Object> updateGroupPayment(String ids) {
- String [] idss=ids.split(",");
- List<Integer>elist=new ArrayList<>();
- List<Integer> list=new ArrayList<>();
- List<Notice> nlist=new ArrayList<>();
- Date date=new Date();
- for (String s : idss) {
- TOrderPayment top=tOrderPaymentMapper.selectByPrimaryKey(Integer.valueOf(s));
- if (top!=null&&top.getStatus()==1) {
- top.setStatus(3);
- top.setPaymentAmount(top.getApplicationAmount());
- tOrderPaymentMapper.updateByPrimaryKeySelective(top);
- list.add(top.getId());
- //做已付款金额计算
- confirmPayment(top);
- //发送站内通知
- Notice n =new Notice();
- n.setId(UUID.randomUUID().toString());
- NoticeInformationBo ni=financialPaymentMapper.selectBypidGetNotice(Integer.valueOf(s));
- AdminListBo a =adminMapper.getDeptNameByAid(TokenManager.getAdminId());
- n.setAid(ni.getTechId());
- n.setCreateTime(date);
- n.setNoticeType(NoticeStatus.PAYMENT_COMPLETE.getCode());
- String str=NoticeStatus.getValueByCode(n.getNoticeType())+": 订单编号 -"+ni.getOrderNo()+
- ",客户名称:"+ni.getBuyerName()+", 操作人:"+a.getName()+"-"+a.getDepartmentName()+"。";
- n.setContent(str);
- n.setReaded(0);//未读
- nlist.add(n);
- }else {
- elist.add(Integer.valueOf(s));
- }
- }
- if(!nlist.isEmpty())asyncUtils.addNoticeBatch(nlist);
- Map<String ,Object> map=new HashMap<>();
- map.put("OK", list);
- map.put("fail", elist);
- return map;
- }
- @Override
- public int addOfficialFeePrice(OfficialFeePrice o) {
- return officialFeePriceMapper.insertSelective(o);
- }
- @Override
- public int updateOfficialFeePrice(OfficialFeePrice o) {
- return officialFeePriceMapper.updateByPrimaryKeySelective(o);
- }
- @Override
- public int deleteOfficialFeePrice(Integer id) {
- return officialFeePriceMapper.deleteByPrimaryKey(id);
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<OfficialFeePrice> listOfficialFeePrice(Integer type, Integer patentType, Integer pageSize, Integer pageNo){
- Map<String, Object>map=new HashedMap<String, Object>();
- if(type!=null)map.put("type", type);
- if(patentType!=null)map.put("patentType", patentType);
- return (Pagination<OfficialFeePrice>)findPage("selectListOfficialFeePrice","countListOfficialFeePrice",
- map,pageNo,pageSize);
- }
- @Override
- public int deleteFinancialPayment(Integer id) {
- return financialPaymentMapper.deleteByPrimaryKey(id);
- }
- @Override
- public void calculationUnitPrice(ThirdPartyCompany t) {
- SoftWritingPrice s=new SoftWritingPrice();
- s.setCid(t.getCid());
- s.setMaterial(t.getMaterial());
- s.setUrgent(t.getUrgent());
- List<SoftWritingPrice> list=softWritingPriceMapper.checkSoftWritingPrice(s);
- for (SoftWritingPrice sw : list) {
- t.setUnitPrice(sw.getUnitPrice());
- t.setTotalAmount(sw.getUnitPrice().multiply(new BigDecimal(t.getQuantity())));
- }
- }
-
- @Override
- public void calculationPatentUnitPrice(ThirdPartyCompany t) {
- PatentPrice p=patentPriceMapper.selectBycid(t.getCid());
- // 专利名称 0实用新型 1发明专利 2外观专利 3 其他
- BigDecimal unitPrice=null;
- if (t.getPatentNameType()==0) {
- unitPrice=p.getUtilityModel();
- }else if (t.getPatentNameType()==1) {
- unitPrice=p.getInventionPatent();
- }else if (t.getPatentNameType()==2) {
- unitPrice=p.getAppearancePatent();
- }
- t.setUnitPrice(unitPrice);
- t.setTotalAmount(unitPrice.multiply(new BigDecimal(t.getQuantity())));
- }
- @Override
- public int addpatentPrice(PatentPrice p) {
- return patentPriceMapper.insertSelective(p);
- }
- @Override
- public int updatepatentPrice(PatentPrice p) {
- return patentPriceMapper.updateByPrimaryKeySelective(p);
- }
- @Override
- public int deletepatentPrice(Integer id) {
- PatentPrice pp=patentPriceMapper.selectByPrimaryKey(id);
- if (pp.getCid()!=null) {
- companyLibraryMapper.deleteByPrimaryKey(pp.getCid());
- }
- return patentPriceMapper.deleteByPrimaryKey(id);
- }
- @Override
- public List<PatentPrice> listpatentPrice(String name) {
- return patentPriceMapper.selectlist(name);
- }
- @Override
- public boolean addCompanyChekeNumber(ThirdPartyCompany t) {
- TOrderTask tt=tOrderTaskMapper.selectByPrimaryKey(t.getTid());
- List<OutThirdPartyCompany> list =thirdPartyCompanyMapper.selectByTid(t.getTid());
- Integer count=t.getQuantity();
- for (OutThirdPartyCompany out : list) {
- if (t.getId()==null||!t.getId().equals(out.getId())) {
- count+=out.getQuantity();
- }
- }
- if (tt.getCommodityQuantity()>=count) {
- return false;
- }
- return true;
- }
-
- @Override
- public void checkGetAmount(TOrderPayment p) {
- if(p.getApplicationAmount()==null) {
- BigDecimal count=new BigDecimal(0);
- if(p.getChooseType()==0) {
- ThirdPartyCompany tpc=thirdPartyCompanyMapper.selectByPrimaryKey(p.getTpcId());
- count=tpc.getUnitPrice().multiply(new BigDecimal(p.getQuantity()));
- } else if (p.getChooseType()==1) {
- PaymentNode pn=paymentNodeMapper.selectByPrimaryKey(p.getNodeId());
- count=pn.getUnitPrice().multiply(new BigDecimal(p.getQuantity()));
- }else if (p.getChooseType()==2) {
- ProjectTypePuls ot=thirdPartyCompanyMapper.selectByTidGetDtails(p.getTid());
- if (ot.getCostReduction()==0) {
- count=ot.getOfficialAmount().multiply(new BigDecimal(p.getQuantity()));
- }else {
- count=ot.getProportion85().multiply(new BigDecimal(p.getQuantity()));
- }
- }
- p.setApplicationAmount(count);
- }
-
- }
- @Override
- public Result exportPaymentList(HttpServletResponse response, InputPaymentList ip, Integer type) {
- if (type==null) type=0;
- @SuppressWarnings("unchecked")
- List<outPaymentList> list=(List<outPaymentList>) selectPaymentList(ip).getList();
- if (type==0) {
- List<outPaymentListFinance> list2=new ArrayList<outPaymentListFinance>();
- for (outPaymentList out : list) {
- outPaymentListFinance out2=new outPaymentListFinance();
- try {
- BeanUtils.copyProperties(out2, out);
- } catch (IllegalAccessException | InvocationTargetException e) {
- e.printStackTrace();
- }
- list2.add(out2);
- }
- NewExcelUtil<outPaymentListFinance> excelUtil=new NewExcelUtil<>(outPaymentListFinance.class);
- return excelUtil.exportExcel(list2, "财务成本列表", response);
- }else {
- List<outPaymentListPatent> list3=new ArrayList<outPaymentListPatent>();
- for (outPaymentList out : list) {
- outPaymentListPatent out3=new outPaymentListPatent();
- try {
- BeanUtils.copyProperties(out3, out);
- } catch (IllegalAccessException | InvocationTargetException e) {
- e.printStackTrace();
- }
- StringBuffer s=new StringBuffer();
- if (out3.getOfficialCost()!=null&&out3.getOfficialCost()==1) {
- s.append("含官费");
- if (out3.getCostReduction()!=null&&out3.getCostReduction()==1) {
- s.append(",有费减");
- }else {
- s.append(",无费减");
- }
- }else {
- s.append("不含官费");
- }
- out3.setOfficialName(s.toString());
- list3.add(out3);
- }
- NewExcelUtil<outPaymentListPatent> p=new NewExcelUtil<>(outPaymentListPatent.class);
- return p.exportExcel(list3, "专利成本列表", response);
- }
- }
- @Override
- public boolean checkOfficialFeePrice(OfficialFeePrice o) {
- OfficialFeePrice x=officialFeePriceMapper.countOfficialFeePrice(o);
- if(o.getId()==null&&x!=null) {
- return true;
- }else if(o.getId()!=null&&o.getId()!=x.getId()) {
- return true;
- }
- return false;
- }
- @Override
- public int pushPaymentExamine(PaymentLog in,String pids) {
- Admin a=adminMapper.selectAllByid(TokenManager.getAdminId());
- int processStatus=0;
- if (in.getStatus()==1) {
- processStatus=2;
- }else {
- processStatus=0;
- }
- if (in.getPid()!=null) {
- in.setAid(a.getId());
- in.setAname(a.getName());
- TOrderPayment tp=new TOrderPayment();
- tp.setId(in.getPid());
- tp.setProcessStatus(processStatus);
- tOrderPaymentMapper.updateByPrimaryKeySelective(tp);
- return paymentLogMapper.insertSelective(in);
- }else if(StringUtils.isNotBlank(pids)) {
- List<String> ss=Arrays.asList(pids.split(","));
- tOrderPaymentMapper.updateByids(ss,processStatus);
- paymentLogMapper.insertBatch(ss,a.getAid(),a.getName(),in.getRemarks(),in.getStatus());
- return 1;
- }else {
- return 0;
- }
-
- }
- @Override
- public boolean checkQuantity(TOrderPayment p) {
- TOrderPayment tp=tOrderPaymentMapper.selectByPrimaryKey(p.getId());
- TOrderTask tt=tOrderTaskMapper.selectByPrimaryKey(tp.getTid());
- List<outOrderPayment> list =tOrderPaymentMapper.selectByTid(tt.getId(), 2,1);
- Integer q=0;
- for (outOrderPayment o : list) {
- if (p.getId().equals(o.getId())) {
- q+=p.getQuantity();
- }else {
- q+=o.getQuantity();
- }
- }
- if (q>tt.getCommodityQuantity()) {
- return true;
- }
- return false;
- }
- @Override
- public Map<String, Object> checkThirdParty(Integer id) {
- int x =tOrderPaymentMapper.selectByCid(id);
- int y = paymentNodeMapper.selectByCid(id);
- Integer i=0;
- String desc="您已有%s,确定则一并删除。";
- Map<String, Object> map=new HashedMap<String, Object>();
- StringBuffer src=new StringBuffer();
- if(x>0){
- i++;
- src.append("付款记录、");
- }
- if(y>0){
- i++;
- src.append("付款催款、");
- }
- map.put("code", i);
- if (i!=0) {
- src.delete(src.length()-1, src.length());
- desc=String.format(desc, src);
- map.put("desc", desc);
- }
- return map;
-
- }
- @Override
- public Object updateCheck(Integer id,Integer type) {
- Map<String, Object> map=new HashedMap<String, Object>();
- if (type==0) {
- Integer i=0;
- String desc="您已有%s,确定则一并删除。";
- StringBuffer src=new StringBuffer();
- List<OutThirdPartyCompany> list=thirdPartyCompanyMapper.selectByTid(id);
- List<OutPaymentNode> list2=paymentNodeMapper.selectByTid(id, null);
- List<outOrderPayment> list3=tOrderPaymentMapper.selectByTid(id, null,1);
- if (!list.isEmpty()) {
- src.append("第三方").append("、");
- i++;
- }
- if (!list2.isEmpty()) {
- src.append("付款催款").append("、");
- i++;
- }
- if (!list3.isEmpty()) {
- src.append("付款记录").append("、");
- i++;
- }
- if (i!=0) {
- src.delete(src.length()-1, src.length());
- desc=String.format(desc, src);
- map.put("desc", desc);
- }
- map.put("code", i);
- }else if(type==1) {
- thirdPartyCompanyMapper.deleteByTid(id);
- paymentNodeMapper.deleteByParam(null,id);
- List<outOrderPayment> list=tOrderPaymentMapper.selectByTid(id,null,0);
- List<String> ss=new ArrayList<String>();
- for (outOrderPayment o : list) {
- TOrderPayment t=new TOrderPayment();
- t.setId(o.getId());
- t.setStatus(4);
- ss.add(o.getId().toString());
- tOrderPaymentMapper.updateByPrimaryKeySelective(t);
- }
- Admin a=adminMapper.selectByPrimaryKey(TokenManager.getAdminId());
- if (!list.isEmpty()&&a.getAid()!=null) {
- paymentLogMapper.insertBatch(ss, a.getAid(), a.getName(), "切换取消支付", 4);
- }
- tOrderTaskMapper.resstPayment(id);
- updateCountByTid(id);
- map.put("desc", "已全部删除");
- }
- return map;
- }
- /**
- * 根据项目编号重新计算订单成本与已付
- * @param id
- */
- private void updateCountByTid(Integer id) {
- List<TTaskMid> list=tTaskMidMapper.selectListByTid(id);
- BigDecimal cost=new BigDecimal(0);
- BigDecimal party=new BigDecimal(0);
- for (TTaskMid t : list) {
- cost=cost.add(t.getCostAmount());
- party=party.add(t.getPartyAmount());
- }
- tOrderMidMapper.updateCostAmount(id, cost,party);
- }
- @Override
- public Object checkNode(Integer id) {
- Integer i=0;
- String desc="您已有%s,确定则一并删除。";
- StringBuffer src=new StringBuffer();
- Map<String, Object> map=new HashedMap<String, Object>();
- List<outOrderPayment> list3=tOrderPaymentMapper.selectList(null, id, null);
- if (!list3.isEmpty()) {
- src.append("付款记录");
- i++;
- }
- if (i!=0) {
- desc=String.format(desc, src);
- map.put("desc", desc);
- }
- map.put("code", i);
- return map;
- }
- }
|