admin
2019-03-13 69bee82b81626b82b7f39f0e459e4f56b1699b51
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ScanHistoryV2ServiceImpl.java
@@ -1,6 +1,7 @@
package com.yeshi.fanli.service.impl.goods;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
@@ -54,11 +55,44 @@
      if (history.getUserInfo() == null && StringUtil.isNullOrEmpty(history.getDevice()))
         throw new ScanHistoryException(1, "设备或用户信息缺失");
      CommonGoods commonGoods = commonGoodsService.addOrUpdateCommonGoods(history.getCommonGoods());
      CommonGoods commonGoods = commonGoodsService.addCommonGoods(history.getCommonGoods());
      if (commonGoods == null)
         throw new CommonGoodsException(2, "商品信息不完整");
      history.setCommonGoods(commonGoods);
      scanHistoryV2Mapper.insertSelective(history);
   }
   @Override
   public List<ScanHistoryV2> getScanHistoryByDeviceOrUid(Long uid, String device, int page, int pageSize) {
      if (uid == null && StringUtil.isNullOrEmpty(device))
         return null;
      return scanHistoryV2Mapper.selectByDeviceOrUid(uid, device, (page - 1) * pageSize, pageSize);
   }
   @Override
   public long getCountByDeviceOrUid(Long uid, String device) {
      if (uid == null && StringUtil.isNullOrEmpty(device))
         return 0;
      Long count = scanHistoryV2Mapper.selectCountByDeviceOrUid(uid, device);
      return count == null ? 0 : count;
   }
   @Override
   public void deleteByDeviceOrUid(Long uid, String device) {
      if (uid == null && StringUtil.isNullOrEmpty(device))
         return;
      scanHistoryV2Mapper.deleteByDeviceOrUid(uid, device);
   }
   @Override
   public void deleteByAuctionIdAndDeviceOrUid(Long uid, String device, Long auctionId) {
      if (uid == null && StringUtil.isNullOrEmpty(device))
         return;
      List<ScanHistoryV2> list = scanHistoryV2Mapper.selectByDeviceOrUidAndGoodsIdAndGoodsType(uid, device, auctionId,
            CommonGoods.GOODS_TYPE_TB);
      if (list != null)
         for (ScanHistoryV2 sv : list)
            scanHistoryV2Mapper.deleteByPrimaryKey(sv.getId());
   }
}