|
|
@@ -2,16 +2,24 @@ package com.usoftchina.saas.sale.service.impl;
|
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import com.usoftchina.saas.base.Result;
|
|
|
+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.page.PageRequest;
|
|
|
+import com.usoftchina.saas.sale.dto.SaleDTO;
|
|
|
+import com.usoftchina.saas.sale.dto.SaleDetailDTO;
|
|
|
+import com.usoftchina.saas.sale.dto.SaleFormDTO;
|
|
|
import com.usoftchina.saas.sale.mapper.SaledownMapper;
|
|
|
import com.usoftchina.saas.sale.po.*;
|
|
|
import com.usoftchina.saas.sale.service.SaleDownService;
|
|
|
+import com.usoftchina.saas.sale.service.SaleService;
|
|
|
+import com.usoftchina.saas.utils.BeanMapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
@@ -30,6 +38,12 @@ public class SaleDownServiceImpl implements SaleDownService{
|
|
|
@Autowired
|
|
|
private SaledownMapper saledownMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private MaxnumberService maxnumberService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SaleService saleService;
|
|
|
+
|
|
|
@Override
|
|
|
public PageInfo getListData(PageRequest page, ListReqDTO req) {
|
|
|
PageHelper.startPage(page.getNumber(), page.getSize());
|
|
|
@@ -95,6 +109,37 @@ public class SaleDownServiceImpl implements SaleDownService{
|
|
|
return baseDTO;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public DocBaseDTO toSale(Long id) {
|
|
|
+ if (StringUtils.isEmpty(id)){
|
|
|
+ throw new BizException(BizExceptionCode.EMPTY_DATA);
|
|
|
+ }
|
|
|
+ //查询主表信息
|
|
|
+ SaleDown main = saledownMapper.selectByPrimaryKey(id);
|
|
|
+ //查询从表
|
|
|
+ List<SaleDownDetail> items = saledownMapper.selectByFK(id);
|
|
|
+ if (Status.CLOSE.getDisplay().equals(main.getSa_status())) {
|
|
|
+ throw new BizException(BizExceptionCode.SALEDOWN_CLOSE);
|
|
|
+ }
|
|
|
+ //转销售单
|
|
|
+ SaleFormDTO saleFormDTO = new SaleFormDTO();
|
|
|
+ List<SaleDetailDTO> details = null;
|
|
|
+ SaleDTO map = BeanMapper.map(main, SaleDTO.class);
|
|
|
+ Result<String> maxnumber = maxnumberService.getMaxnumber(BillCodeSeq.SALE.getCaller(), true);
|
|
|
+ if (maxnumber.isSuccess()) {
|
|
|
+ map.setSa_code(maxnumber.getData());
|
|
|
+ } else {
|
|
|
+ throw new BizException(maxnumber.getCode(), maxnumber.getMessage());
|
|
|
+ }
|
|
|
+ map.setId(0l);
|
|
|
+ map.setSa_date(new Date());
|
|
|
+
|
|
|
+ details = BeanMapper.mapList(items, SaleDetailDTO.class);
|
|
|
+ saleFormDTO.setMain(map);
|
|
|
+ saleFormDTO.setItems(details);
|
|
|
+ return saleService.saveFormData(saleFormDTO);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public SaleDownForm getFormData(Long id) {
|
|
|
if (null == id || "0".equals(id)) {
|