| | |
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.transaction.Transactional;
|
| | |
|
| | | import org.apache.commons.beanutils.PropertyUtils;
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | |
| | | import com.yeshi.fanli.dao.mybatis.GoodsClassMapper;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsSubClass;
|
| | | import com.yeshi.fanli.entity.bus.su.clazz.SuperGoodsClass;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | | import com.yeshi.fanli.exception.GoodsClassException;
|
| | | import com.yeshi.fanli.service.inter.config.BusinessSystemService;
|
| | | import com.yeshi.fanli.service.inter.goods.GoodsClassService;
|
| | | import com.yeshi.fanli.service.inter.goods.GoodsSubClassService;
|
| | | import com.yeshi.fanli.service.inter.goods.SuperGoodsClassService;
|
| | | import com.yeshi.fanli.service.inter.lable.LabelClassService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.Utils;
|
| | |
|
| | | @Service
|
| | | public class GoodsClassServiceImpl implements GoodsClassService {
|
| | |
|
| | | @Resource
|
| | | private BusinessSystemService businessSystemService;
|
| | |
|
| | | @Resource
|
| | | private SuperGoodsClassService superGoodsClassService;
|
| | |
|
| | | @Resource
|
| | | private GoodsClassMapper goodsClassMapper;
|
| | |
| | |
|
| | |
|
| | | @Override
|
| | | public int getCount(String platform, String packages, final String key) {
|
| | | public List<GoodsClass> listquery() throws Exception{
|
| | |
|
| | | Long systemId = null;
|
| | | |
| | | platform = Utils.getMap().get(platform);
|
| | | |
| | | BusinessSystem system = businessSystemService.getBusinessSystem(platform, packages);
|
| | | if (system != null) {
|
| | | systemId = system.getId();
|
| | | }
|
| | | ;
|
| | | return goodsClassMapper.countByName(key, systemId);
|
| | | }
|
| | | List<GoodsClass> list = goodsClassMapper.getGoodsClassAll();
|
| | | |
| | | if (list != null && list.size() == 0) {
|
| | | return list;
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public List<GoodsClass> queryAll(String platform, String packages) throws Exception{
|
| | |
|
| | | List<BusinessSystem> defultList = businessSystemService.getBusinessSystems();
|
| | |
|
| | | platform = Utils.getMap().get(platform);
|
| | | BusinessSystem system = businessSystemService.getBusinessSystem(platform, packages);
|
| | | |
| | | List<GoodsClass> goodsClassList = new ArrayList<GoodsClass>();
|
| | | List<SuperGoodsClass> superGoodsClassList = null;
|
| | | List<Long> gcIdList = new ArrayList<Long>();
|
| | | |
| | | if (system == null) {
|
| | | |
| | | goodsClassList = goodsClassMapper.getGoodsClassAll();
|
| | | |
| | | if (goodsClassList == null || goodsClassList.size() == 0) {
|
| | | return null;
|
| | | }
|
| | | |
| | | /* 存放类别id集合 */
|
| | | for (GoodsClass rs : goodsClassList) {
|
| | | gcIdList.add(rs.getId());
|
| | | }
|
| | |
|
| | | } else if (system != null) {
|
| | | superGoodsClassList = superGoodsClassService.getSuperGoodsClassBySystemId(system.getId());
|
| | | |
| | | if (goodsClassList == null || goodsClassList.size() == 0) {
|
| | | return null;
|
| | | }
|
| | | |
| | | for (SuperGoodsClass superGoodsClass : superGoodsClassList) {
|
| | | GoodsClass goodsClass = superGoodsClass.getGoodsClass();
|
| | | goodsClassList.add(goodsClass);
|
| | | gcIdList.add(goodsClass.getId());
|
| | | }
|
| | | |
| | | }
|
| | | |
| | | /* 根据类别 id 查询关联系统数据 */
|
| | | superGoodsClassList = superGoodsClassService.getSuperGoodsClasss(gcIdList);
|
| | |
|
| | | for (GoodsClass gclass : goodsClassList) {
|
| | | |
| | | for (GoodsClass gclass : list) {
|
| | | Long iosClick = gclass.getIosClick();
|
| | | Long androidClick = gclass.getAndroidClick();
|
| | |
|
| | |
| | | gclass.setCountClick(0l);
|
| | | }
|
| | |
|
| | | // 参数处理
|
| | | String searchParam = gclass.getSearchParam();
|
| | | if (searchParam == null) {
|
| | | gclass.setSearchParam("");
|
| | |
| | | gclass.setSearchParam(searchParam);
|
| | | }
|
| | |
|
| | |
|
| | | // 标签
|
| | | int countlabel = labelClassService.getCountQueryByClassId(gclass.getId());
|
| | | gclass.setCountlabel(countlabel);
|
| | |
|
| | | List<Long> gList = new ArrayList<Long>();
|
| | | if (superGoodsClassList != null && superGoodsClassList.size() > 0) {
|
| | | for (SuperGoodsClass srs : superGoodsClassList) {
|
| | | |
| | | long rsId = srs.getGoodsClass().getId();
|
| | | |
| | | if (gclass.getId() == rsId) {
|
| | | BusinessSystem gsystem = srs.getSystem();
|
| | | gList.add(gsystem.getId());
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | List<BusinessSystem> newList = new ArrayList<BusinessSystem>();
|
| | | // 是否有关联系统选项
|
| | | for (BusinessSystem dsystem : defultList) {
|
| | | |
| | | BusinessSystem newsystem = new BusinessSystem();
|
| | | |
| | | PropertyUtils.copyProperties(newsystem, dsystem);
|
| | | newsystem.setCheck(0);
|
| | | |
| | | if (gList != null && gList.size() > 0) {
|
| | | Long did = newsystem.getId();
|
| | | for (Long gid : gList) {
|
| | | if (gid == did) {
|
| | | newsystem.setCheck(1);
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | newList.add(newsystem);
|
| | | }
|
| | | |
| | | gclass.setSystemList(newList);
|
| | | |
| | | }
|
| | | |
| | | return goodsClassList;
|
| | |
|
| | | return list;
|
| | | }
|
| | |
|
| | | public List<GoodsClass> getGoodsClassAll() {
|
| | |
| | | throw new GoodsClassException(1, "分类名称不能为空");
|
| | | }
|
| | |
|
| | | |
| | | // 图片上传
|
| | | String picture = null;
|
| | | if (file != null) {
|
| | |
| | | }
|
| | |
|
| | | String params = record.getSearchParam();
|
| | | if (params== null || params.trim().length() == 0 || "null".equalsIgnoreCase(params)) {
|
| | | if (params == null || params.trim().length() == 0 || "null".equalsIgnoreCase(params)) {
|
| | | record.setSearchParam(null);
|
| | | } else {
|
| | | record.setSearchParam(params);
|
| | | } else if (!StringUtil.isJson(params)) {
|
| | | throw new GoodsClassException(1, "筛选条件非JSON格式");
|
| | | }
|
| | | |
| | |
|
| | |
|
| | | Long id = record.getId();
|
| | |
| | | record.setPicture(picture);
|
| | | record.setIosClick(0L);
|
| | | record.setAndroidClick(0L);
|
| | | |
| | | record.setCreatetime(java.lang.System.currentTimeMillis());
|
| | | |
| | | Integer state = record.getState();
|
| | | if (state == null) {
|
| | | record.setState(0);
|
| | | }
|
| | | |
| | |
|
| | | if (params== null || params.trim().length() == 0 || "null".equalsIgnoreCase(params)) {
|
| | | // 搜索条件:有券、在售价20-200、牛皮癣轻微
|
| | |
| | | record.setOrderby(maxOrder + 1);
|
| | |
|
| | | goodsClassMapper.insert(record);
|
| | | |
| | | // 默认所有系统使用
|
| | | List<BusinessSystem> listSystems = businessSystemService.getBusinessSystems();
|
| | | if (listSystems != null && listSystems.size() > 0) {
|
| | | for(BusinessSystem businessSystem: listSystems) {
|
| | | SuperGoodsClass superGoodsClass = new SuperGoodsClass();
|
| | | superGoodsClass.setGoodsClass(record);;
|
| | | superGoodsClass.setSystem(businessSystem);
|
| | | superGoodsClassService.insertSelective(superGoodsClass);
|
| | | }
|
| | | }
|
| | |
|
| | | } else {
|
| | | // 修改
|
| | |
| | | }
|
| | |
|
| | |
|
| | | |
| | | |
| | | |
| | | @Override
|
| | | public void uploadPicture(GoodsClass record, MultipartFile file) throws Exception {
|
| | |
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | @Cacheable(value="classCache",key="'getListClassCache-'+#systemId")
|
| | | public List<GoodsClass> getListClassCache(Long systemId) throws Exception {
|
| | | List<SuperGoodsClass> superGoodsClassList = superGoodsClassService.getSuperGoodsClassBySystemId(systemId);
|
| | | |
| | | if (superGoodsClassList == null || superGoodsClassList.size() == 0) {
|
| | | return null;
|
| | | }
|
| | | |
| | | List<GoodsClass> goodsClassList = new ArrayList<GoodsClass>();
|
| | | for (SuperGoodsClass superGoodsClass : superGoodsClassList) {
|
| | | GoodsClass goodsClass = superGoodsClass.getGoodsClass();
|
| | | goodsClassList.add(goodsClass);
|
| | | }
|
| | | |
| | | return goodsClassList;
|
| | | @Cacheable(value="classCache",key="'getEffectiveClassCache'")
|
| | | public List<GoodsClass> getEffectiveClassCache() throws Exception {
|
| | | return goodsClassMapper.getEffectiveClass();
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | @Cacheable(value="classCache",key="'getClassListAllCache-'+#systemId")
|
| | | public List<Map<String, Object>> getClassListAllCache(Long systemId) throws Exception {
|
| | | @Cacheable(value="classCache",key="'getClassListAllCache'+#changePicture")
|
| | | public List<Map<String, Object>> getClassListAllCache(boolean changePicture) throws Exception {
|
| | |
|
| | | List<GoodsClass> goodsClassList = goodsClassMapper.listGoodsClassBySystemId(systemId);
|
| | | List<GoodsClass> goodsClassList = goodsClassMapper.getEffectiveClass();
|
| | | if (goodsClassList == null || goodsClassList.size() == 0) {
|
| | | return null;
|
| | | }
|
| | |
| | | GoodsSubClass goodsSubClass = iterator.next();
|
| | | GoodsClass goodsClassInner = goodsSubClass.getRootClass();
|
| | | if (goodsClass.getId() == goodsClassInner.getId()) {
|
| | | |
| | | // 1.5.3新版图片替换
|
| | | if (changePicture) {
|
| | | String pictureSecond = goodsSubClass.getPictureSecond();
|
| | | if (pictureSecond != null && pictureSecond.trim().length() > 0) {
|
| | | goodsSubClass.setPicture(pictureSecond);
|
| | | }
|
| | | }
|
| | | |
| | | // 对应下子分类
|
| | | subClassList.add(goodsSubClass);
|
| | | iterator.remove();
|
| | | }
|
| | | |
| | | |
| | | }
|
| | | }
|
| | |
|