喻健
2018-12-10 5a9e4c13d08d3b1cb7da8f50f1097b33bb113b23
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserGoodsStorageServiceImpl.java
@@ -4,7 +4,6 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
@@ -208,11 +207,9 @@
      long nd = 1000 * 24 * 60 * 60;
      List<CommonGoods> listUpadteCommonGoods = new ArrayList<CommonGoods>();
      
      BigDecimal  rate = manageService.getFanLiRate();
      Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
            .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
      Map<String, String> map = manageService.convertMap();
      BigDecimal  rate = manageService.getFanLiRate();
      
      
      for (UserGoodsStorage userGoodsStorage : listStorage) {
@@ -231,20 +228,28 @@
         if (goodsState != null && (goodsState != 1 || !goodsState.equals(1))) {
            Date updateTime = commonGoods.getUpdateTime();
            if (updateTime != null) {
               long diff = nowDate.getTime() - updateTime.getTime();
               // 计算差多少小时
               long diff = nowDate.getTime() - updateTime.getTime();
               long day = diff / nd;
                long hour = diff % nd / nh;
                if (hour > 1 ) {
                if (hour > 1 || day > 0 ) {
                   try {
                      if (commonGoods.getGoodsType() == CommonGoods.GOODS_TYPE_TB) {
                         goodsBrief = redisManager.getTaoBaoGoodsBrief(commonGoods.getGoodsId());
                         goodsBrief.setState(0);
                         goodsState = 0;
                         goodsBrief.setState(goodsState);
                         CommonGoods upadeteCommonGoods = CommonGoodsFactory.create(goodsBrief);
                         upadeteCommonGoods.setState(goodsState);
                        upadeteCommonGoods.setId(commonGoods.getId());
                        listUpadteCommonGoods.add(upadeteCommonGoods);
                      }
                  } catch (TaobaoGoodsDownException e) {
                     // 已下架
                     goodsState = 1;
                     commonGoods.setState(1);
                     commonGoods.setState(goodsState);
                     listUpadteCommonGoods.add(commonGoods);
                     e.printStackTrace();
                  }
                }
@@ -253,25 +258,21 @@
         
         if (goodsBrief == null) {
            goodsBrief = TaoBaoUtil.convert(commonGoods);
         } else {
            CommonGoods upadeteCommonGoods = CommonGoodsFactory.create(goodsBrief);
            upadeteCommonGoods.setState(goodsState);
            listUpadteCommonGoods.add(upadeteCommonGoods);
         }
         
         // 判断是否已分享
         Integer state = userGoodsStorage.getState();
         int shared = UserGoodsStorage.STATE_SHARED;
         if (state != null && (state == shared || state.equals(shared))) {
            if (goodsState != 1 || goodsState.equals(1)) {
            if (goodsState != 1 || !goodsState.equals(1)) {
               goodsBrief.setState(2); // 已分享状态
            }
         }
         // 改变图片尺寸
         String pictUrl = commonGoods.getPicture();
         String pictUrl = goodsBrief.getPictUrl();
         if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
            commonGoods.setPicture(TbImgUtil.getTBSize320Img(pictUrl));
            goodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
         }
         String json = gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, rate.toString(), null));
@@ -349,6 +350,5 @@
      data.put("notifyDesc", configService.get("goods_share_notify"));
      return data;
   }
}