|
|
@@ -9,21 +9,31 @@ import com.dk.common.response.ResponseResultUtil;
|
|
|
import com.dk.common.response.ResponseResultVO;
|
|
|
import com.dk.mdm.infrastructure.convert.mst.CustomerConvert;
|
|
|
import com.dk.mdm.infrastructure.util.AuthUtils;
|
|
|
+import com.dk.mdm.mapper.common.CommonMapper;
|
|
|
import com.dk.mdm.model.pojo.mst.Customer;
|
|
|
import com.dk.mdm.mapper.mst.CustomerMapper;
|
|
|
import com.dk.common.service.BaseService;
|
|
|
import com.dk.common.mapper.BaseMapper;
|
|
|
import com.dk.mdm.model.query.mst.CustomerQuery;
|
|
|
import com.dk.mdm.model.response.mst.CustomerResponse;
|
|
|
+import com.dk.mdm.model.vo.mac.OtherPayableItemVO;
|
|
|
+import com.dk.mdm.model.vo.mac.OtherPayableVO;
|
|
|
+import com.dk.mdm.model.vo.mac.OtherReceivableItemVO;
|
|
|
+import com.dk.mdm.model.vo.mac.OtherReceivableVO;
|
|
|
import com.dk.mdm.model.vo.mst.CustomerVO;
|
|
|
import com.dk.mdm.service.common.CommonService;
|
|
|
+import com.dk.mdm.service.mac.OtherPayableService;
|
|
|
+import com.dk.mdm.service.mac.OtherReceivableService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -49,6 +59,11 @@ public class CustomerService extends BaseService<Customer> {
|
|
|
@Autowired
|
|
|
private OrgService orgService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CommonMapper commonMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OtherReceivableService otherReceivableService;
|
|
|
|
|
|
@Autowired
|
|
|
private AuthUtils authUtils;
|
|
|
@@ -112,6 +127,30 @@ public class CustomerService extends BaseService<Customer> {
|
|
|
//报备日期
|
|
|
customer.setReportTime(LocalDateTime.now());
|
|
|
ResponseResultVO<?> insert = super.insert(customer);
|
|
|
+
|
|
|
+ if (customerVO!= null && customerVO.getStartAmount().compareTo(BigDecimal.ZERO) > 0) { //说明有起始欠款 需要插入其他支出
|
|
|
+ //先组装明细
|
|
|
+ List<OtherReceivableItemVO> itemList = new ArrayList<>();
|
|
|
+ OtherReceivableItemVO otherReceivableItemVO = new OtherReceivableItemVO();
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
+ param.put("cpId", authUtils.getStaff().getCpId());
|
|
|
+ param.put("dictCode", "基础资料-收入");
|
|
|
+ param.put("dataValue", "期初");
|
|
|
+ Map<String, Object> data = commonMapper.selectDictionaryData(param);
|
|
|
+ if(data != null && data.size() > 0){
|
|
|
+ String dataId = String.valueOf(data.get("dataId"));
|
|
|
+ otherReceivableItemVO.setReceivableType(dataId);
|
|
|
+ otherReceivableItemVO.setAmtReceivable(customerVO.getStartAmount());
|
|
|
+ itemList.add(otherReceivableItemVO);
|
|
|
+ //调用 新建其他支出
|
|
|
+ OtherReceivableVO otherReceivableVO = new OtherReceivableVO().setBusinessType(0).setObjectId(customer.getCusId())
|
|
|
+ .setSumAmtReceivable(customerVO.getStartAmount()).setStaffId(customer.getStaffId())
|
|
|
+ .setOrgId(customer.getOrgId()).setAccDate(LocalDate.now()).setMakeStaff(customer.getReportStaff())
|
|
|
+ .setItemList(itemList).setSumAmtRec(BigDecimal.ZERO);
|
|
|
+ otherReceivableService.insert(otherReceivableVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (insert.getCode() == ResponseCodeEnum.SUCCESS.getCode()) {
|
|
|
return ResponseResultUtil.success(customer);
|
|
|
} else {
|