|
|
@@ -539,59 +539,4 @@ public class DistributionRuleServiceImpl implements DistributionRuleService{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<Goods> updateData() {
|
|
|
- List<Goods> allGoods = goodsDao.findAll();
|
|
|
- List<Goods> resultList = new ArrayList<>(allGoods.size());
|
|
|
- for (Goods goods : allGoods) {
|
|
|
- if (isNeedUpdate(goods)) {
|
|
|
-// updatePrice(goods);
|
|
|
- resultList.add(goods);
|
|
|
- }
|
|
|
- }
|
|
|
-// goodsDao.save(resultList);
|
|
|
- return resultList;
|
|
|
- }
|
|
|
-
|
|
|
- private void updatePrice(Goods goods) {
|
|
|
- if (Currency.RMB.equals(goods.getCurrencyName())) {
|
|
|
- goods.setMinPriceRMB(GoodsUtil.getMinPriceRMB(goods.getPrices()));
|
|
|
- goods.setMaxPriceRMB(GoodsUtil.getMaxPriceRMB(goods.getPrices()));
|
|
|
- } else if (Currency.USD.equals(goods.getCurrencyName())) {
|
|
|
- goods.setMinPriceUSD(GoodsUtil.getMinPriceUSD(goods.getPrices()));
|
|
|
- goods.setMaxPriceUSD(GoodsUtil.getMaxPriceUSD(goods.getPrices()));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private boolean isNeedUpdate(Goods goods) {
|
|
|
- if (Currency.RMB.equals(goods.getCurrencyName())) {
|
|
|
- return boolRmb(goods);
|
|
|
- } else if (Currency.USD.equals(goods.getCurrencyName())) {
|
|
|
- return boolUsd(goods);
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- private boolean boolRmb(Goods goods) {
|
|
|
- if (goods.getMinPriceRMB() == null || goods.getMaxPriceRMB() == null) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- if (!goods.getMinPriceRMB().equals(GoodsUtil.getMinPriceRMB(goods.getPrices()))
|
|
|
- || !goods.getMaxPriceRMB().equals(GoodsUtil.getMaxPriceRMB(goods.getPrices()))) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- private boolean boolUsd(Goods goods) {
|
|
|
- if (goods.getMinPriceUSD() == null || goods.getMaxPriceUSD() == null) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- if (!goods.getMinPriceUSD().equals(GoodsUtil.getMinPriceUSD(goods.getPrices()))
|
|
|
- || !goods.getMaxPriceUSD().equals(GoodsUtil.getMaxPriceUSD(goods.getPrices()))) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
}
|