ThirdPartyCompanyServiceImpl.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. package com.goafanti.organization.service.impl;
  2. import java.io.UnsupportedEncodingException;
  3. import java.math.BigDecimal;
  4. import java.util.ArrayList;
  5. import java.util.Date;
  6. import java.util.HashMap;
  7. import java.util.List;
  8. import java.util.Map;
  9. import java.util.UUID;
  10. import javax.mail.MessagingException;
  11. import org.apache.commons.lang3.StringUtils;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.stereotype.Service;
  14. import com.goafanti.admin.bo.AdminListBo;
  15. import com.goafanti.common.bo.EmailBo;
  16. import com.goafanti.common.constant.AFTConstants;
  17. import com.goafanti.common.dao.AdminMapper;
  18. import com.goafanti.common.dao.CompanyLibraryMapper;
  19. import com.goafanti.common.dao.FinancialPaymentMapper;
  20. import com.goafanti.common.dao.NoticeMapper;
  21. import com.goafanti.common.dao.OfficialFeePriceMapper;
  22. import com.goafanti.common.dao.PatentPriceMapper;
  23. import com.goafanti.common.dao.PaymentLogMapper;
  24. import com.goafanti.common.dao.PaymentNodeMapper;
  25. import com.goafanti.common.dao.SoftWritingPriceMapper;
  26. import com.goafanti.common.dao.TOrderPaymentMapper;
  27. import com.goafanti.common.dao.TOrderTaskMapper;
  28. import com.goafanti.common.dao.TTaskMidMapper;
  29. import com.goafanti.common.dao.ThirdPartyCompanyMapper;
  30. import com.goafanti.common.enums.NoticeStatus;
  31. import com.goafanti.common.model.CompanyLibrary;
  32. import com.goafanti.common.model.Notice;
  33. import com.goafanti.common.model.OfficialFeePrice;
  34. import com.goafanti.common.model.PatentPrice;
  35. import com.goafanti.common.model.PaymentLog;
  36. import com.goafanti.common.model.PaymentNode;
  37. import com.goafanti.common.model.SoftWritingPrice;
  38. import com.goafanti.common.model.TOrderPayment;
  39. import com.goafanti.common.model.ThirdPartyCompany;
  40. import com.goafanti.common.utils.DateUtils;
  41. import com.goafanti.common.utils.SendEmailUtil;
  42. import com.goafanti.core.mybatis.BaseMybatisDao;
  43. import com.goafanti.core.mybatis.page.Pagination;
  44. import com.goafanti.core.shiro.token.TokenManager;
  45. import com.goafanti.order.bo.TOrderTaskDetailBo;
  46. import com.goafanti.order.enums.NewOrderDunType;
  47. import com.goafanti.organization.bo.InputNodeList;
  48. import com.goafanti.organization.bo.InputPaymentList;
  49. import com.goafanti.organization.bo.InputPaymentNode;
  50. import com.goafanti.organization.bo.InuptFinancialPayment;
  51. import com.goafanti.organization.bo.NoticeInformationBo;
  52. import com.goafanti.organization.bo.OutPaymentLog;
  53. import com.goafanti.organization.bo.OutPaymentNode;
  54. import com.goafanti.organization.bo.OutThirdPartyCompany;
  55. import com.goafanti.organization.bo.outFinancialPayment;
  56. import com.goafanti.organization.bo.outNodeList;
  57. import com.goafanti.organization.bo.outPaymentList;
  58. import com.goafanti.organization.bo.outOrderPayment;
  59. import com.goafanti.organization.service.ThirdPartyCompanyService;
  60. @Service
  61. public class ThirdPartyCompanyServiceImpl extends BaseMybatisDao<ThirdPartyCompanyMapper> implements ThirdPartyCompanyService {
  62. @Autowired
  63. private ThirdPartyCompanyMapper thirdPartyCompanyMapper;
  64. @Autowired
  65. private CompanyLibraryMapper companyLibraryMapper;
  66. @Autowired
  67. private PaymentNodeMapper paymentNodeMapper;
  68. @Autowired
  69. private TOrderPaymentMapper tOrderPaymentMapper;
  70. @Autowired
  71. private PaymentLogMapper paymentLogMapper;
  72. @Autowired
  73. private AdminMapper adminMapper;
  74. @Autowired
  75. private NoticeMapper noticeMapper;
  76. @Autowired
  77. private FinancialPaymentMapper financialPaymentMapper;
  78. @Autowired
  79. private TOrderTaskMapper tOrderTaskMapper;
  80. @Autowired
  81. private SoftWritingPriceMapper softWritingPriceMapper;
  82. @Autowired
  83. private OfficialFeePriceMapper officialFeePriceMapper;
  84. @Autowired
  85. private TTaskMidMapper tTaskMidMapper;
  86. @Autowired
  87. private PatentPriceMapper patentPriceMapper;
  88. @Override
  89. public int addCompany(ThirdPartyCompany t,Integer calculation) {
  90. if(calculation==null)calculation=0;
  91. if (calculation==0) {//0其他 1计算
  92. CompanyLibrary c=new CompanyLibrary();
  93. String aid=TokenManager.getAdminId();
  94. List<Integer> list=companyLibraryMapper.selectName(t.getCompanyName(),1,aid);
  95. if (list.size()<1) {
  96. c.setCompanyName(t.getCompanyName());
  97. c.setAid(aid);
  98. c.setType(1);//0系统 1录入
  99. companyLibraryMapper.insertSelectiveGetId(c);
  100. t.setCid(c.getId());
  101. }else {
  102. t.setCid(list.get(0));
  103. }
  104. t.setTotalAmount(t.getUnitPrice().multiply(new BigDecimal(t.getQuantity())));
  105. }
  106. return thirdPartyCompanyMapper.insertSelective(t);
  107. }
  108. @Override
  109. public int updateCompany(ThirdPartyCompany t) {
  110. SoftWritingPrice s=new SoftWritingPrice();
  111. s.setCid(t.getCid());
  112. s.setMaterial(t.getMaterial());
  113. s.setUrgent(t.getUrgent());
  114. List<SoftWritingPrice> list=softWritingPriceMapper.checkSoftWritingPrice(s);
  115. for (SoftWritingPrice sw : list) {
  116. t.setUnitPrice(sw.getUnitPrice().multiply(new BigDecimal(t.getQuantity())));
  117. }
  118. return thirdPartyCompanyMapper.updateByPrimaryKeySelective(t);
  119. }
  120. @Override
  121. public List<CompanyLibrary> selectVague(String name,Integer type) {
  122. String aid = null;
  123. if(type==null)type=1;
  124. if (type==1) aid=TokenManager.getAdminId();
  125. return companyLibraryMapper.selectVague(name,type,aid);
  126. }
  127. @Override
  128. public int addPaymentNode(InputPaymentNode p) {
  129. if (StringUtils.isNoneBlank(p.getPartyTimes())) {
  130. p.setPartyTime(DateUtils.StringToDate(p.getPartyTimes(), AFTConstants.YYYYMMDD));
  131. }
  132. return paymentNodeMapper.insertSelective(p);
  133. }
  134. @Override
  135. public boolean addNodeCheck(InputPaymentNode p) {
  136. ThirdPartyCompany t=thirdPartyCompanyMapper.selectByPrimaryKey(p.getCid());
  137. if (p.getTotalAmount().compareTo(t.getTotalAmount())>0) {
  138. return true;
  139. }
  140. List<OutPaymentNode> list=paymentNodeMapper.selectByTidAndCid(p.getTid(),p.getCid());
  141. BigDecimal sum=p.getTotalAmount();
  142. for (OutPaymentNode pn : list) {
  143. if (!pn.getId().equals(p.getId())) sum=sum.add(pn.getTotalAmount());
  144. }
  145. if (sum.compareTo(t.getTotalAmount())>0) {
  146. return true;
  147. }
  148. return false;
  149. }
  150. @Override
  151. public int updatePaymentNode(InputPaymentNode p) {
  152. if (StringUtils.isNoneBlank(p.getPartyTimes())) {
  153. p.setPartyTime(DateUtils.StringToDate(p.getPartyTimes(), AFTConstants.YYYYMMDD));
  154. }
  155. return paymentNodeMapper.updateByPrimaryKeySelective(p);
  156. }
  157. @Override
  158. public List<OutThirdPartyCompany> selectCompany(Integer tid) {
  159. List<OutThirdPartyCompany> list=thirdPartyCompanyMapper.selectByTid(tid);
  160. return list;
  161. }
  162. @Override
  163. public List<OutPaymentNode> selectPaymentNode(Integer tid) {
  164. List<OutPaymentNode> list=paymentNodeMapper.selectByTid(tid,null);
  165. return list;
  166. }
  167. @Override
  168. public int deleteCompany(String id) {
  169. if (id.contains(",")) {
  170. String []ids =id.split(",");
  171. for (String s : ids) {
  172. thirdPartyCompanyMapper.deleteByPrimaryKey(Integer.valueOf(s));
  173. }
  174. }else thirdPartyCompanyMapper.deleteByPrimaryKey(Integer.valueOf(id));
  175. return 1;
  176. }
  177. @Override
  178. public int deletePaymentNode(String id) {
  179. if (id.contains(",")) {
  180. String []ids =id.split(",");
  181. for (String s : ids) {
  182. paymentNodeMapper.deleteByPrimaryKey(Integer.valueOf(s));
  183. }
  184. }else paymentNodeMapper.deleteByPrimaryKey(Integer.valueOf(id));
  185. return 1;
  186. }
  187. @Override
  188. public int addOrderPayment(TOrderPayment p) {
  189. p.setStatus(0);
  190. tOrderPaymentMapper.insertSelectiveGetId(p);
  191. NoticeInformationBo ni=financialPaymentMapper.selectBypidGetNotice(p.getId());
  192. AdminListBo a =adminMapper.getDeptNameByAid(TokenManager.getAdminId());
  193. addNoticAndSendEmail(ni,a,NoticeStatus.PAYMENT_NODE.getCode());
  194. PaymentLog pl=new PaymentLog(p.getId(),0,"发起付款:"+p.getRemarks(),a.getId(),a.getName());
  195. paymentLogMapper.insertSelective(pl);
  196. return 1;
  197. }
  198. @Override
  199. public outOrderPayment OrderPaymentDetails(Integer id) {
  200. TOrderPayment tt=tOrderPaymentMapper.selectByPrimaryKey(id);
  201. int type=tt.getChooseType();
  202. return tOrderPaymentMapper.selectByidGetDetails(id,type);
  203. }
  204. @Override
  205. public int updateOrderPayment(TOrderPayment p) {
  206. TOrderPayment tp=new TOrderPayment();
  207. tp.setId(p.getId());
  208. tp.setRemarks(p.getRemarks());
  209. tp.setStatus(p.getStatus());
  210. Integer type=NoticeStatus.PAYMENT_NODE.getCode();
  211. String auditStr="重新发起付款:";
  212. //状态 0审核 1待支付 2驳回 3已支付 4取消
  213. if (p.getStatus()==0) {
  214. tp.setApplicationAmount(p.getApplicationAmount());
  215. tp.setChooseType(p.getChooseType());
  216. tp.setPaymentType(p.getPaymentType());
  217. tp.setPaymentAmount(p.getPaymentAmount());
  218. tp.setQuantity(p.getQuantity());
  219. tp.setPaymentStatus(p.getPaymentStatus());
  220. NoticeInformationBo ni=financialPaymentMapper.selectBypidGetNotice(p.getId());
  221. AdminListBo a =adminMapper.getDeptNameByAid(TokenManager.getAdminId());
  222. addNoticAndSendEmail(ni,a,NoticeStatus.PAYMENT_NODE.getCode());
  223. PaymentLog pl=new PaymentLog(p.getId(),0,auditStr+p.getAuditNotes()==null?"":p.getAuditNotes(),a.getId(),a.getName());
  224. paymentLogMapper.insertSelective(pl);
  225. }else if (p.getStatus()==1) {
  226. type= NoticeStatus.PAYMENT_YES.getCode();
  227. tp.setApplicationAmount(p.getApplicationAmount());
  228. auditStr="审核通过:";
  229. }else if(p.getStatus()==2) {
  230. type= NoticeStatus.PAYMENT_NO.getCode();
  231. tp.setApplicationAmount(p.getApplicationAmount());
  232. auditStr="审核驳回:";
  233. }else if (p.getStatus()==3) {
  234. tp.setPaymentAmount(p.getPaymentAmount()==null?p.getPaymentAmount():p.getApplicationAmount());
  235. confirmPayment(p);
  236. auditStr="审核完成";
  237. }else if(p.getStatus()==4) {
  238. auditStr="付款取消";
  239. }
  240. if (p.getStatus()!=0) {
  241. NoticeInformationBo ni=financialPaymentMapper.selectBypidGetNotice(p.getId());
  242. AdminListBo a =adminMapper.getDeptNameByAid(TokenManager.getAdminId());
  243. addNoticAndSendEmail(ni,a,type);
  244. PaymentLog pl=new PaymentLog(p.getId(),p.getStatus(),auditStr+p.getAuditNotes()==null?"":p.getAuditNotes(),a.getId(),a.getName());
  245. paymentLogMapper.insertSelective(pl);
  246. }
  247. return tOrderPaymentMapper.updateByPrimaryKeySelective(tp);
  248. }
  249. private void confirmPayment(TOrderPayment p) {
  250. //如果确定支付
  251. int flag=0;
  252. TOrderPayment tp=tOrderPaymentMapper.selectByPrimaryKey(p.getId());
  253. ThirdPartyCompany tpc=new ThirdPartyCompany();
  254. if (p.getPaymentAmount()==null||p.getPaymentAmount().compareTo(new BigDecimal(0))==0) {
  255. p.setPaymentAmount(tp.getApplicationAmount());
  256. }
  257. if (tp.getChooseType()==1) {
  258. PaymentNode pn=paymentNodeMapper.selectByPrimaryKey(tp.getNodeId());
  259. BigDecimal count=pn.getTotalAmount();
  260. BigDecimal party=pn.getPartyAmount();
  261. party=party.add(p.getPaymentAmount());
  262. if (party.compareTo(new BigDecimal(0))==0) {
  263. flag=0;
  264. }else if (party.compareTo(count)==0) {
  265. flag=2;
  266. }else if (party.compareTo(count)==-1) {
  267. flag=1;
  268. }
  269. pn.setStatus(flag);
  270. pn.setPartyAmount(p.getPaymentAmount());
  271. paymentNodeMapper.updateByPrimaryKeySelective(pn);
  272. tpc=thirdPartyCompanyMapper.selectByPrimaryKey(pn.getCid());
  273. }else {
  274. tpc=thirdPartyCompanyMapper.selectByPrimaryKey(tp.getTpcId());
  275. }
  276. TOrderPayment used=tOrderPaymentMapper.selectByPrimaryKey(p.getId());
  277. tpc.setPartyAmount(tpc.getPartyAmount().add(p.getPaymentAmount()));
  278. tTaskMidMapper.updatePaymentAmount(used.getTid(), tp.getPaymentAmount(), 0);
  279. financialPaymentMapper.updateOrderCost(p.getId(),p.getPaymentAmount());
  280. thirdPartyCompanyMapper.updateByPrimaryKeySelective(tpc);
  281. }
  282. @Override
  283. public List<OutPaymentLog> selectPaymentLog(Integer id) {
  284. return paymentLogMapper.selectByPid(id);
  285. }
  286. @Override
  287. public List<outOrderPayment> selectOrderPayment(Integer id) {
  288. return tOrderPaymentMapper.selectByTid(id);
  289. }
  290. @Override
  291. public int addfinancialPayment(InuptFinancialPayment f) {
  292. f.setPaymentTime(DateUtils.StringToDate(f.getPaymentTimes(), AFTConstants.YYYYMMDD));
  293. // financialPaymentMapper.updateOrderCost(f.getPid(),f.getPartyAmount());
  294. // NoticeInformationBo ni=financialPaymentMapper.selectBypidGetNotice(f.getPid());
  295. // AdminListBo a =adminMapper.getDeptNameByAid(TokenManager.getAdminId());
  296. // addNoticAndSendEmail(ni,a,NoticeStatus.PAYMENT_COMPLETE.getCode());
  297. financialPaymentMapper.insertSelectiveGetId(f);
  298. return f.getId();
  299. }
  300. @Override
  301. public List<outFinancialPayment> selectfinancialPayment(Integer id) {
  302. return financialPaymentMapper.selectByPid(id);
  303. }
  304. public void addNoticAndSendEmail(NoticeInformationBo in,AdminListBo a,Integer type) {
  305. String str=NoticeStatus.getValueByCode(type)+": 订单编号 -"+in.getOrderNo()+
  306. ",客户名称:"+in.getBuyerName()+", 操作人:"+a.getName()+"-"+a.getDepartmentName()+"。";
  307. Notice n =new Notice();
  308. EmailBo bo = new EmailBo(NoticeStatus.getValueByCode(type), a.getEmail(), a.getDepartmentName(), a.getName(),
  309. in.getOrderNo(), in.getSalesmanName());
  310. n.setId(UUID.randomUUID().toString());
  311. if (type==NoticeStatus.PAYMENT_NODE.getCode()) {
  312. n.setAid(in.getFinanceId());
  313. bo.setAddress(in.getFinanceEmail());
  314. } else {
  315. n.setAid(in.getSalesmanId());
  316. bo.setAddress(in.getSalesmanEmail());
  317. }
  318. n.setNoticeType(type);
  319. n.setContent(str);
  320. n.setReaded(0);//未读
  321. noticeMapper.insertSelective(n);
  322. if(StringUtils.isNotBlank(a.getEmail())) {
  323. try {
  324. SendEmailUtil.getInstance().send(bo);
  325. } catch (UnsupportedEncodingException | MessagingException e) {
  326. e.printStackTrace();
  327. }
  328. }
  329. }
  330. @Override
  331. public boolean checkPayment(TOrderPayment p) {
  332. BigDecimal total=new BigDecimal(0);
  333. BigDecimal a=p.getApplicationAmount();
  334. List<outOrderPayment> list=new ArrayList<>();
  335. //支付种类 0第三方 1催款
  336. if (p.getChooseType()==0) {
  337. //首先不能大于第三方
  338. list=tOrderPaymentMapper.selectList(p.getTpcId(),null);
  339. }else if (p.getChooseType()==1) {
  340. list=tOrderPaymentMapper.selectList(null,p.getNodeId());
  341. }
  342. for (outOrderPayment o : list) {
  343. if (o.getApplicationAmount()!=null) {
  344. a=a.add(o.getApplicationAmount());
  345. }
  346. }
  347. if (p.getChooseType()==0) {
  348. ThirdPartyCompany t=thirdPartyCompanyMapper.selectByPrimaryKey(p.getTpcId());
  349. total=t.getTotalAmount();
  350. }else if (p.getChooseType()==1) {
  351. PaymentNode n=paymentNodeMapper.selectByPrimaryKey(p.getNodeId());
  352. total=n.getTotalAmount();
  353. }
  354. if (a.compareTo(total) != 1) {
  355. return false;
  356. }
  357. return true;
  358. }
  359. @Override
  360. public boolean checkprojectDun(TOrderPayment p) {
  361. PaymentNode pn=paymentNodeMapper.selectByPrimaryKey(p.getNodeId());
  362. TOrderTaskDetailBo tt=tOrderTaskMapper.getOrderTaskDetail(p.getTid().toString());
  363. // 项目状态 0-项目待提交 1-项目已提交,2-项目评审,3-项目立项,4-项目公示,5-项目抽查,6-项目备案,7-项目下证,8-项目验收,
  364. // 9-项目拨款 10- 项目进度10% 11- 项目进度30% 12- 项目进度70%
  365. if (pn.getDunType()==0&&pn.getPartyTime().getTime()<new Date().getTime()) {//如果自定义则看触发时间
  366. return false;
  367. }else if (NewOrderDunType.CGZH_WC.getCode()==Integer.valueOf(""+pn.getProjectType()+pn.getDunType())
  368. &&(tt.getProjectStatus()>7&&tt.getProjectStatus()<10)) {
  369. return false;
  370. }else if (NewOrderDunType.COMMON_NGS.getCode()==Integer.valueOf(""+pn.getProjectType()+pn.getDunType())
  371. &&(tt.getProjectStatus()>3&&tt.getProjectStatus()<10)) {
  372. return false;
  373. }else if (NewOrderDunType.COMMON_XZ.getCode()==Integer.valueOf(""+pn.getProjectType()+pn.getDunType())
  374. &&(tt.getProjectStatus()>6&&tt.getProjectStatus()<10)) {
  375. return false;
  376. } else if (NewOrderDunType.KJXM_LX.getCode()==Integer.valueOf(""+pn.getProjectType()+pn.getDunType())
  377. &&(tt.getProjectStatus()>2&&tt.getProjectStatus()<10)) {
  378. return false;
  379. } else if (NewOrderDunType.KJXM_BK.getCode()==Integer.valueOf(""+pn.getProjectType()+pn.getDunType())
  380. &&(tt.getProjectStatus()>8&&tt.getProjectStatus()<10)) {
  381. return false;
  382. } else if (NewOrderDunType.KJJR_BK.getCode()==Integer.valueOf(""+pn.getProjectType()+pn.getDunType())
  383. &&(tt.getProjectStatus()>8&&tt.getProjectStatus()<10)) {
  384. return false;
  385. } else if (NewOrderDunType.RJKF_LX.getCode()==Integer.valueOf(""+pn.getProjectType()+pn.getDunType())
  386. &&(tt.getProjectStatus()>2&&tt.getProjectStatus()<10)) {
  387. return false;
  388. } else if (NewOrderDunType.RJKF_WZ.getCode()==Integer.valueOf(""+pn.getProjectType()+pn.getDunType())
  389. &&(tt.getProjectStatus()>7&&tt.getProjectStatus()<10)) {
  390. return false;
  391. } else if (NewOrderDunType.ZSCQ_GS_SL_XZ.getCode()==Integer.valueOf(""+pn.getProjectType()+pn.getDunType())) {
  392. if (tt.getBpType()==1&&(tt.getProjectStatus()>7&&tt.getProjectStatus()<10)) {
  393. return false;
  394. }else if (tt.getBpType()!=1&&(tt.getProjectStatus()>3&&tt.getProjectStatus()<10)){
  395. return false;
  396. }
  397. } else if (NewOrderDunType.ZSCQ_XZ.getCode()==Integer.valueOf(""+pn.getProjectType()+pn.getDunType())
  398. &&(tt.getProjectStatus()>6&&tt.getProjectStatus()<10)) {
  399. return false;
  400. }
  401. return true;
  402. }
  403. @SuppressWarnings("unchecked")
  404. @Override
  405. public Pagination<outPaymentList> selectPaymentList(InputPaymentList i) {
  406. Map<String, Object> map =new HashMap<>();
  407. map.put("aid", TokenManager.getAdminId());
  408. if (i.getContractNo()!=null)map.put("contractNo", i.getContractNo());
  409. if (i.getOrderNo()!=null)map.put("orderNo", i.getOrderNo());
  410. if (i.getUserName()!=null)map.put("userName", i.getUserName());
  411. if (i.getDepId()!=null)map.put("depId", i.getDepId());
  412. if (i.getAname()!=null)map.put("aname", i.getAname());
  413. if (i.getFinanceName()!=null)map.put("financeName", i.getFinanceName());
  414. if (i.getCname()!=null)map.put("cname", i.getCname());
  415. if (i.getPname()!=null)map.put("pname", i.getPname());
  416. if (i.getStatus()!=null)map.put("status", i.getStatus());
  417. if (TokenManager.hasRole(AFTConstants.FINANCE_MANAGER)) {
  418. map.put("lvl", 1);
  419. }else if (TokenManager.hasRole(AFTConstants.FINANCE_ADMIN)||TokenManager.hasRole(AFTConstants.VICE_CEO)||
  420. TokenManager.hasRole(AFTConstants.CED)||TokenManager.hasRole(AFTConstants.SUPERADMIN)||
  421. TokenManager.hasRole(AFTConstants.APPROVAL_DECISION)) {
  422. map.put("lvl", 2);
  423. }else {
  424. map.put("lvl", 0);
  425. }
  426. return (Pagination<outPaymentList>)findPage("selectPaymentList","selectPaymentCount",
  427. map,i.getPageNo(),i.getPageSize());
  428. }
  429. @SuppressWarnings("unchecked")
  430. @Override
  431. public Pagination<outNodeList> selectPaymentList(InputNodeList i) {
  432. Map<String, Object> map =new HashMap<>();
  433. map.put("aid", TokenManager.getAdminId());
  434. if (i.getContractNo()!=null)map.put("contractNo", i.getContractNo());
  435. if (i.getOrderNo()!=null)map.put("orderNo", i.getOrderNo());
  436. if (i.getUserName()!=null)map.put("userName", i.getUserName());
  437. if (i.getCname()!=null)map.put("cname", i.getCname());
  438. if (i.getPname()!=null)map.put("pname", i.getPname());
  439. if (i.getStatus()!=null)map.put("status", i.getStatus());
  440. if (i.getStartTime()!=null&&i.getEndTime()!=null) {
  441. map.put("startTime", DateUtils.StringToDate(i.getStartTime(), AFTConstants.YYYYMMDD));
  442. map.put("endTime", DateUtils.StringToDate(i.getEndTime()+" 23:59:59", AFTConstants.YYYYMMDDHHMMSS));
  443. }
  444. if (TokenManager.hasRole(AFTConstants.FINANCE)) {
  445. map.put("lvl", 1);
  446. }else if (TokenManager.hasRole(AFTConstants.FINANCE_MANAGER)) {
  447. map.put("lvl", 2);
  448. }else if (TokenManager.hasRole(AFTConstants.FINANCE_ADMIN)||TokenManager.hasRole(AFTConstants.VICE_CEO)||
  449. TokenManager.hasRole(AFTConstants.CED)||TokenManager.hasRole(AFTConstants.SUPERADMIN)||
  450. TokenManager.hasRole(AFTConstants.APPROVAL_DECISION)) {
  451. map.put("lvl", 3);
  452. }else {
  453. map.put("lvl", 0);
  454. }
  455. return (Pagination<outNodeList>)findPage("selectNodeList","selectNodeCount",
  456. map,i.getPageNo(),i.getPageSize());
  457. }
  458. @Override
  459. public int insertSoftWritingPrice(SoftWritingPrice s) {
  460. return softWritingPriceMapper.insertSelective(s);
  461. }
  462. @Override
  463. public int updateSoftWritingPrice(SoftWritingPrice s) {
  464. return softWritingPriceMapper.updateByPrimaryKeySelective(s);
  465. }
  466. @Override
  467. public Integer pushSelectByCid(String companyName,int i) {
  468. String aid=null;
  469. if (i==1) {
  470. aid=TokenManager.getAdminId();
  471. }
  472. List<Integer> list=companyLibraryMapper.selectName(companyName,i,aid);
  473. if (list.size()<1) {
  474. CompanyLibrary c=new CompanyLibrary();
  475. c.setCompanyName(companyName);
  476. companyLibraryMapper.insertSelectiveGetId(c);
  477. return c.getId();
  478. }else {
  479. return list.get(0);
  480. }
  481. }
  482. @SuppressWarnings("unchecked")
  483. @Override
  484. public Pagination<SoftWritingPrice> listSoftWritingPrice(SoftWritingPrice s, Integer pageNo, Integer pageSize) {
  485. Map<String, Object> map =new HashMap<>();
  486. map.put("s", s);
  487. return (Pagination<SoftWritingPrice>)findPage("softWritingPriceList","softWritingPriceCount",
  488. map,pageNo,pageSize);
  489. }
  490. @Override
  491. public int deleteSoftWritingPrice(Integer id) {
  492. return softWritingPriceMapper.deleteByPrimaryKey(id);
  493. }
  494. @Override
  495. public boolean checkSoftWritingPrice(SoftWritingPrice s) {
  496. SoftWritingPrice sw=new SoftWritingPrice();
  497. if(s.getId()!=null)sw=softWritingPriceMapper.selectByPrimaryKey(s.getId());
  498. if (s.getId()!=null) {
  499. s.setCid(sw.getCid());
  500. }
  501. List<SoftWritingPrice>list=softWritingPriceMapper.checkSoftWritingPrice(s);
  502. if (list.size()<1) {
  503. return false;
  504. }else if (list.size()==1&&s.getId()!=null) {
  505. for (SoftWritingPrice ss : list) {
  506. if(ss.getId().equals(s.getId()))return false;
  507. }
  508. }
  509. return true;
  510. }
  511. @Override
  512. public Map<String ,Object> updateGroupPayment(String ids) {
  513. String [] idss=ids.split(",");
  514. List<Integer>elist=new ArrayList<>();
  515. List<Integer> list=new ArrayList<>();
  516. for (String s : idss) {
  517. TOrderPayment top=tOrderPaymentMapper.selectByPrimaryKey(Integer.valueOf(s));
  518. if (top!=null&&top.getStatus()==1) {
  519. list.add(top.getId());
  520. //做已付款金额计算
  521. confirmPayment(top);
  522. }else {
  523. elist.add(Integer.valueOf(s));
  524. }
  525. }
  526. if(!list.isEmpty())tOrderPaymentMapper.updateByids(list);
  527. Map<String ,Object> map=new HashMap<>();
  528. map.put("OK", list);
  529. map.put("fail", elist);
  530. return map;
  531. }
  532. @Override
  533. public int addOfficialFeePrice(OfficialFeePrice o) {
  534. return officialFeePriceMapper.insertSelective(o);
  535. }
  536. @Override
  537. public int updateOfficialFeePrice(OfficialFeePrice o) {
  538. return officialFeePriceMapper.updateByPrimaryKeySelective(o);
  539. }
  540. @Override
  541. public int deleteOfficialFeePrice(Integer id) {
  542. return officialFeePriceMapper.deleteByPrimaryKey(id);
  543. }
  544. @Override
  545. public List<OfficialFeePrice> listOfficialFeePrice(String name) {
  546. return officialFeePriceMapper.selectListByname(name);
  547. }
  548. @Override
  549. public int deleteFinancialPayment(Integer id) {
  550. return financialPaymentMapper.deleteByPrimaryKey(id);
  551. }
  552. @Override
  553. public void calculationUnitPrice(ThirdPartyCompany t) {
  554. SoftWritingPrice s=new SoftWritingPrice();
  555. int i=0;
  556. s.setCid(t.getCid());
  557. s.setMaterial(t.getMaterial());
  558. s.setUrgent(t.getUrgent());
  559. List<SoftWritingPrice> list=softWritingPriceMapper.checkSoftWritingPrice(s);
  560. for (SoftWritingPrice sw : list) {
  561. t.setUnitPrice(sw.getUnitPrice());
  562. t.setTotalAmount(sw.getUnitPrice().multiply(new BigDecimal(t.getQuantity())));
  563. }
  564. }
  565. @Override
  566. public void calculationPatentUnitPrice(ThirdPartyCompany t,Integer patentType) {
  567. PatentPrice p=patentPriceMapper.selectBycid(t.getCid());
  568. // 专利名称 0实用新型 1发明专利 2外观专利 3 其他
  569. BigDecimal unitPrice=null;
  570. if (patentType==0) {
  571. unitPrice=p.getUtilityModel();
  572. }else if (patentType==1) {
  573. unitPrice=p.getInventionPatent();
  574. }else if (patentType==2) {
  575. unitPrice=p.getAppearancePatent();
  576. }
  577. t.setUnitPrice(unitPrice);
  578. t.setTotalAmount(unitPrice.multiply(new BigDecimal(t.getQuantity())));
  579. }
  580. @Override
  581. public int addpatentPrice(PatentPrice p) {
  582. return patentPriceMapper.insertSelective(p);
  583. }
  584. @Override
  585. public int updatepatentPrice(PatentPrice p) {
  586. return patentPriceMapper.updateByPrimaryKeySelective(p);
  587. }
  588. @Override
  589. public int deletepatentPrice(Integer id) {
  590. return patentPriceMapper.deleteByPrimaryKey(id);
  591. }
  592. @Override
  593. public List<PatentPrice> listpatentPrice(String name) {
  594. return patentPriceMapper.selectlist(name);
  595. }
  596. }