1 避免大量if判空检查
/**
* 空置判断
* @param v
* @param mes
* @throws BusinessException
*/
private void checkNull(Object v,String mes) throws BusinessException{
if(v==null || "".equals(v)) throw new BusinessException(ExceptionEmnu.NULL,mes);
}
checkNull(request.getExchangeRate(),"汇率不能为空");
2 避免大量的set语句
ExchangeOrder order=new ExchangeOrder(
//多机部署需要更换订单号生成策略
IDProduceUtil.produceEfId(),
request.getUserPin(),
//如果时买进则为负数
request.getAmount().multiply(fh),
//如果时买进则为负数
request.getForeignAmount().multiply(fh),
request.getExchangeRate(),
request.getForeignCurrency(),
request.getExchangeType(),
ORDER_STATUS_SUBMIT
);
this.exchangeOrderDao.saveOrder(order);
网友评论