@ -91,91 +91,6 @@ public class CollectionController {
return ActionResult . success ( result ) ;
}
/* */ / * *
* 提 交
*
* @param ids
* @return
* //*
@PostMapping ( "/commit/{ids}" )
@Transactional
public ActionResult commit ( @PathVariable ( "ids" ) String ids ) {
String [ ] idList = ids . split ( "," ) ;
for ( String id : idList ) {
CollectionEntity collectionEntity = collectionService . getInfo ( id ) ;
if ( collectionEntity . getStatus ( ) . equals ( "1" ) ) {
return ActionResult . fail ( "已提交" ) ;
}
if ( collectionEntity . getStatus ( ) . equals ( "2" ) ) {
return ActionResult . fail ( "已认款" ) ;
}
if ( collectionEntity . getStatus ( ) . equals ( "0" ) ) {
QueryWrapper < Collection_item0Entity > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . lambda ( ) . eq ( Collection_item0Entity : : getCollectionId , id ) ;
List < Collection_item0Entity > collection_item0EntityList = collection_item0Service . list ( queryWrapper ) ; //查询收款单子表信息
for ( Collection_item0Entity collection_item0Entity : collection_item0EntityList ) {
BigDecimal sum = new BigDecimal ( 0 ) ;
SaleorderitemEntity saleordercetEntity = saleorderitemService . getById ( collection_item0Entity . getSalesorderId ( ) ) ; //查询销售订单信息
if ( saleordercetEntity . getAmountCollected ( ) = = null ) {
saleordercetEntity . setAmountCollected ( new BigDecimal ( 0 ) ) ;
}
// if (saleordercetEntity.getAmountCollected().equals(saleordercetEntity.getPrice())) {
// return ActionResult.fail("已回款金额等于金额");
// }
if ( collectionEntity . getAmountCollected ( ) = = null | | collectionEntity . getAmountCollected ( ) . compareTo ( BigDecimal . ZERO ) < 1 ) {
return ActionResult . fail ( "请先输入回款金额" ) ;
} else {
sum = saleordercetEntity . getAmountCollected ( ) . add ( collection_item0Entity . getAmount ( ) ) ;
if ( sum . compareTo ( saleordercetEntity . getPrice ( ) ) > 0 ) {
return ActionResult . fail ( "总回款金额大于金额" ) ;
}
}
QueryWrapper < Salesorder_item0Entity > queryWrapper1 = new QueryWrapper < > ( ) ;
queryWrapper1 . lambda ( ) . eq ( Salesorder_item0Entity : : getSalesOrderId , saleordercetEntity . getId ( ) ) ;
List < Salesorder_item0Entity > list = salesorder_item0Service . list ( queryWrapper1 ) ;
List < PoundlistEntity > poundlist = new ArrayList < > ( ) ;
for ( Salesorder_item0Entity saleItem : list ) {
PoundlistEntity poundlistEntity = collectionService . queryPoundInfo ( saleItem . getPoundlistId ( ) ) ;
if ( ObjectUtils . isNotEmpty ( poundlistEntity ) ) {
poundlist . add ( poundlistEntity ) ;
}
}
if ( poundlist . size ( ) > 0 ) {
poundlist = poundlist . stream ( ) . sorted ( Comparator . comparing ( PoundlistEntity : : getAdvance ) . reversed ( )
. thenComparing ( Comparator . comparing ( PoundlistEntity : : getPoundDate ) ) ) . collect ( Collectors . toList ( ) ) ;
} else {
return ActionResult . fail ( "磅单为空" ) ;
}
BigDecimal amount = new BigDecimal ( 0 ) ;
List < PoundlistEntity > poundlist1 = new ArrayList < > ( ) ;
for ( PoundlistEntity pound : poundlist ) {
if ( pound . getSalesPrice ( ) ! = null & & pound . getSettlement ( ) ! = null ) {
amount = amount . add ( pound . getSalesPrice ( ) . multiply ( pound . getSettlement ( ) ) ) ;
if ( amount . compareTo ( sum ) < 1 ) {
poundlist1 . add ( pound ) ;
} else {
break ;
}
}
}
for ( PoundlistEntity poundlistEntity : poundlist1 ) {
poundlistEntity . setIsCollection ( "1" ) ;
if ( poundlistEntity . getPaymentDate ( ) = = null ) {
poundlistEntity . setPaymentDate ( new Date ( ) ) ;
}
poundlistService . updateById ( poundlistEntity ) ;
}
saleordercetEntity . setAmountCollected ( sum ) ;
// saleordercetEntity.setStatus("3");
saleorderitemService . updateById ( saleordercetEntity ) ;
collectionEntity . setStatus ( "1" ) ;
collectionService . updateById ( collectionEntity ) ;
return ActionResult . success ( "提交成功" ) ;
}
}
}
return ActionResult . fail ( "请选择一条数据" ) ;
} * /
/ * *
* 认 款
@ -261,27 +176,6 @@ public class CollectionController {
}
}
return ActionResult . fail ( "请选择一条数据" ) ;
// String[] idList = ids.split(",");
// for (String id : idList) {
// CollectionEntity collectionEntity = collectionService.getInfo(id);
// if (ObjectUtils.isNotEmpty(collectionEntity)) {
// if (collectionEntity.getStatus().equals("0")) {
// return ActionResult.fail("请先提交");
// }
// if (collectionEntity.getStatus().equals("2")) {
// return ActionResult.fail("已认款,无需再次提交");
// }
// if (collectionEntity.getAmountCollected() == null || collectionEntity.getAmountCollected().compareTo(BigDecimal.ZERO) < 1) {
// return ActionResult.fail("请先输入收款金额");
// }
// collectionEntity.setStatus("2");
// collectionService.updateById(collectionEntity);
// return ActionResult.success("认款成功");
// } else {
// return ActionResult.fail("数据为空");
// }
// }
// return ActionResult.fail("请选择一条数据");
}
/ * *
* 列 表