|
|
|
@ -13,8 +13,11 @@ import com.jianshui.invoice.domain.Invoice; |
|
|
|
|
import com.jianshui.invoice.domain.InvoiceDetail; |
|
|
|
|
import com.jianshui.invoice.domain.Redinfo; |
|
|
|
|
import com.jianshui.invoice.domain.Redinfodetail; |
|
|
|
|
import com.jianshui.invoice.domain.dto.HXResponse; |
|
|
|
|
import com.jianshui.invoice.factory.IInvoiceServiceFactory; |
|
|
|
|
import com.jianshui.invoice.mapper.InvoiceMapper; |
|
|
|
|
import com.jianshui.invoice.mapper.RedinfoMapper; |
|
|
|
|
import com.jianshui.invoice.service.IInvoiceApiService; |
|
|
|
|
import com.jianshui.platform.constant.ExceptionInformationConstants; |
|
|
|
|
import com.jianshui.platform.constant.RedWordConstants; |
|
|
|
|
import com.jianshui.invoice.domain.dto.FindRedWordDTO; |
|
|
|
@ -37,7 +40,6 @@ import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.UUID; |
|
|
|
|
|
|
|
|
|
import static com.github.pagehelper.page.PageMethod.startPage; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @Author: kane |
|
|
|
@ -63,6 +65,9 @@ public class RedInformationServiceImpl implements RedInformationService { |
|
|
|
|
@Autowired |
|
|
|
|
private IServiceManageService serviceManageService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IInvoiceServiceFactory invoiceServiceFactory; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 功能描述: 红字信息选择 |
|
|
|
@ -205,7 +210,7 @@ public class RedInformationServiceImpl implements RedInformationService { |
|
|
|
|
redinfo.setOutTradeOrderno(outOrderNO); |
|
|
|
|
redinfo.setFpqqlsh(uuidhm); |
|
|
|
|
redinfo.setCompanyId(sysUser.getCompanyId()); |
|
|
|
|
redinfo.setRedInfoStatus("0"); |
|
|
|
|
redinfo.setRedInfoStatus("6"); |
|
|
|
|
String serviceKey = null; |
|
|
|
|
try { |
|
|
|
|
serviceKey = serviceManageService.getCompanyServiceSupplier("invoice", sysUser.getCompanyId()); |
|
|
|
@ -278,4 +283,163 @@ public class RedInformationServiceImpl implements RedInformationService { |
|
|
|
|
return AjaxResult.success(pageFindRedWordVO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 功能描述: 红字信息明细查询 |
|
|
|
|
* @param id |
|
|
|
|
* @return : com.jianshui.common.core.domain.AjaxResult |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public AjaxResult findRedWordDetail(Long id) { |
|
|
|
|
if (id == null){ |
|
|
|
|
return AjaxResult.error(ExceptionInformationConstants.REDWORDINFOISEMPT); |
|
|
|
|
} |
|
|
|
|
Redinfo redinfo = redinfoMapper.selectRedinfoById(id); |
|
|
|
|
if (redinfo == null){ |
|
|
|
|
return AjaxResult.error(ExceptionInformationConstants.NOTFINREDWORDINFO); |
|
|
|
|
} |
|
|
|
|
//封装红字信息返回
|
|
|
|
|
RedWordDTO redWordDTO = new RedWordDTO(); |
|
|
|
|
BeanUtils.copyProperties(redinfo,redWordDTO); |
|
|
|
|
redWordDTO.setStatus(RedWordConstants.NOTTAXINVOICE); |
|
|
|
|
redWordDTO.setTotalMoney(redinfo.getTaxfreeamt()); |
|
|
|
|
//封装红字信息详情
|
|
|
|
|
List<Redinfodetail> redinfodetailList = redinfo.getRedinfodetailList(); |
|
|
|
|
List<RedinfodetailDTO> redinfodetailDTOS = new ArrayList<>(); |
|
|
|
|
for (Redinfodetail redinfodetail : redinfodetailList) { |
|
|
|
|
RedinfodetailDTO redinfodetailDTO = new RedinfodetailDTO(); |
|
|
|
|
BeanUtils.copyProperties(redinfodetail,redinfodetailDTO); |
|
|
|
|
redinfodetailDTO.setCost(redinfodetail.getPrice()); |
|
|
|
|
redinfodetailDTO.setMoney(redinfodetail.getTaxfreeamt()); |
|
|
|
|
redinfodetailDTOS.add(redinfodetailDTO); |
|
|
|
|
} |
|
|
|
|
redWordDTO.setRedinfodetailList(redinfodetailDTOS); |
|
|
|
|
return AjaxResult.success(redWordDTO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 功能描述: 批量删除红字信息 |
|
|
|
|
* @param ids |
|
|
|
|
* @return : com.jianshui.common.core.domain.AjaxResult |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public AjaxResult deleteRedWord(Long[] ids) { |
|
|
|
|
if (ids == null || ids.length == 0){ |
|
|
|
|
return AjaxResult.error(ExceptionInformationConstants.REDWORDINFOISEMPT); |
|
|
|
|
} |
|
|
|
|
for (Long id : ids) { |
|
|
|
|
Redinfo redinfo = redinfoMapper.selectRedinfoById(id); |
|
|
|
|
String redInfoStatus = redinfo.getRedInfoStatus(); |
|
|
|
|
if (!"6".equals(redInfoStatus)){ |
|
|
|
|
return AjaxResult.error(ExceptionInformationConstants.NOTDELETEREDWORD); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//批量删除
|
|
|
|
|
redinfoMapper.deleteRedinfoByIds(ids); |
|
|
|
|
redinfoMapper.deleteRedinfodetailByRedinfoIds(ids); |
|
|
|
|
return AjaxResult.success(RedWordConstants.DELETESUCCESS); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 功能描述: 红字信息修改 |
|
|
|
|
* @param dto |
|
|
|
|
* @return : com.jianshui.common.core.domain.AjaxResult |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public AjaxResult updateRedWord(RedWordDTO dto) { |
|
|
|
|
if (dto.getId() == null){ |
|
|
|
|
return AjaxResult.error(ExceptionInformationConstants.REDWORDINFOISEMPT); |
|
|
|
|
} |
|
|
|
|
Redinfo redinfo = redinfoMapper.selectRedinfoById(dto.getId()); |
|
|
|
|
if (redinfo == null){ |
|
|
|
|
return AjaxResult.error(ExceptionInformationConstants.NOTFINREDWORDINFO); |
|
|
|
|
} |
|
|
|
|
if ("6".equals(redinfo.getRedInfoStatus()) || "2".equals(redinfo.getRedInfoStatus())){ |
|
|
|
|
BeanUtils.copyProperties(dto,redinfo); |
|
|
|
|
if (RedWordConstants.TAXINVOICE.equals(dto.getStatus())){ |
|
|
|
|
// 含税总计金额
|
|
|
|
|
redinfo.setTaxamt(dto.getTotalMoney()); |
|
|
|
|
// 总计税额
|
|
|
|
|
redinfo.setTax(dto.getTotalTax()); |
|
|
|
|
// 不含税总计金额
|
|
|
|
|
redinfo.setTaxfreeamt(dto.getTotalMoney().subtract(dto.getTotalTax())); |
|
|
|
|
} |
|
|
|
|
if (RedWordConstants.NOTTAXINVOICE.equals(dto.getStatus())){ |
|
|
|
|
// 不含税总计金额
|
|
|
|
|
redinfo.setTaxfreeamt(dto.getTotalMoney()); |
|
|
|
|
// 含税总计金额
|
|
|
|
|
redinfo.setTaxamt(dto.getTotalMoney().add(dto.getTotalTax())); |
|
|
|
|
// 总计税额
|
|
|
|
|
redinfo.setTax(dto.getTotalTax()); |
|
|
|
|
} |
|
|
|
|
redinfoMapper.updateRedinfo(redinfo); |
|
|
|
|
// 红字信息详情
|
|
|
|
|
List<RedinfodetailDTO> redinfodetailList = dto.getRedinfodetailList(); |
|
|
|
|
List<Redinfodetail> redinfodetails = new ArrayList<>(); |
|
|
|
|
int count = 1; |
|
|
|
|
for (RedinfodetailDTO redinfodetailDTO : redinfodetailList) { |
|
|
|
|
//删除详情表
|
|
|
|
|
redinfoMapper.deleteRedinfodetailByRedinfoId(dto.getId()); |
|
|
|
|
Redinfodetail redinfodetail = new Redinfodetail(); |
|
|
|
|
BeanUtils.copyProperties(redinfodetailDTO,redinfodetail); |
|
|
|
|
redinfodetail.setRedinfoId(redinfo.getId()); |
|
|
|
|
redinfodetail.setIndex(count); |
|
|
|
|
redinfodetail.setTaxrate(redinfodetailDTO.getTaxrate().divide(new BigDecimal("100"),4,BigDecimal.ROUND_HALF_UP)); |
|
|
|
|
if (RedWordConstants.TAXINVOICE.equals(dto.getStatus())){ |
|
|
|
|
//单价税额
|
|
|
|
|
BigDecimal taxCost = redinfodetailDTO.getTax().divide(redinfodetailDTO.getNum(),2,BigDecimal.ROUND_HALF_UP); |
|
|
|
|
//不含税单价
|
|
|
|
|
redinfodetail.setPrice(redinfodetailDTO.getCost().subtract(taxCost)); |
|
|
|
|
//含税金额
|
|
|
|
|
redinfodetail.setTaxamt(redinfodetailDTO.getMoney()); |
|
|
|
|
//不含税金额
|
|
|
|
|
redinfodetail.setTaxfreeamt(redinfodetailDTO.getMoney().subtract(redinfodetailDTO.getTax())); |
|
|
|
|
}else if (RedWordConstants.NOTTAXINVOICE.equals(dto.getStatus())){ |
|
|
|
|
//不含税单价
|
|
|
|
|
redinfodetail.setPrice(redinfodetailDTO.getCost()); |
|
|
|
|
//不含税金额
|
|
|
|
|
redinfodetail.setTaxfreeamt(redinfodetailDTO.getMoney()); |
|
|
|
|
//含税金额
|
|
|
|
|
redinfodetail.setTaxamt(redinfodetailDTO.getMoney().add(redinfodetailDTO.getTax())); |
|
|
|
|
} |
|
|
|
|
redinfodetails.add(redinfodetail); |
|
|
|
|
count++; |
|
|
|
|
} |
|
|
|
|
redinfoMapper.batchRedinfodetail(redinfodetails); |
|
|
|
|
return AjaxResult.success(RedWordConstants.SUBMITSUCCESS); |
|
|
|
|
}else { |
|
|
|
|
return AjaxResult.error(ExceptionInformationConstants.NOTUPDATEREDWORD); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 功能描述: 红字信息表上传 |
|
|
|
|
* @param id |
|
|
|
|
* @return : com.jianshui.common.core.domain.AjaxResult |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public HXResponse uploadRedWord(Long id) { |
|
|
|
|
// TODO 暂未开发完成
|
|
|
|
|
if (id == null){ |
|
|
|
|
return new HXResponse(ExceptionInformationConstants.REDWORDINFOISEMPT); |
|
|
|
|
} |
|
|
|
|
Redinfo redinfo = redinfoMapper.selectRedinfoById(id); |
|
|
|
|
if (redinfo == null){ |
|
|
|
|
return new HXResponse(ExceptionInformationConstants.NOTFINREDWORDINFO); |
|
|
|
|
} |
|
|
|
|
Long userId = SecurityUtils.getUserId(); |
|
|
|
|
SysUser sysUser = sysUserMapper.selectUserById(userId); |
|
|
|
|
Companyservice companyservice = companyserviceMapper.selectCompanyserviceByCompanyid(sysUser.getCompanyId()); |
|
|
|
|
String serviceKey = null; |
|
|
|
|
HXResponse result; |
|
|
|
|
try { |
|
|
|
|
serviceKey = serviceManageService.getCompanyServiceSupplier("invoice", sysUser.getCompanyId()); |
|
|
|
|
IInvoiceApiService invoiceService = invoiceServiceFactory.getService(serviceKey); |
|
|
|
|
result = invoiceService.uploadRedInfo(redinfo, companyservice); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("简税产品端,红字信息上传失败,企业税号={},servicekey={}",companyservice.toString(),serviceKey); |
|
|
|
|
throw new JianshuiServiceException("红字信息上传异常!"); |
|
|
|
|
} |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|