|
|
|
@ -37,7 +37,6 @@ import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.UUID; |
|
|
|
|
|
|
|
|
|
import static com.github.pagehelper.page.PageMethod.startPage; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @Author: kane |
|
|
|
@ -205,7 +204,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()); |
|
|
|
@ -311,4 +310,99 @@ public class RedInformationServiceImpl implements RedInformationService { |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|