|
|
@@ -2,16 +2,25 @@ package com.usoftchina.saas.money.service.impl;
|
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import com.usoftchina.saas.commons.api.MaxnumberService;
|
|
|
+import com.usoftchina.saas.commons.dto.DocBaseDTO;
|
|
|
+import com.usoftchina.saas.commons.dto.ListReqDTO;
|
|
|
+import com.usoftchina.saas.commons.exception.BizExceptionCode;
|
|
|
+import com.usoftchina.saas.commons.po.BillCodeSeq;
|
|
|
import com.usoftchina.saas.commons.po.Status;
|
|
|
+import com.usoftchina.saas.context.BaseContextHolder;
|
|
|
+import com.usoftchina.saas.exception.BizException;
|
|
|
import com.usoftchina.saas.money.mapper.FundtransferMapper;
|
|
|
import com.usoftchina.saas.money.mapper.FundtransferdetailMapper;
|
|
|
import com.usoftchina.saas.money.po.Fundtran;
|
|
|
import com.usoftchina.saas.money.po.Fundtransfer;
|
|
|
import com.usoftchina.saas.money.po.Fundtransferdetail;
|
|
|
+import com.usoftchina.saas.money.po.Paybalance;
|
|
|
import com.usoftchina.saas.money.service.FundtransferService;
|
|
|
import com.usoftchina.saas.page.PageRequest;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
@@ -26,34 +35,55 @@ public class FundtransferServiceImpl implements FundtransferService {
|
|
|
private FundtransferMapper fundtransferMapper;
|
|
|
@Autowired
|
|
|
private FundtransferdetailMapper fundtransferdetailMapper;
|
|
|
+ @Autowired
|
|
|
+ private MaxnumberService maxnumberService;
|
|
|
|
|
|
@Override
|
|
|
- public int insert(Fundtran fundtran) {
|
|
|
+ public DocBaseDTO insert(Fundtran fundtran) {
|
|
|
Fundtransfer fundtransfer = fundtran.getMain();
|
|
|
List<Fundtransferdetail> fundtransferdetails = fundtran.getItems();
|
|
|
|
|
|
+ String ft_code = fundtransfer.getFt_code();
|
|
|
+
|
|
|
+ //编号校验
|
|
|
+ ft_code = pushMaxnubmer(ft_code, fundtransfer.getId());
|
|
|
+
|
|
|
+ System.out.println("ft_code" + ft_code);
|
|
|
+ //单号赋值
|
|
|
+ fundtransfer.setFt_code(ft_code);
|
|
|
+
|
|
|
+ Long id = fundtransfer.getId();
|
|
|
+
|
|
|
if (fundtransfer.getId() > 0){
|
|
|
fundtransferMapper.updateByPrimaryKeySelective(fundtransfer);
|
|
|
}else {
|
|
|
- fundtransferMapper.insert(fundtransfer);
|
|
|
+ fundtransfer.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
+ fundtransferMapper.insertSelective(fundtransfer);
|
|
|
+ id = fundtransfer.getId();
|
|
|
}
|
|
|
|
|
|
Iterator isdet = fundtransferdetails.iterator();
|
|
|
while (isdet.hasNext()){
|
|
|
Fundtransferdetail fundtransferdetail= (Fundtransferdetail) isdet.next();
|
|
|
- if (fundtransferdetail.getFtdId() > 0 ){
|
|
|
+ fundtransfer.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
+ fundtransferdetail.setFtd_ftid(Math.toIntExact(id));
|
|
|
+ if (fundtransferdetail.getId() > 0 ){
|
|
|
fundtransferdetailMapper.updateByPrimaryKey(fundtransferdetail);
|
|
|
}else {
|
|
|
fundtransferdetailMapper.insertSelective(fundtransferdetail);
|
|
|
}
|
|
|
}
|
|
|
- return 0;
|
|
|
+ return new DocBaseDTO(id, ft_code, BillCodeSeq.FUNDTRANSFER.getCaller());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void audit(Fundtran fundtran) {
|
|
|
+ Long companyId = BaseContextHolder.getCompanyId();
|
|
|
int id = Math.toIntExact(fundtran.getMain().getId());
|
|
|
Fundtransfer fundtransfer = fundtransferMapper.selectByPrimaryKey(id);
|
|
|
+ fundtransfer.setFt_status(Status.AUDITED.getDisplay());
|
|
|
+ fundtransfer.setFt_statuscode(Status.AUDITED.name());
|
|
|
+ fundtransfer.setCompanyId(companyId);
|
|
|
if ( fundtransfer == null || "".equals(fundtransfer)){
|
|
|
this.insert(fundtran);
|
|
|
}else {
|
|
|
@@ -85,12 +115,12 @@ public class FundtransferServiceImpl implements FundtransferService {
|
|
|
public Fundtran select(int id) {
|
|
|
Fundtran fundtran = new Fundtran();
|
|
|
fundtran.setMain(fundtransferMapper.selectByPrimaryKey(id));
|
|
|
- fundtran.setItems((List<Fundtransferdetail>) fundtransferdetailMapper.selectByPrimaryKey(id));
|
|
|
+ fundtran.setItems(fundtransferdetailMapper.selectByPrimaryKey(id));
|
|
|
return fundtran;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PageInfo<Fundtransfer> selectList(PageRequest page) {
|
|
|
+ public PageInfo<Fundtransfer> selectList(PageRequest page, ListReqDTO reqDTO) {
|
|
|
//设置默认分页
|
|
|
if (null == page || page.getSize() == 0 || page.getNumber() == 0) {
|
|
|
page = new PageRequest();
|
|
|
@@ -98,9 +128,44 @@ public class FundtransferServiceImpl implements FundtransferService {
|
|
|
page.setSize(10);
|
|
|
}
|
|
|
PageHelper.startPage(page.getNumber(), page.getSize());
|
|
|
- List<Fundtransfer> fundtransfers = fundtransferMapper.selectList();
|
|
|
+ List<Fundtransfer> fundtransfers = this.getListByMode(reqDTO);
|
|
|
//取分页信息
|
|
|
PageInfo<Fundtransfer> pageInfo = new PageInfo<>(fundtransfers);
|
|
|
return pageInfo;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Description: 检验获取并更新单号
|
|
|
+ * @Param: [code, id]
|
|
|
+ * @return: java.lang.String
|
|
|
+ * @Author: guq
|
|
|
+ * @Date: 2018/10/19
|
|
|
+ */
|
|
|
+ private String pushMaxnubmer(String code, Long id) {
|
|
|
+ if (null == code) {
|
|
|
+ throw new BizException(BizExceptionCode.NULL_CODE);
|
|
|
+ }
|
|
|
+ Long companyId = BaseContextHolder.getCompanyId();
|
|
|
+ Integer count = "0".equals(String.valueOf(id)) ? fundtransferMapper.validateCodeWhenInsert(code, companyId) :
|
|
|
+ fundtransferMapper.validateCodeWhenUpdate(code, id, companyId);
|
|
|
+ return maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.FUNDTRANSFER.getCaller()).getData();
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Fundtransfer> getListByMode(ListReqDTO req) {
|
|
|
+ List<Fundtransfer> fundtransferList = null;
|
|
|
+ Long companyId = BaseContextHolder.getCompanyId();
|
|
|
+ if (StringUtils.isEmpty(req)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ String con = req.getFinalCondition();
|
|
|
+ if (null == con) {
|
|
|
+ con = "1=1";
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(req.getMode()) || "MAIN".equals(req.getMode())) {
|
|
|
+ fundtransferList = fundtransferMapper.selectFundtransferBycondition(con, companyId);
|
|
|
+ } else {
|
|
|
+ fundtransferList = fundtransferMapper.selectFundtransferListByCondition(con, companyId);
|
|
|
+ }
|
|
|
+ return fundtransferList;
|
|
|
+ }
|
|
|
}
|