|
@@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.pagehelper.Page;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -135,13 +136,33 @@ public class OrderBillSheetServiceImpl extends ServiceImpl<OrderBillSheetMapper,
|
|
|
//生成订单
|
|
|
Collection<OrderBillGoods> coll = new HashSet<>();
|
|
|
for (OrderBillGoodsAddBo g : goodsList) {
|
|
|
+ //计费单商品
|
|
|
OrderBillGoods orderGoods = BeanUtil.toBean(g, OrderBillGoods.class);
|
|
|
orderGoods.setOrderSn(bo.getOrderSn());
|
|
|
orderGoods.setSheetSn(sheet_no);
|
|
|
orderGoods.setCreateTime(DateUtils.getNowTime());
|
|
|
orderGoods.setUpdateTime(DateUtils.getNowTime());
|
|
|
coll.add(orderGoods);
|
|
|
- iOrderGoodsService.getOne(new LambdaQueryWrapper<OrderGoods>().eq(OrderGoods::getOrderSn, bo.getOrderSn()));
|
|
|
+ if(orderGoods.getAmount().compareTo(BigDecimal.ZERO)!=1){
|
|
|
+ throw new CustomException("已收费用必须大于0");
|
|
|
+ }
|
|
|
+ //订单商品
|
|
|
+ OrderGoods goods = iOrderGoodsService.getOne(new LambdaQueryWrapper<OrderGoods>().eq(OrderGoods::getOrderSn, bo.getOrderSn()).eq(OrderGoods::getGoodsId,g.getGoodsId()));
|
|
|
+ //计费单已收费用累加
|
|
|
+ goods.getGoodsReceived().add(orderGoods.getAmount());
|
|
|
+ if(goods.getGoodsRealPrice().compareTo(goods.getGoodsReceived()) == -1){
|
|
|
+ throw new CustomException("已收费用超出成交价");
|
|
|
+ }
|
|
|
+ else if(goods.getGoodsRealPrice().compareTo(goods.getGoodsReceived()) == 0){
|
|
|
+ //完全收费
|
|
|
+ goods.setPayStatus(OrderGoods.PAY_FULL);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ //部分收费
|
|
|
+ goods.setPayStatus(OrderGoods.PAY_PART);
|
|
|
+ }
|
|
|
+ goods.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ iOrderGoodsService.updateById(goods);
|
|
|
}
|
|
|
iOrderBillGoodsService.saveBatch(coll);
|
|
|
this.save(add);
|