|
|
@@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.usoftchina.saas.base.Result;
|
|
|
import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
|
|
|
+import com.usoftchina.saas.commons.api.ConfigsApi;
|
|
|
import com.usoftchina.saas.commons.api.MaxnumberService;
|
|
|
import com.usoftchina.saas.commons.api.MessageLogService;
|
|
|
import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
|
|
|
@@ -12,14 +13,12 @@ import com.usoftchina.saas.commons.dto.ComboDTO;
|
|
|
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.DataImportDetail;
|
|
|
-import com.usoftchina.saas.commons.po.Operation;
|
|
|
-import com.usoftchina.saas.commons.po.Status;
|
|
|
+import com.usoftchina.saas.commons.po.*;
|
|
|
import com.usoftchina.saas.context.BaseContextHolder;
|
|
|
import com.usoftchina.saas.document.dto.*;
|
|
|
import com.usoftchina.saas.document.entities.*;
|
|
|
import com.usoftchina.saas.document.mapper.*;
|
|
|
+import com.usoftchina.saas.document.service.CustAramountService;
|
|
|
import com.usoftchina.saas.document.service.CustomerService;
|
|
|
import com.usoftchina.saas.exception.BizException;
|
|
|
import com.usoftchina.saas.page.PageRequest;
|
|
|
@@ -31,7 +30,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
-import sun.reflect.generics.tree.LongSignature;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
@@ -63,7 +61,12 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
|
|
|
private CustomerMapper customerMapper;
|
|
|
@Autowired
|
|
|
private DataImportMapper dataImportMapper;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private ConfigsApi configsApi;
|
|
|
+ @Autowired
|
|
|
+ private CustAramountService custAramountService;
|
|
|
+ @Autowired
|
|
|
+ private CustAramountMapper custAramountMapper;
|
|
|
|
|
|
@Override
|
|
|
public PageInfo<CustomerList> getListData(PageRequest page, ListReqDTO req) {
|
|
|
@@ -135,28 +138,6 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
|
|
|
customer.setCreatorId(userId);
|
|
|
customer.setCreateTime(new Date());
|
|
|
customer.setCreatorName(userName);
|
|
|
- //应付款余额
|
|
|
- Double beginapamount = main.getCu_beginaramount()==null?new Double(0):main.getCu_beginaramount();
|
|
|
- Double beginprepayamount = main.getCu_beginprerecamount()==null?new Double(0):main.getCu_beginprerecamount();
|
|
|
- Double recamount = main.getCu_recamount()==null? new Double(0):main.getCu_recamount();
|
|
|
- Double preamount = main.getCu_preamount()==null? new Double(0):main.getCu_preamount();
|
|
|
- customer.setCu_leftamount(beginapamount-beginprepayamount+recamount-preamount);
|
|
|
-
|
|
|
- //获取已结账的期间
|
|
|
- String YM = subledgerMapper.selectUnPeriod(companyId);
|
|
|
- if(YM==null || YM.equals("")){
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMM");
|
|
|
- YM = simpleDateFormat.format(main.getCu_begindate());
|
|
|
- }else{
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMM");
|
|
|
- String beginDate = simpleDateFormat.format(main.getCu_begindate());
|
|
|
- if(Integer.valueOf(YM)>Integer.valueOf(beginDate)){
|
|
|
- int code = BizExceptionCode.LIMIT_PERIOD_CUSTOMER.getCode();
|
|
|
- String mes = String.format(BizExceptionCode.LIMIT_PERIOD_CUSTOMER.getMessage(),YM);
|
|
|
- throw new BizException(code , mes);
|
|
|
- }
|
|
|
- YM = beginDate;
|
|
|
- }
|
|
|
//编号校验
|
|
|
cu_code = RegexpUtils.replaceSpecCharacter(cu_code);
|
|
|
//检测单号是否修改
|
|
|
@@ -184,11 +165,10 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
|
|
|
detail1.setCreatorName(userName);
|
|
|
insertDetail1.add(detail1);
|
|
|
}
|
|
|
- //插入从表
|
|
|
+ //插入从表1
|
|
|
if (insertDetail1.size()>0) {
|
|
|
customercontactMapper.batchInsert(insertDetail1);
|
|
|
}
|
|
|
-
|
|
|
for (CustomeraddressDTO item : items2) {
|
|
|
Customeraddress detail2 = BeanMapper.map(item,Customeraddress.class);
|
|
|
detail2.setCa_cuid(cu_id);
|
|
|
@@ -198,10 +178,25 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
|
|
|
detail2.setCreatorName(userName);
|
|
|
insertDetail2.add(detail2);
|
|
|
}
|
|
|
- //插入从表
|
|
|
+ //插入从表2
|
|
|
if (insertDetail2.size()>0) {
|
|
|
customeraddressMapper.batchInsert(insertDetail2);
|
|
|
}
|
|
|
+ //单一币别设置期初
|
|
|
+ if(1==2 ){
|
|
|
+ Double beginAramount=main.getCu_beginaramount()==null ? new Double(0):main.getCu_beginaramount();
|
|
|
+ Double beginPreRecamount=main.getCu_beginprerecamount()==null ? new Double(0):main.getCu_beginaramount();
|
|
|
+ if(beginAramount>0 || beginPreRecamount>0){
|
|
|
+ CustAramount custAramount=new CustAramount();
|
|
|
+ custAramount.setId(new Long(0));
|
|
|
+ custAramount.setCa_beginaramount(beginAramount);
|
|
|
+ custAramount.setCa_beginprerecamount(beginPreRecamount);
|
|
|
+ custAramount.setCa_currency(configsApi.getConfigDataBycode("defaultCurrency"));
|
|
|
+ custAramount.setCa_custid(main.getId());
|
|
|
+ custAramount.setCa_custcode(main.getCu_code());
|
|
|
+ custAramountService.saveData(custAramount);
|
|
|
+ }
|
|
|
+ }
|
|
|
baseDTO = getBaseDTOById(cu_id);
|
|
|
//日志记录
|
|
|
messageLogService.save(baseDTO);
|
|
|
@@ -212,7 +207,6 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
|
|
|
if (count > 0) {
|
|
|
throw new BizException(BizExceptionCode.REPEAT_CUSTOMERCODE);
|
|
|
}
|
|
|
-
|
|
|
//有关联时不可修改名称编号
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
map.put("v_id",cu_id);
|
|
|
@@ -227,7 +221,6 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
|
|
|
if (count > 0) {
|
|
|
throw new BizException(BizExceptionCode.BIZ_RELUPDATE_CODEANDNAME);
|
|
|
}
|
|
|
-
|
|
|
//限制关联单据不可修改金额
|
|
|
Customer customer1 = getMapper().selectByPrimaryKey(customer.getId());
|
|
|
if (customer.getCu_beginaramount()!=null&&(customer.getCu_beginaramount().doubleValue() != customer1.getCu_beginaramount().doubleValue() ||
|
|
|
@@ -237,8 +230,6 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
//检查期初日期是否已结转
|
|
|
count = getMapper().validFinish(cu_id, companyId);
|
|
|
if (count > 0) {
|
|
|
@@ -248,7 +239,6 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
|
|
|
//期初预收
|
|
|
customer.setCu_beginprerecamount(cutpl.getCu_beginprerecamount());
|
|
|
}
|
|
|
-
|
|
|
//更新操作
|
|
|
getMapper().updateByPrimaryKeySelective(customer);
|
|
|
//添加从表传输对象
|
|
|
@@ -284,7 +274,6 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
|
|
|
} else {
|
|
|
updateDetail2.add(detail2);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
//插入从表
|
|
|
if (insertDetail2.size() > 0) {
|
|
|
@@ -294,55 +283,14 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
|
|
|
if (updateDetail2.size() > 0) {
|
|
|
customeraddressMapper.batchUpdate(updateDetail2);
|
|
|
}
|
|
|
+ if(1==2){//单一币别
|
|
|
+ }
|
|
|
baseDTO = getBaseDTOById(cu_id);
|
|
|
//日志记录
|
|
|
messageLogService.update(baseDTO);
|
|
|
}
|
|
|
-
|
|
|
- //更新应收余额
|
|
|
- Customer customer1 = getMapper().selectByPrimaryKey(cu_id);
|
|
|
- Double cu_leftamount = (customer1.getCu_beginaramount() == null ? new Double(0) : customer1.getCu_beginaramount())-
|
|
|
- (customer1.getCu_beginprerecamount() == null ? new Double(0) : customer1.getCu_beginprerecamount()) +
|
|
|
- (customer1.getCu_recamount() == null ? new Double(0) : customer1.getCu_recamount()) -
|
|
|
- (customer1.getCu_preamount() == null ? new Double(0) : customer1.getCu_preamount());
|
|
|
- customer.setCu_leftamount(cu_leftamount);
|
|
|
- getMapper().updateByPrimaryKeySelective(customer);
|
|
|
-
|
|
|
- //插入中间表
|
|
|
- Double amount = (main.getCu_beginaramount() == null ? new Double(0) : main.getCu_beginaramount())
|
|
|
- - (main.getCu_beginprerecamount() == null ? new Double(0) : main.getCu_beginprerecamount());
|
|
|
- Subledger subledger = new Subledger();
|
|
|
- subledger.setSl_code("期初余额");
|
|
|
- subledger.setSl_kind("期初余额");
|
|
|
- subledger.setSl_vendid(0);
|
|
|
- subledger.setSl_custid(Math.toIntExact(customer.getId()));
|
|
|
- subledger.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
- subledger.setSl_date(DateUtils.getFirstDay(customer.getCu_begindate()));
|
|
|
- subledger.setSl_ym(DateUtils.getYm(customer.getCu_begindate()));
|
|
|
- subledger.setCreateTime(new Date());
|
|
|
- subledger.setCreatorId(BaseContextHolder.getUserId());
|
|
|
- subledger.setCreatorName(BaseContextHolder.getUserName());
|
|
|
- subledger.setSl_currency(customer.getCu_currency());
|
|
|
- if (amount > new Double(0)){
|
|
|
- subledger.setSl_amount(amount);
|
|
|
- subledger.setSl_preamount(new Double(0));
|
|
|
- }else {
|
|
|
- subledger.setSl_amount(new Double(0));
|
|
|
- subledger.setSl_preamount(Math.abs(amount));
|
|
|
- }
|
|
|
- subledger.setSl_orderamount(Math.abs(amount));
|
|
|
- subledger.setSl_namount((subledger.getSl_orderamount() == null ? new Double(0) : subledger.getSl_orderamount()) +
|
|
|
- (subledger.getSl_discount() == null ? new Double(0) : subledger.getSl_discount()) -
|
|
|
- (subledger.getSl_yamount() == null ? new Double(0) : subledger.getSl_yamount()));
|
|
|
-
|
|
|
- Long sl_id = subledgerMapper.selectByKindCodeCustid("期初余额","期初余额",
|
|
|
- Math.toIntExact(customer.getId()),BaseContextHolder.getCompanyId(),YM);
|
|
|
- subledger.setId(sl_id);
|
|
|
- if ( sl_id!=null && sl_id > 0 ) {
|
|
|
- subledgerMapper.updateByPrimaryKeySelective(subledger);
|
|
|
- }else {
|
|
|
- subledgerMapper.insertSelective(subledger);
|
|
|
- }
|
|
|
+ //更新供应商应付余额表供应商编号,名称.
|
|
|
+ custAramountMapper.updateCodeAndNameByCustid(main.getId());
|
|
|
return baseDTO;
|
|
|
}
|
|
|
|
|
|
@@ -372,10 +320,10 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
|
|
|
//从表删除
|
|
|
customercontactMapper.deleteByFK(id);
|
|
|
customeraddressMapper.deleteByFK(id);
|
|
|
-
|
|
|
+ //删除客户期初设置
|
|
|
+ custAramountMapper.deleteByCustid(id);
|
|
|
//删除中间表
|
|
|
subledgerMapper.deleteCustomer("期初余额", "期初余额", Math.toIntExact(id));
|
|
|
-
|
|
|
//日志
|
|
|
messageLogService.delete(docBaseDTO);
|
|
|
}
|