|
|
@@ -23,6 +23,7 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
|
|
|
+import com.trade.purchase.order.enums.OrderTypeEnum;
|
|
|
import io.seata.spring.annotation.GlobalTransactional;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.Data;
|
|
|
@@ -59,6 +60,7 @@ import org.springblade.mocha.entity.BusinessOverpaymentItem;
|
|
|
import org.springblade.mocha.entity.Overpayment;
|
|
|
import org.springblade.mocha.feign.IBusinessOverpaymentClient;
|
|
|
import org.springblade.purchase.sales.entity.Order;
|
|
|
+import org.springblade.purchase.sales.entity.OrderEnum;
|
|
|
import org.springblade.purchase.sales.entity.OrderFees;
|
|
|
import org.springblade.purchase.sales.entity.OrderItems;
|
|
|
import org.springblade.purchase.sales.feign.IOrderDescClient;
|
|
|
@@ -503,7 +505,7 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, Settlem
|
|
|
}
|
|
|
}
|
|
|
//原业务表,计算应收未收款,应收未收款 = 销售金额 - 本次溢付款 - 已收款
|
|
|
- client.setBalanceAmount((client.getOrderAmount().subtract(client.getSettlmentAmount())).subtract(client.getCaseOverPayment()));
|
|
|
+ client.setBalanceAmount((client.getDebitAmount().subtract(client.getSettlmentAmount())).subtract(client.getCaseOverPayment()));
|
|
|
orderDescClient.updateOrder(client);
|
|
|
}
|
|
|
//修改费用明细
|
|
|
@@ -631,7 +633,7 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, Settlem
|
|
|
//明细账单操作
|
|
|
accMapper.updateById(acc);
|
|
|
//原业务表,计算应收未收款,应收未收款 = 销售金额 - 本次溢付款 - 已收款
|
|
|
- client.setBalanceAmount((client.getOrderAmount().subtract(client.getSettlmentAmount())).subtract(client.getCaseOverPayment()));
|
|
|
+ client.setBalanceAmount((client.getDebitAmount().subtract(client.getSettlmentAmount())).subtract(client.getCaseOverPayment()));
|
|
|
orderDescClient.updateOrder(client);
|
|
|
|
|
|
}
|
|
|
@@ -684,7 +686,7 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, Settlem
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public Settlement apply(List<Items> itemsList, String billType, String url, String pageStatus, String pageLabel, String checkType) throws Exception {
|
|
|
+ public Settlement apply(List<Items> itemsList, String billType, String url, String pageStatus, String pageLabel, String checkType, String tradeType) throws Exception {
|
|
|
BigDecimal total = itemsList.stream().filter(e -> e.getAmount() != null && "CNY".equals(e.getCurrency())).map(Items::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
BigDecimal foreignTotal = itemsList.stream().filter(e -> e.getAmount() != null && !"CNY".equals(e.getCurrency())).map(Items::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
Settlement settlement = new Settlement();
|
|
|
@@ -713,55 +715,92 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, Settlem
|
|
|
settlement.setDc("c");
|
|
|
settlement.setSettlementType(1);
|
|
|
baseMapper.insert(settlement);
|
|
|
-
|
|
|
- itemsList.forEach(e -> {
|
|
|
- // 修改原费用明细状态
|
|
|
- if (e.getSrcType() == 2) {
|
|
|
- OrderFees client = orderFeesClient.getById(e.getSrcFeesId());
|
|
|
- if (client == null) {
|
|
|
- throw new SecurityException("未查到原单据的费用明细,无法修改状态");
|
|
|
- }
|
|
|
- client.setIsCheck(1);
|
|
|
- client.setSubmitPay(1);
|
|
|
- R submit = orderFeesClient.submit(client);
|
|
|
- if (!submit.isSuccess()) {
|
|
|
- throw new SecurityException("财务-修改原单据的费用明细错误");
|
|
|
- }
|
|
|
- } else if (e.getSrcType() == 3) {
|
|
|
- R<DeliveryFees> fees = deliveryClient.getFeesById(e.getSrcFeesId());
|
|
|
- DeliveryFees feesData = fees.getData();
|
|
|
- if (feesData == null) {
|
|
|
- throw new SecurityException("未查到原单据的费用明细,无法修改状态");
|
|
|
- }
|
|
|
- feesData.setIsCheck(1);
|
|
|
- R submit = deliveryClient.submitFees(feesData);
|
|
|
- if (!submit.isSuccess()) {
|
|
|
- throw new SecurityException("财务-修改原单据的费用明细错误");
|
|
|
+ if ((StringUtils.isBlank(tradeType)) || (StringUtils.isNotBlank(tradeType)) && !tradeType.equals(OrderTypeEnum.DOMESTIC.getType())){
|
|
|
+ itemsList.forEach(e -> {
|
|
|
+ // 修改原费用明细状态
|
|
|
+ if (e.getSrcType() == 2) {
|
|
|
+ OrderFees client = orderFeesClient.getById(e.getSrcFeesId());
|
|
|
+ if (client == null) {
|
|
|
+ throw new SecurityException("未查到原单据的费用明细,无法修改状态");
|
|
|
+ }
|
|
|
+ client.setIsCheck(1);
|
|
|
+ client.setSubmitPay(1);
|
|
|
+ R submit = orderFeesClient.submit(client);
|
|
|
+ if (!submit.isSuccess()) {
|
|
|
+ throw new SecurityException("财务-修改原单据的费用明细错误");
|
|
|
+ }
|
|
|
+ } else if (e.getSrcType() == 3) {
|
|
|
+ R<DeliveryFees> fees = deliveryClient.getFeesById(e.getSrcFeesId());
|
|
|
+ DeliveryFees feesData = fees.getData();
|
|
|
+ if (feesData == null) {
|
|
|
+ throw new SecurityException("未查到原单据的费用明细,无法修改状态");
|
|
|
+ }
|
|
|
+ feesData.setIsCheck(1);
|
|
|
+ R submit = deliveryClient.submitFees(feesData);
|
|
|
+ if (!submit.isSuccess()) {
|
|
|
+ throw new SecurityException("财务-修改原单据的费用明细错误");
|
|
|
+ }
|
|
|
+ } else if (e.getSrcType() == 1) {
|
|
|
+ OrderItems client = orderItemsClient.getById(e.getSrcFeesId());
|
|
|
+ if (client == null) {
|
|
|
+ throw new SecurityException("未查到原单据的商品明细,无法修改状态");
|
|
|
+ }
|
|
|
+ client.setSubmitPay(1);
|
|
|
+ R submit = orderItemsClient.submit(client);
|
|
|
+ if (!submit.isSuccess()) {
|
|
|
+ throw new SecurityException("财务-修改原单据的商品明细错误");
|
|
|
+ }
|
|
|
}
|
|
|
- } else if (e.getSrcType() == 1) {
|
|
|
- OrderItems client = orderItemsClient.getById(e.getSrcFeesId());
|
|
|
- if (client == null) {
|
|
|
- throw new SecurityException("未查到原单据的商品明细,无法修改状态");
|
|
|
+
|
|
|
+ e.setId(null);
|
|
|
+ e.setPid(settlement.getId());
|
|
|
+ e.setCreateTime(new Date());
|
|
|
+ e.setTenantId(AuthUtil.getTenantId());
|
|
|
+ e.setCreateUser(AuthUtil.getUserId());
|
|
|
+ itemsMapper.insert(e);
|
|
|
+
|
|
|
+ R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(e.getCorpId());
|
|
|
+ if (corpMessage.isSuccess() && corpMessage.getData() != null) {
|
|
|
+ e.setCorpName(corpMessage.getData().getCname());
|
|
|
}
|
|
|
- client.setSubmitPay(1);
|
|
|
- R submit = orderItemsClient.submit(client);
|
|
|
- if (!submit.isSuccess()) {
|
|
|
- throw new SecurityException("财务-修改原单据的商品明细错误");
|
|
|
+ });
|
|
|
+ }else {
|
|
|
+ for (Items e : itemsList) {// 修改原费用明细状态
|
|
|
+ if (e.getSrcType() == 2) {
|
|
|
+ Order order = orderDescClient.getById(e.getSrcParentId());
|
|
|
+ if (order == null) {
|
|
|
+ throw new SecurityException("未查到原单据信息,请查看单据是否存在");
|
|
|
+ }
|
|
|
+ R submit = orderFeesClient.submitPay(e.getSrcParentId());
|
|
|
+ if (!submit.isSuccess()) {
|
|
|
+ throw new SecurityException("财务-修改原单据的费用明细错误");
|
|
|
+ }
|
|
|
+ } else if (e.getSrcType() == 3) {
|
|
|
+ R submit = deliveryClient.submitPay(e.getSrcParentId());
|
|
|
+ if (!submit.isSuccess()) {
|
|
|
+ throw new SecurityException("财务-修改原单据的费用明细错误");
|
|
|
+ }
|
|
|
+ } else if (e.getSrcType() == 1) {
|
|
|
+ R submit = orderItemsClient.submitPay(e.getSrcParentId());
|
|
|
+ if (!submit.isSuccess()) {
|
|
|
+ throw new SecurityException("财务-修改原单据的商品明细错误");
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- e.setId(null);
|
|
|
- e.setPid(settlement.getId());
|
|
|
- e.setCreateTime(new Date());
|
|
|
- e.setTenantId(AuthUtil.getTenantId());
|
|
|
- e.setCreateUser(AuthUtil.getUserId());
|
|
|
- itemsMapper.insert(e);
|
|
|
+ e.setId(null);
|
|
|
+ e.setPid(settlement.getId());
|
|
|
+ e.setCreateTime(new Date());
|
|
|
+ e.setTenantId(AuthUtil.getTenantId());
|
|
|
+ e.setCreateUser(AuthUtil.getUserId());
|
|
|
+ itemsMapper.insert(e);
|
|
|
|
|
|
- R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(e.getCorpId());
|
|
|
- if (corpMessage.isSuccess() && corpMessage.getData() != null) {
|
|
|
- e.setCorpName(corpMessage.getData().getCname());
|
|
|
+ R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(e.getCorpId());
|
|
|
+ if (corpMessage.isSuccess() && corpMessage.getData() != null) {
|
|
|
+ e.setCorpName(corpMessage.getData().getCname());
|
|
|
+ }
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
+
|
|
|
List<CorpsBank> corpsBanks = corpsDescClient.listBankByCorpId(settlement.getCorpId());
|
|
|
settlement.setBankList(corpsBanks);
|
|
|
// 付费申请-直接开启审批
|
|
|
@@ -859,7 +898,7 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, Settlem
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public void paymentApply(List<Items> itemsList, String billType, String belongCompany) {
|
|
|
+ public void paymentApply(List<Items> itemsList, String billType, String belongCompany,String tradeType) {
|
|
|
itemsList.forEach(e -> {
|
|
|
//产生凭证: 销售订单-生成账单
|
|
|
/* if(e.getSrcType()==1 && e.getItemType().equals("销售"))
|
|
|
@@ -875,26 +914,28 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, Settlem
|
|
|
throw new SecurityException(exception.getMessage());
|
|
|
}
|
|
|
}*/
|
|
|
- if (e.getSrcType() == 2) {
|
|
|
- OrderFees orderFees = orderFeesClient.getById(e.getSrcFeesId());
|
|
|
- if (orderFees == null) {
|
|
|
- throw new SecurityException("未查到原单据的费用明细,无法修改状态");
|
|
|
- }
|
|
|
- orderFees.setSubmitPay(1);
|
|
|
- orderFees.setIsCheck(1);
|
|
|
- R submit = orderFeesClient.submit(orderFees);
|
|
|
- if (!submit.isSuccess()) {
|
|
|
- throw new SecurityException("财务-修改原单据的费用明细错误");
|
|
|
- }
|
|
|
- } else {
|
|
|
- OrderItems client = orderItemsClient.getById(e.getSrcFeesId());
|
|
|
- if (client == null) {
|
|
|
- throw new SecurityException("未查到原单据的商品明细,无法修改状态");
|
|
|
- }
|
|
|
- client.setSubmitPay(1);
|
|
|
- R submit = orderItemsClient.submit(client);
|
|
|
- if (!submit.isSuccess()) {
|
|
|
- throw new SecurityException("财务-修改原单据的商品明细错误");
|
|
|
+ if ((StringUtils.isBlank(tradeType)) || (StringUtils.isNotBlank(tradeType)) && !tradeType.equals(OrderTypeEnum.DOMESTIC.getType())){
|
|
|
+ if (e.getSrcType() == 2) {
|
|
|
+ OrderFees orderFees = orderFeesClient.getById(e.getSrcFeesId());
|
|
|
+ if (orderFees == null) {
|
|
|
+ throw new SecurityException("未查到原单据的费用明细,无法修改状态");
|
|
|
+ }
|
|
|
+ orderFees.setSubmitPay(1);
|
|
|
+ orderFees.setIsCheck(1);
|
|
|
+ R submit = orderFeesClient.submit(orderFees);
|
|
|
+ if (!submit.isSuccess()) {
|
|
|
+ throw new SecurityException("财务-修改原单据的费用明细错误");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ OrderItems client = orderItemsClient.getById(e.getSrcFeesId());
|
|
|
+ if (client == null) {
|
|
|
+ throw new SecurityException("未查到原单据的商品明细,无法修改状态");
|
|
|
+ }
|
|
|
+ client.setSubmitPay(1);
|
|
|
+ R submit = orderItemsClient.submit(client);
|
|
|
+ if (!submit.isSuccess()) {
|
|
|
+ throw new SecurityException("财务-修改原单据的商品明细错误");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|