| | |
| | | package com.yeshi.fanli.service.impl.goods;
|
| | |
|
| | | import java.io.Serializable;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.hibernate.HibernateException;
|
| | | import org.hibernate.Query;
|
| | | import org.hibernate.Session;
|
| | | import org.hibernate.Transaction;
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.orm.hibernate4.HibernateCallback;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.goods.SuperRecommendBannerV2Dao;
|
| | | import com.yeshi.fanli.dao.mybatis.SuperRecommendBannerV2Mapper;
|
| | | import com.yeshi.fanli.entity.bus.recommend.RecommendBannerV2;
|
| | | import com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendBannerV2;
|
| | | import com.yeshi.fanli.entity.system.System;
|
| | | import com.yeshi.fanli.service.inter.config.SystemService;
|
| | | import com.yeshi.fanli.entity.common.JumpDetailV2;
|
| | | import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.goods.SuperRecommendBannerV2Service;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
|
| | | @Service
|
| | | public class SuperRecommendBannerV2ServiceImpl implements SuperRecommendBannerV2Service {
|
| | |
|
| | | @Resource
|
| | | private SuperRecommendBannerV2Dao superRecommendBannerV2Dao;
|
| | | private SuperRecommendBannerV2Mapper superRecommendBannerV2Mapper;
|
| | |
|
| | | @Resource
|
| | | private SystemService systemService;
|
| | | |
| | | @Cacheable(value = "bannerCache", key = "'getSuperRecommendBannerV2sBySystem-'+#system.id")
|
| | | public List<SuperRecommendBannerV2> getSuperRecommendBannerV2sBySystem(
|
| | | final System system) {
|
| | | List<SuperRecommendBannerV2> list = superRecommendBannerV2Dao.list(
|
| | | "from SuperRecommendBannerV2 srb where srb.system.id=? order by srb.recommendBanner.orderby",
|
| | | new Serializable[] { system.getId() });
|
| | | return list;
|
| | | }
|
| | | private JumpDetailV2Service jumpDetailV2Service;
|
| | |
|
| | | |
| | | public List<SuperRecommendBannerV2> getSuperRecommendBanners(int pageIndex) {
|
| | | int start = pageIndex * Constant.PAGE_SIZE;
|
| | |
|
| | | List<SuperRecommendBannerV2> list = superRecommendBannerV2Dao.list(
|
| | | "from SuperRecommendBannerV2 srb order by srb.recommendBanner.orderby", start, Constant.PAGE_SIZE,
|
| | | new Serializable[] {});
|
| | | @Cacheable(value = "bannerCache", key = "'getSuperRecommendBannerV2sBySystem-'+#systemId")
|
| | | public List<RecommendBannerV2> getSuperRecommendBannerV2sBySystem(Long systemId) {
|
| | | // 首页Banner
|
| | | List<RecommendBannerV2> listBanner = null;
|
| | |
|
| | | return list;
|
| | | }
|
| | |
|
| | | public List<SuperRecommendBannerV2> getSuperRecommendBannersByBanners(
|
| | | List<Long> rbIdList) {
|
| | | if (rbIdList.size() == 0) {
|
| | | return new ArrayList<SuperRecommendBannerV2>();
|
| | | }
|
| | | StringBuffer sb = new StringBuffer(" from SuperRecommendBannerV2 srb ");
|
| | | Serializable[] serArr = new Serializable[rbIdList.size()];
|
| | | for (int i = 0; i < rbIdList.size(); i++) {
|
| | | if (i == 0) {
|
| | | sb.append(" where srb.recommendBanner.id=? ");
|
| | | } else {
|
| | | sb.append(" or srb.recommendBanner.id=? ");
|
| | | }
|
| | | serArr[i] = rbIdList.get(i);
|
| | | }
|
| | | sb.append(" order by srb.recommendBanner.orderby ");
|
| | | String hql = sb.toString();
|
| | |
|
| | | return superRecommendBannerV2Dao.list(hql, serArr);
|
| | |
|
| | | }
|
| | |
|
| | | public Integer deleteSuperRecommendBanner(final long rbid, final String platform,final String packageName) {
|
| | | return (Integer) superRecommendBannerV2Dao.excute(new HibernateCallback<Integer>() {
|
| | |
|
| | | public Integer doInHibernate(Session session)
|
| | | throws HibernateException {
|
| | | System system = systemService.getSystem(platform, packageName);
|
| | | Transaction transaction = session.beginTransaction();
|
| | | Query query = session.createQuery("delete SuperRecommendBannerV2 srb "
|
| | | + " where srb.recommendBanner.id=? and srb.system.id=?");
|
| | | query.setLong(0, rbid);
|
| | | query.setLong(1, system.getId());
|
| | | int i = query.executeUpdate();
|
| | | transaction.commit();
|
| | | return i ;
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | public void addSuperRecommendBanner(long rbid, String platform,String packageName) {
|
| | | System system = systemService.getSystem(platform,packageName);
|
| | | SuperRecommendBannerV2 superRecommendBanner = new SuperRecommendBannerV2();
|
| | | RecommendBannerV2 recommendBanner = new RecommendBannerV2();
|
| | | recommendBanner.setId(rbid);
|
| | | superRecommendBanner.setRecommendBanner(recommendBanner);
|
| | | superRecommendBanner.setSystem(system);
|
| | | superRecommendBannerV2Dao.create(superRecommendBanner);
|
| | | }
|
| | |
|
| | | public void deleteSuperRecommendBanners(final long[] rbids) {
|
| | | superRecommendBannerV2Dao.excute(new HibernateCallback() {
|
| | |
|
| | | public Object doInHibernate(Session session) throws HibernateException {
|
| | | List<SuperRecommendBannerV2> listRecommendBanner = superRecommendBannerV2Mapper.listBySystemId(systemId);
|
| | | if (listRecommendBanner != null && listRecommendBanner.size() > 0) {
|
| | | listBanner = new ArrayList<RecommendBannerV2>();
|
| | | |
| | | for (SuperRecommendBannerV2 superRecommendBanner : listRecommendBanner) {
|
| | | RecommendBannerV2 recommendBanner = superRecommendBanner.getRecommendBanner();
|
| | | // 淘特价暂时修改
|
| | | if (systemId == 7) {
|
| | | recommendBanner.getJumpDetail().setActivity(recommendBanner.getJumpDetail().getActivity()
|
| | | .replace("com.yeshi.ec.rebate.myapplication", "com.yeshi.ec.taospecial"));
|
| | | }
|
| | |
|
| | | StringBuffer sb = new StringBuffer("delete from SuperRecommendBannerV2 s ");
|
| | | for (int i = 0; i < rbids.length; i++) {
|
| | | if(i==0){
|
| | | sb.append(" where s.recommendBanner.id=? ");
|
| | | }else{
|
| | | sb.append(" or s.recommendBanner.id=?");
|
| | | }
|
| | | JumpDetailV2 jumpDetail = recommendBanner.getJumpDetail();
|
| | | if (jumpDetail != null) {
|
| | | jumpDetail = jumpDetailV2Service.selectByPrimaryKey(jumpDetail.getId());
|
| | | recommendBanner.setJumpDetail(jumpDetail);
|
| | | }
|
| | | Query query = session.createQuery(sb.toString());
|
| | | for (int i = 0; i < rbids.length; i++) {
|
| | | query.setLong(i, rbids[i]);
|
| | | }
|
| | | query.executeUpdate();
|
| | | return null;
|
| | | listBanner.add(recommendBanner);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | public List<SuperRecommendBannerV2> getSuperRecommendBannerBySystemId(
|
| | | long id, int strat, int count) {
|
| | | return superRecommendBannerV2Dao.list("from SuperRecommendBannerV2 srs where srs.system.id=? order by srs.recommendBanner.orderby ",strat,count,new Serializable[]{id});
|
| | | }
|
| | |
|
| | | return listBanner;
|
| | | }
|
| | |
|
| | |
|
| | | public List<SuperRecommendBannerV2> getSuperRecommendBannerBySystemId(
|
| | | long id, int strat, int count, String key) {
|
| | | return superRecommendBannerV2Dao.list("from SuperRecommendBannerV2 srs where srs.system.id=? and srs.recommendBanner.name like ?",strat,count,new Serializable[]{id, key});
|
| | | |
| | | }
|
| | |
|
| | | |
| | | }
|