浏览代码

增加fees结算

ioioio 3 年之前
父节点
当前提交
6fedb364ea

+ 4 - 0
blade-service-api/blade-deliver-goods-api/src/main/java/org/springblade/deliver/goods/entity/DeliveryFees.java

@@ -180,5 +180,9 @@ public class DeliveryFees implements Serializable {
 	@ApiModelProperty(value = "1.应收 2.应付")
 		private int feesType;
 
+	private String srcOrderNo;
+	private BigDecimal refundSettlmentAmount;
+	private Integer isCheck;
+
 
 }

+ 10 - 0
blade-service-api/blade-deliver-goods-api/src/main/java/org/springblade/deliver/goods/feign/IDeliveryClient.java

@@ -4,10 +4,12 @@ import io.swagger.annotations.ApiParam;
 import org.springblade.common.constant.LauncherConstant;
 import org.springblade.core.tool.api.R;
 import org.springblade.deliver.goods.entity.Delivery;
+import org.springblade.deliver.goods.entity.DeliveryFees;
 import org.springblade.deliver.goods.entity.DeliveryItems;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 
 import java.util.List;
@@ -19,6 +21,8 @@ public interface IDeliveryClient {
 	String API_PREFIX = "/client";
 	String CREATE_DELIVER_GOODS = API_PREFIX + "create-deliver-goods";
 	String LIST_BY_ITEM_ID = API_PREFIX + "listByItemId";
+	String GET_FEES_BY_ID = API_PREFIX + "getFeesById";
+	String SUBMIT_FEES = API_PREFIX + "submitFees";
 
 	/**
 	 * 生成发货单
@@ -31,4 +35,10 @@ public interface IDeliveryClient {
 	@GetMapping(LIST_BY_ITEM_ID)
 	R<List<DeliveryItems>> listByItemId(@RequestParam Long itemId);
 
+	@GetMapping(GET_FEES_BY_ID)
+	R<DeliveryFees> getFeesById(@RequestParam Long feeId);
+
+	@PostMapping(SUBMIT_FEES)
+	R submitFees (@RequestBody DeliveryFees deliveryFees);
+
 }

+ 19 - 4
blade-service/blade-deliver-goods/src/main/java/org/springblade/deliver/goods/feign/DeliveryClient.java

@@ -6,13 +6,12 @@ import lombok.AllArgsConstructor;
 import org.springblade.core.tenant.annotation.NonDS;
 import org.springblade.core.tool.api.R;
 import org.springblade.deliver.goods.entity.Delivery;
+import org.springblade.deliver.goods.entity.DeliveryFees;
 import org.springblade.deliver.goods.entity.DeliveryItems;
+import org.springblade.deliver.goods.service.IDeliveryFeesService;
 import org.springblade.deliver.goods.service.IDeliveryItemsService;
 import org.springblade.deliver.goods.service.IDeliveryService;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import springfox.documentation.annotations.ApiIgnore;
 
 import java.util.List;
@@ -24,6 +23,7 @@ import java.util.List;
 public class DeliveryClient implements IDeliveryClient{
 	private IDeliveryService deliveryService;//发货 收货信息
 	private IDeliveryItemsService deliveryItemsService;
+	private IDeliveryFeesService feesService;
 
 	/**
 	 * 生成发货信息
@@ -44,4 +44,19 @@ public class DeliveryClient implements IDeliveryClient{
 		List<DeliveryItems> list = deliveryItemsService.list(orderItemsLambdaQueryWrapper);
 		return R.data(list);
 	}
+
+	@Override
+	@GetMapping(GET_FEES_BY_ID)
+	public R<DeliveryFees> getFeesById(Long feeId) {
+
+		return R.data(feesService.getById(feeId));
+	}
+
+	@Override
+	@PostMapping(SUBMIT_FEES)
+	public R submitFees(@RequestBody DeliveryFees deliveryFees)
+	{
+		feesService.updateById(deliveryFees);
+		return R.success("操作成功");
+	}
 }

+ 7 - 0
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/feign/OrderItemsClient.java

@@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.RestController;
 import springfox.documentation.annotations.ApiIgnore;
 
 import java.math.BigDecimal;
+import java.util.List;
+
 @Slf4j
 @NonDS
 @ApiIgnore()
@@ -89,4 +91,9 @@ public class OrderItemsClient implements IOrderItemsClient{
 		}
 		return R.data(orderItemsService.updateById(items));
 	}
+
+	@Override
+	public R<List<OrderItems>> listByItemId(Long itemId) {
+		return null;
+	}
 }

+ 65 - 1
blade-service/trade-finance/src/main/java/org/springblade/finance/service/impl/SettlementServiceImpl.java

@@ -29,7 +29,9 @@ import org.springblade.client.entity.CorpsDesc;
 import org.springblade.core.secure.utils.SecureUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.deliver.goods.entity.Delivery;
+import org.springblade.deliver.goods.entity.DeliveryFees;
 import org.springblade.deliver.goods.entity.DeliveryItems;
+import org.springblade.deliver.goods.feign.IDeliveryClient;
 import org.springblade.finance.dto.SettlementDTO;
 import org.springblade.finance.enums.SettlementEnum;
 import org.springblade.finance.vojo.*;
@@ -95,6 +97,8 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, Settlem
 
 	private final IBusinessOverpaymentClient businessOverpaymentClient; //溢付款对外访问接口
 
+	private IDeliveryClient deliveryClient;
+
 
 	@Override
 	public IPage<SettlementVO> selectSettlementPage(IPage<SettlementVO> page, SettlementVO settlement) {
@@ -414,6 +418,29 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, Settlem
 			orderFees.setSettlmentAmount(decimal);
 			orderFeesClient.submit(orderFees);
 		}
+		else if(type ==3)
+		{
+			Long srcFeesId = acc.getSrcFeesId();
+			if (srcFeesId == null) {
+				throw new SecurityException("撤销账单失败,未获取到原业务信息");
+			}
+
+			R<DeliveryFees> feesR = deliveryClient.getFeesById(srcFeesId);
+			if (feesR.getData() == null) {
+				throw new SecurityException("修改原单据失败");
+			}
+			//回退原业务表数据
+			DeliveryFees deliveryFees = feesR.getData();
+			if (deliveryFees.getSettlmentAmount() == null) {
+				throw new SecurityException("撤销账单失败,原业务表已收金额为空");
+			}
+			BigDecimal decimal = deliveryFees.getSettlmentAmount().subtract(items.getThisAmount());
+			if (decimal.compareTo(BigDecimal.ZERO) == -1) {
+				throw new SecurityException("撤销账单失败,剩余已收金额不够本次扣款");
+			}
+			deliveryFees.setSettlmentAmount(decimal);
+			deliveryClient.submitFees(deliveryFees);
+		}
 
 	}
 
@@ -535,10 +562,31 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, Settlem
 			orderFees.setSettlmentAmount(orderFees.getSettlmentAmount() != null ? orderFees.getSettlmentAmount().add(items.getThisAmount()) : new BigDecimal("0").add(items.getThisAmount()));
 			accMapper.updateById(acc);
 			orderFeesClient.submit(orderFees);
-		} else {
+		}
+		else if(type==3)
+		{
+			Long srcFeesId = acc.getSrcFeesId();
+			if (srcFeesId == null)
+			{
+				throw new SecurityException("操作失败,未获取到原业务信息");
+			}
+			R<DeliveryFees> feesById = deliveryClient.getFeesById(srcFeesId);
+			if(!feesById.isSuccess()&&feesById.getData()==null)
+			{
+				throw new SecurityException("修改原单据失败");
+			}
+			DeliveryFees deliveryFees = feesById.getData();
+			acc.setSettlementAmount(acc.getSettlementAmount() != null ? acc.getSettlementAmount().add(items.getThisAmount()) : new BigDecimal("0").add(items.getThisAmount()));
+			deliveryFees.setSettlmentAmount(deliveryFees.getSettlmentAmount() != null ? deliveryFees.getSettlmentAmount().add(items.getThisAmount()) : new BigDecimal("0").add(items.getThisAmount()));
+			accMapper.updateById(acc);
+			deliveryClient.submitFees(deliveryFees);
+		}
+
+		else {
 			throw new SecurityException("操作失败,财务类型为空无法结算");
 		}
 
+
 		//验证结算总金额是否超限
 
 		/*BigDecimal orderAmount = client.getSettlmentAmount();
@@ -592,6 +640,22 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, Settlem
 					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("财务-修改原单据的费用明细错误");
+					}
+
+
+			}
 			e.setId(null);
 			e.setPid(settlement.getId());
 			e.setCreateTime(new Date());