/** * 将包含授权信息的Shop转换为ShopVo * * @param shop * @return */ private ShopVo convertShopAndAuth2ShopVo(Shop shop) { ShopVo shopVo = null; if (shop == null) { return shopVo; } shopVo = new ShopVo(); shopVo.setId(shop.getId()); shopVo.setShopId(shop.getOutShopId()); shopVo.setCatId(shop.getCatId()); shopVo.setNick(shop.getNick()); shopVo.setTitle(shop.getTitle()); shopVo.setDescription(shop.getDescription()); shopVo.setBulletin(shop.getBulletin()); shopVo.setPicPath(shop.getPicPath()); shopVo.setItemScore(shop.getItemScore()); shopVo.setServiceScore(shop.getServiceScore()); shopVo.setDeliveryScore(shop.getDeliveryScore()); shopVo.setDeExpress(shop.getDeExpress()); shopVo.setEnableMsg(shop.getEnableMsg()); shopVo.setMsgTemp(shop.getMsgTemp()); shopVo.setMsgSign(shop.getMsgSign()); shopVo.setOutPlatformType(shop.getPlatformType().getName()); shopVo.setOutPlatformTypeValue( PlatformType.valueOf(shop.getPlatformType().getName()).getValue()); shopVo.setCreateTime(shop.getCreateTime()); shopVo.setUpdateTime(shop.getUpdateTime()); if (shop.getShopAuth() != null) { shopVo.setSessionKey(shop.getShopAuth().getSessionKey()); shopVo.setRefreshToken(shop.getShopAuth().getRefreshToken()); } return shopVo; }
/** * 查询店铺 * * @param shop * @return */ @Transactional(readOnly = true) public List<Shop> getShop(Shop shop) { if (logger.isInfoEnabled()) { logger.info("getShop方法参数为shop[{}]", shop); } Search search = new Search(Shop.class).setCacheable(true); if (shop != null) { if (!NumberUtil.isNullOrZero(shop.getId())) { search.addFilterEqual("id", shop.getId()); } if (StringUtils.isNotBlank(shop.getNick())) { search.addFilterLike("nick", "%" + shop.getNick().trim() + "%"); } if (StringUtils.isNotBlank(shop.getUid())) { search.addFilterLike("uid", "%" + shop.getUid().trim() + "%"); } if (StringUtils.isNotBlank(shop.getTitle())) { search.addFilterLike("title", "%" + shop.getTitle().trim() + "%"); } if (shop.getPlatformType() != null) { search.addFilterEqual("platformType", shop.getPlatformType()); } if (!NumberUtil.isNullOrZero(shop.getOutShopId())) { search.addFilterEqual("outShopId", shop.getOutShopId()); } } search.addFilterEqual("isDelete", false); return generalDAO.search(search); }
/** * 查询店铺 * * @param shop * @return */ @Transactional(readOnly = true) public List<Shop> getOnlineShopAndAuth(Shop shop) { if (logger.isInfoEnabled()) { logger.info("getShop方法参数为shop[{}]", shop); } Search search = new Search(Shop.class).addFetch("shopAuth").setCacheable(true); if (shop != null) { // 根据id精确查询 if (!NumberUtil.isNullOrZero(shop.getId())) { search.addFilterEqual("id", shop.getId()); } // 根据nick模糊查询 if (StringUtils.isNotBlank(shop.getNick())) { search.addFilterLike("nick", "%" + shop.getNick().trim() + "%"); } // 根据店铺名称模糊查询 if (StringUtils.isNotBlank(shop.getTitle())) { search.addFilterLike("title", "%" + shop.getTitle().trim() + "%"); } // 根据外部平台店铺id精确查询 if (!NumberUtil.isNullOrZero(shop.getOutShopId())) { search.addFilterEqual("outShopId", shop.getOutShopId()); } // 根据平台模糊查询 if (shop.getPlatformType() != null) { search.addFilterEqual("platformType", shop.getPlatformType()); } } search.addFilterNotEmpty("shopAuthId"); search.addFilterEqual("isDelete", false); return generalDAO.search(search); }
/** * 根据条件查询唯一的返回值 * * @param shop * @return */ public Shop getShopByConditionIncludeDelete(Shop shop) { if (logger.isInfoEnabled()) { logger.info("getShop方法参数为shop[{}]", shop); } Search search = new Search(Shop.class).setCacheable(true); if (shop != null) { if (!NumberUtil.isNullOrZero(shop.getUid())) { search.addFilterEqual("uid", shop.getUid()); } if (shop.getPlatformType() != null) { search.addFilterEqual("platformType", shop.getPlatformType()); } } // search.addFilterEqual("isDelete", false); List<Shop> shopList = generalDAO.search(search); return CollectionUtils.isNotEmpty(shopList) ? shopList.get(0) : null; }
/** * 店铺更新 * * @param shop */ public void updateShop(Shop shop, String sessionKey) throws Exception { if (logger.isInfoEnabled()) { logger.info("店铺更新:" + shop); } if (!(StringUtils.isBlank(shop.getBulletin()) && StringUtils.isBlank(shop.getDescription()))) { // 判断来自哪个平台 if (StringUtils.equals(shop.getPlatformType().getName(), PlatformType.TAO_BAO.getName()) || StringUtils.equals( shop.getPlatformType().getName(), PlatformType.TAO_BAO_2.getName())) { // 将店铺信息更新至淘宝平台 taoBaoShopApiService.updateShop(shop, sessionKey); } else if (StringUtils.equals( shop.getPlatformType().getName(), PlatformType.JING_DONG.getName())) { // 将店铺信息更新至京东平台 jingDongShopApiService.updateShop(shop, sessionKey); } } // 所有操作成功,店铺更新 generalDAO.saveOrUpdate(shop); if (logger.isInfoEnabled()) { logger.info("店铺更新成功!"); } }
/** * 将店铺及授权信息转换为shopBean * * @param shop * @return */ private ShopBean convertShop2ShopBean(Shop shop) { ShopBean shopBean = null; if (shop == null) { return shopBean; } shopBean = new ShopBean(); shopBean.setShopId(shop.getId()); shopBean.setOutShopId(shop.getOutShopId()); shopBean.setTitle(shop.getTitle()); shopBean.setSellerNick(shop.getNick()); if (shop.getShopAuth() != null) { shopBean.setUserId(shop.getShopAuth().getUserId()); shopBean.setSessionKey(shop.getShopAuth().getSessionKey()); shopBean.setRefreshToken(shop.getShopAuth().getRefreshToken()); } shopBean.setPlatformType(shop.getPlatformType()); shopBean.setShopType(shop.getShopType()); return shopBean; }