|
@@ -6,12 +6,26 @@ package com.trade.service.trade.salescontract.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.trade.service.enterprise.customer.domain.Enterprise;
|
|
|
+import com.trade.service.enterprise.customer.service.EnterpriseBaseService;
|
|
|
import com.trade.service.trade.salescontract.domain.SalesCommodity;
|
|
|
+import com.trade.service.trade.salescontract.dto.SalesCommodityDto;
|
|
|
import com.trade.service.trade.salescontract.mapper.SalesCommodityMapper;
|
|
|
import com.trade.service.trade.salescontract.service.SalesCommodityService;
|
|
|
import com.trade.service.trade.salescontract.vo.SalesCommoditySearch;
|
|
|
+import com.trade.common.exception.ServiceException;
|
|
|
+import com.trade.common.utils.StringUtils;
|
|
|
+import com.trade.service.DictConstants;
|
|
|
+import com.trade.service.system.service.SuperviseCertificateCodeService;
|
|
|
+import com.trade.service.thirdparty.xiaotu.dto.BusinessCommonRequest;
|
|
|
+import com.trade.service.thirdparty.xiaotu.dto.CommodityCustomsTariffRespose;
|
|
|
+import com.trade.service.thirdparty.xiaotu.dto.CommodityRequest;
|
|
|
+import com.trade.service.thirdparty.xiaotu.dto.CommodityResponse;
|
|
|
+import com.trade.service.thirdparty.xiaotu.service.XiaotuRequestService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -22,6 +36,13 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class SalesCommodityServiceImpl extends ServiceImpl<SalesCommodityMapper, SalesCommodity> implements SalesCommodityService {
|
|
|
|
|
|
+ @Resource
|
|
|
+ private XiaotuRequestService xiaotuRequestService;
|
|
|
+ @Resource
|
|
|
+ private EnterpriseBaseService enterpriseBaseService;
|
|
|
+ @Resource
|
|
|
+ private SuperviseCertificateCodeService superviseCertificateCodeService;
|
|
|
+
|
|
|
@Override
|
|
|
public List<SalesCommodity> queryBySalesContractId(Long salesContractId) {
|
|
|
return this.baseMapper.selectBySalesContractId(salesContractId);
|
|
@@ -36,4 +57,55 @@ public class SalesCommodityServiceImpl extends ServiceImpl<SalesCommodityMapper,
|
|
|
}
|
|
|
return this.list(queryWrapper);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<SalesCommodityDto> getXiaoTuCommodityList(String name, String xtUid, Long customerId,
|
|
|
+ boolean isImport) {
|
|
|
+ Enterprise enterprise = enterpriseBaseService.getEnterpriseByCustomerId(customerId);
|
|
|
+ CommodityRequest commodityRequest = new CommodityRequest();
|
|
|
+ if (!isImport) {
|
|
|
+ commodityRequest.setCksptssplxDm(CommodityRequest.OTHER);
|
|
|
+ }
|
|
|
+ commodityRequest.setCkspdm(name);
|
|
|
+ BusinessCommonRequest businessCommonRequest = new BusinessCommonRequest();
|
|
|
+ businessCommonRequest.setXtUid(xtUid);
|
|
|
+ businessCommonRequest.setCustomerId(customerId);
|
|
|
+ businessCommonRequest.setXtEid(enterprise.getXtEid());
|
|
|
+ CommodityResponse commodityResponse = xiaotuRequestService.taxRefundRateInquiry(commodityRequest,
|
|
|
+ businessCommonRequest);
|
|
|
+ if (commodityResponse == null || StringUtils.isEmpty(commodityResponse.getSpid())) {
|
|
|
+ throw new ServiceException("未检索到商品信息");
|
|
|
+ }
|
|
|
+ CommodityCustomsTariffRespose commodityCustomsTariffRespose = xiaotuRequestService
|
|
|
+ .commodityCustomsTariffInquiry(commodityResponse.getSpid(), businessCommonRequest);
|
|
|
+ List<SalesCommodityDto> salesCommodityDtos = new ArrayList<>();
|
|
|
+ for (CommodityCustomsTariffRespose.Spmhgszinfo spmhgszinfo : commodityCustomsTariffRespose.getSPMHGSZINFO()) {
|
|
|
+ SalesCommodityDto salesCommodityDto = new SalesCommodityDto();
|
|
|
+ salesCommodityDto.setHsCode(spmhgszinfo.getHSCODE());
|
|
|
+ salesCommodityDto.setName(spmhgszinfo.getHSNAME());
|
|
|
+ salesCommodityDto.setMeasurementUnit(commodityCustomsTariffRespose.getHGJLDWMC());
|
|
|
+ salesCommodityDto.setExportTaxRebateRate(commodityCustomsTariffRespose.getTSL());
|
|
|
+ salesCommodityDto.setAddedTaxRate(commodityCustomsTariffRespose.getZSSLJH());
|
|
|
+ if (isImport) {
|
|
|
+ if (commodityRequest.PROHIBITION_EXPORT.equals(commodityCustomsTariffRespose.getCKSPTSSPLX_DM())) {
|
|
|
+ salesCommodityDto.setErrors("该商品禁止出口");
|
|
|
+ }
|
|
|
+ if (commodityRequest.TAX_FREE.equals(commodityCustomsTariffRespose.getCKSPTSSPLX_DM())) {
|
|
|
+ salesCommodityDto.setErrors("该商品为免税商品");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (DictConstants.EXPORT_TYPE_PROXY.equals(enterprise.getExportType())) {
|
|
|
+ Long count = superviseCertificateCodeService.countByCode(spmhgszinfo.getHSHGJGTJ());
|
|
|
+ if (count != null && count > 0) {
|
|
|
+ salesCommodityDto.setErrors("该商品为监管商品");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isImport && StringUtils.isEmpty(salesCommodityDto.getErrors())) {
|
|
|
+ salesCommodityDtos.add(salesCommodityDto);
|
|
|
+ } else {
|
|
|
+ salesCommodityDtos.add(salesCommodityDto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return salesCommodityDtos;
|
|
|
+ }
|
|
|
}
|