新的需求还能搞清楚,旧功能又出问题了
这就是高要求
而且你不能等着问题找上来才解决
你要自己发现问题才行
只是无脑开发没有任何灵魂
在一个地方加 场地必填 其它地方你要想到会不会需要必填
如果想到了 这个问题 这就是你的水平
当你看一个系统,你知道它的灵魂在哪里说明你掌握了它
对你负责的系统一定要烂熟于心
一个系统是由无数个细节构成的
你能发现多少个细节
就能发现多少系统的美
细节是魔鬼呀
也是天使
怎么算是烂熟于心呢?
你可以随心所欲的在上面加新功能
还不影响原来的功能
这就要求非常高了
你会被哪些随心所欲的改造惊艳到的
这就是逻辑之美
写代码并不仅仅时简单的增删改查
那是没有灵魂的
你找到了代码的灵魂,就发现它的美了
public IocarFeeEntity buildIocarFeeInfo(IocarCarEntity inCar, List<IocarGoodsEntity> inGoodsList, String tradeNum) {
IocarFeeEntity iocarFee = new IocarFeeEntity();
iocarFee.setTradeNum(tradeNum);
iocarFee.setFeeNameType(inCar.getAreaType() == 0 ? "10" : "20");
iocarFee.setConfirmRegisterId(inCar.getId());
iocarFee.setConfirmRegisterNo(inCar.getRegisterNumber());
iocarFee.setPregisterId(inCar.getPregisterNumber());
iocarFee.setParkArea(inCar.getArea());
iocarFee.setParkBooth(inCar.getBooth());
iocarFee.setPayerName(inCar.getOwnerName());
iocarFee.setPayerPhone(inCar.getOwnerPhone());
iocarFee.setCarNumber(inCar.getCarNumber());
iocarFee.setContainerNumber(inCar.getContainerNumber());
iocarFee.setCarWeight(getDictValue("car_weight", inCar.getCarWeight()));
iocarFee.setCarLoadType(getDictValue("car_load_type", inCar.getCarLoadType()));
// 生成goodsType,goodsName,goodsInfo, goodsQuantity信息
StringBuilder goodsType = new StringBuilder();
StringBuilder goodsName = new StringBuilder();
StringBuilder goodsInfo = new StringBuilder();
BigDecimal entranceFee = BigDecimal.ZERO;
BigDecimal serviceFee = BigDecimal.ZERO;
BigDecimal selfServiceFee = BigDecimal.ZERO;
BigDecimal garbageFee = BigDecimal.ZERO;
BigDecimal overTimeFee = BigDecimal.ZERO;
Integer goodsQuantity = 0;
BigDecimal unitWeight = BigDecimal.ZERO;
BigDecimal totalWeight = BigDecimal.ZERO;
for (IocarGoodsEntity goods : inGoodsList) {
entranceFee = entranceFee.add(goods.getEntranceFee() == null ? BigDecimal.ZERO : goods.getEntranceFee());
serviceFee = serviceFee.add(goods.getServiceFee() == null ? BigDecimal.ZERO : goods.getServiceFee());
//空指针 导致支付更新接口失败
overTimeFee = overTimeFee.add(goods.getOvertimeFee() == null ? BigDecimal.ZERO : goods.getOvertimeFee());
selfServiceFee = selfServiceFee.add(goods.getSelfServiceFee() == null ? BigDecimal.ZERO : goods.getSelfServiceFee());
goodsQuantity += goods.getGoodsQuantity();
unitWeight = unitWeight.add(goods.getUnitWeight());
totalWeight = totalWeight.add(goods.getTotalWeight());
garbageFee = garbageFee.add(goods.getGarbageFee() == null ? BigDecimal.ZERO : goods.getGarbageFee());
goodsType.append(goods.getGoodsType()).append(",");
goodsName.append(goods.getGoodsName()).append(",");
goodsInfo.append(goods.getGoodsType()).append("-").append(goods.getGoodsName()).append(",");
}
goodsType.deleteCharAt(goodsType.length() - 1);
goodsName.deleteCharAt(goodsName.length() - 1);
goodsInfo.deleteCharAt(goodsInfo.length() - 1);
iocarFee.setGoodsType(goodsType.toString());
iocarFee.setGoodsName(goodsName.toString());
iocarFee.setGoodsInfo(goodsInfo.toString());
iocarFee.setGoodsQuantity(goodsQuantity);
iocarFee.setUnitWeight(unitWeight);
iocarFee.setTotalWeight(totalWeight);
// 费用信息
iocarFee.setEntranceFee(entranceFee);
iocarFee.setServiceFee(serviceFee);
iocarFee.setSelfServiceFee(selfServiceFee);
iocarFee.setGarbageFee(garbageFee);
iocarFee.setOvertimeFee(overTimeFee);
iocarFee.setReceivableFee(inCar.getPreSum());
//实收金额 = 预收金额 + 超时费
iocarFee.setFeeSum(inCar.getPreSum().add(overTimeFee));
iocarFee.setFeeStatus(PaymentStatusEnum.PAID.getCode());
iocarFee.setPayType(PayTypeEnum.WechatPayABC.getType());
iocarFee.setFeeDutyId(inCar.getAreaType() == 0 ? LocalDateTimeUtil.format(LocalDateTimeUtil.now(), "yyMMdd") + "00": LocalDateTimeUtil.format(LocalDateTimeUtil.now(), "yyMMdd") + "000");
iocarFee.setFeeDutyDate(LocalDate.now());
return iocarFee;