| | |
| | |
|
| | | /**
|
| | | * 更新浏览记录数据
|
| | | * @param uid
|
| | | * @param auctionId
|
| | | * @param shareId 分享id
|
| | | * @param count 浏览次数
|
| | | */
|
| | | @Override
|
| | | public void updateBrowseRecord (Long uid, Long auctionId, int count) throws UserShareGoodsRecordException{
|
| | | if (uid == null) {
|
| | | throw new UserShareGoodsRecordException(1, "用户ID不能为空");
|
| | | public void updateBrowseRecord (Long shareId, int count) throws UserShareGoodsRecordException{
|
| | |
|
| | | if (shareId == null) {
|
| | | throw new UserShareGoodsRecordException(1, "分享id为空");
|
| | | }
|
| | |
|
| | | if (auctionId == null) {
|
| | | throw new UserShareGoodsRecordException(1, "商品ID不能为空");
|
| | | List<UserShareGoodsGroup> list = listByRecordId(shareId);
|
| | | if (list == null || list.size() == 0) {
|
| | | throw new UserShareGoodsRecordException(1, "分享商品已不存在");
|
| | | }
|
| | |
|
| | | UserShareGoodsGroup newestRecord = getNewestRecord(uid, auctionId);
|
| | | List<UserShareGoodsGroup> listUpdate = new ArrayList<UserShareGoodsGroup>();
|
| | |
|
| | | if (newestRecord != null) {
|
| | | for (UserShareGoodsGroup group: list) {
|
| | | // 注意: 修改记录数据、但不可修改更新设置
|
| | | UserShareGoodsGroup shareGoodsGroup = new UserShareGoodsGroup(newestRecord.getId());
|
| | | UserShareGoodsGroup shareGoodsGroup = new UserShareGoodsGroup(group.getId());
|
| | |
|
| | | shareGoodsGroup.setTotalBrowse(newestRecord.getTotalBrowse() + count);
|
| | | shareGoodsGroup.setTotalBrowse(group.getTotalBrowse() + count);
|
| | |
|
| | | Date browseTime = newestRecord.getBrowseTime();
|
| | | Date browseTime = group.getBrowseTime();
|
| | | if (DateUtil.isSameDay(browseTime, new Date())) {
|
| | | shareGoodsGroup.setTodayBrowse(newestRecord.getTodayBrowse() + count);
|
| | | shareGoodsGroup.setTodayBrowse(group.getTodayBrowse() + count);
|
| | | } else {
|
| | | shareGoodsGroup.setTodayBrowse(count);
|
| | | shareGoodsGroup.setBrowseTime(new Date());
|
| | | }
|
| | |
|
| | | updateByPrimaryKeySelective(shareGoodsGroup);
|
| | | listUpdate.add(shareGoodsGroup);
|
| | | }
|
| | | |
| | | userShareGoodsGroupMapper.updateBatchSelective(listUpdate);
|
| | | |
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 更新订单记录数据
|
| | |
| | |
|
| | | Map<String, String> map = hongBaoManageService.convertMap();
|
| | | String proportion = map.get("hongbao_goods_proportion");
|
| | | String fcRate = map.get("hongbao_fc_ratio");
|
| | |
|
| | | for (UserShareGoodsGroup userShareGoodsGroup : list) {
|
| | | CommonGoods commonGoods = userShareGoodsGroup.getCommonGoods();
|
| | |
| | | if (goodsState != null && (goodsState != 1 || !goodsState.equals(1))) {
|
| | | Date updateTime = commonGoods.getUpdateTime();
|
| | | if (updateTime != null) {
|
| | | long diff = nowDate.getTime() - updateTime.getTime();
|
| | | |
| | | // 计算差多少小时
|
| | | long hour = diff % nd / nh;
|
| | | if (hour > 1) {
|
| | | try {
|
| | | if (commonGoods.getGoodsType() == CommonGoods.GOODS_TYPE_TB) {
|
| | | goodsBrief = redisManager.getTaoBaoGoodsBrief(commonGoods.getGoodsId());
|
| | | goodsBrief.setState(0);
|
| | | goodsState = 0;
|
| | | }
|
| | | long diff = nowDate.getTime() - updateTime.getTime();
|
| | | long day = diff / nd;
|
| | | long hour = diff % nd / nh;
|
| | | if (hour > 1 || day > 0 ) {
|
| | | try {
|
| | | if (commonGoods.getGoodsType() == CommonGoods.GOODS_TYPE_TB) {
|
| | | goodsBrief = redisManager.getTaoBaoGoodsBrief(commonGoods.getGoodsId());
|
| | | |
| | | 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();
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | if (goodsBrief == null) {
|
| | | goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | } else {
|
| | | CommonGoods upadeteCommonGoods = CommonGoodsFactory.create(goodsBrief);
|
| | | upadeteCommonGoods.setState(goodsState);
|
| | | listUpadteCommonGoods.add(upadeteCommonGoods);
|
| | | }
|
| | | } |
| | |
|
| | | // 改变图片尺寸
|
| | | String pictUrl = commonGoods.getPicture();
|
| | | if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
|
| | | commonGoods.setPicture(TbImgUtil.getTBSize320Img(pictUrl));
|
| | | }
|
| | |
|
| | | String json = gson
|
| | | .toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion, fcRate));
|
| | |
|
| | | |
| | | String json = gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion, null));
|
| | | |
| | | dataObject.put("groupId", userShareGoodsGroup.getId());
|
| | | dataObject.put("goods", json);
|
| | | array.add(dataObject);
|