package com.goafanti.organization.service.impl; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.goafanti.common.constant.AFTConstants; import com.goafanti.common.dao.AdminMapper; import com.goafanti.common.dao.CompanyLibraryMapper; import com.goafanti.common.dao.PaymentLogMapper; import com.goafanti.common.dao.PaymentNodeMapper; import com.goafanti.common.dao.TOrderPaymentMapper; import com.goafanti.common.dao.ThirdPartyCompanyMapper; import com.goafanti.common.model.Admin; import com.goafanti.common.model.CompanyLibrary; import com.goafanti.common.model.PaymentLog; import com.goafanti.common.model.TOrderPayment; import com.goafanti.common.model.ThirdPartyCompany; import com.goafanti.common.utils.DateUtils; import com.goafanti.core.mybatis.BaseMybatisDao; import com.goafanti.core.shiro.token.TokenManager; import com.goafanti.organization.bo.InputPaymentNode; import com.goafanti.organization.bo.OutPaymentLog; import com.goafanti.organization.bo.OutPaymentNode; import com.goafanti.organization.bo.OutThirdPartyCompany; import com.goafanti.organization.bo.outOrderPayment; import com.goafanti.organization.service.ThirdPartyCompanyService; @Service public class ThirdPartyCompanyServiceImpl extends BaseMybatisDao 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; @Override public int addCompany(ThirdPartyCompany t) { if (t.getCid()==null) { List list=companyLibraryMapper.selectName(t.getCompanyName()); if (list.size()<1) { CompanyLibrary c=new CompanyLibrary(); c.setCompanyName(t.getCompanyName()); c.setAid(TokenManager.getAdminId()); companyLibraryMapper.insertSelectiveGetId(c); t.setCid(c.getId()); }else { t.setCid(Integer.parseInt(list.get(0))); } } return thirdPartyCompanyMapper.insertSelective(t); } @Override public int updateCompany(ThirdPartyCompany t) { if (t.getCid()==null) { CompanyLibrary c=new CompanyLibrary(); c.setCompanyName(t.getCompanyName()); c.setAid(TokenManager.getAdminId()); companyLibraryMapper.insertSelectiveGetId(c); t.setCid(c.getId()); } return thirdPartyCompanyMapper.updateByPrimaryKeySelective(t); } @Override public List selectVague(String name) { return companyLibraryMapper.selectVague(name); } @Override public int addPaymentNode(InputPaymentNode p) { if (p.getPartyTimes()!=null) { p.setPartyTime(DateUtils.StringToDate(p.getPartyTimes(), AFTConstants.YYYYMMDD)); } return paymentNodeMapper.insertSelective(p); } @Override public int updatePaymentNode(InputPaymentNode p) { if (p.getPartyTimes()!=null) { p.setPartyTime(DateUtils.StringToDate(p.getPartyTimes(), AFTConstants.YYYYMMDD)); } return paymentNodeMapper.updateByPrimaryKeySelective(p); } @Override public List selectCompany(Integer tid) { return thirdPartyCompanyMapper.selectByTid(tid); } @Override public List selectPaymentNode(Integer tid) { return paymentNodeMapper.selectByTid(tid,null); } @Override public int deleteCompany(Integer id) { return thirdPartyCompanyMapper.deleteByPrimaryKey(id); } @Override public int deletePaymentNode(Integer id) { return paymentNodeMapper.deleteByPrimaryKey(id); } @Override public int addOrderPayment(TOrderPayment p) { tOrderPaymentMapper.insertSelectiveGetId(p); Admin a=adminMapper.selectByPrimaryKey(TokenManager.getAdminId()); PaymentLog pl=new PaymentLog(p.getId(),0,"发起付款",a.getId(),a.getName()); paymentLogMapper.insertSelective(pl); return 1; } @Override public outOrderPayment OrderPaymentDetails(Integer id) { return tOrderPaymentMapper.selectByidGetDetails(id); } @Override public int updateOrderPayment(TOrderPayment p) { return tOrderPaymentMapper.updateByPrimaryKeySelective(p); } @Override public List selectOrderPayment(Integer id) { return paymentLogMapper.selectByPid(id); } }