| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.apache.commons.beanutils.PropertyUtils;
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
| | | import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl.AdActivityType;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.Special;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.SpecialExtra;
|
| | | import com.yeshi.fanli.entity.common.JumpDetailV2;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | import com.yeshi.fanli.exception.banner.SwiperPictureException;
|
| | | import com.yeshi.fanli.exception.homemodule.HomeNavbarException;
|
| | | import com.yeshi.fanli.exception.homemodule.SpecialException;
|
| | | import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.config.AppVersionService;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.AdActivityVersionControlService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SpecialCardService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SpecialExtraService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SpecialPlaceService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SpecialService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.vo.homemodule.SpecialVO;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | |
| | | @Resource
|
| | | private SpecialCardService specialCardService;
|
| | |
|
| | | @Resource
|
| | | private SpecialExtraService specialExtraService;
|
| | | |
| | | @Resource
|
| | | private JumpDetailV2Service jumpDetailV2Service;
|
| | |
|
| | |
| | |
|
| | | @Override
|
| | | public void saveObject(MultipartFile file, MultipartFile file2, MultipartFile file3, Special record,
|
| | | String jumpType) throws SpecialException, Exception {
|
| | | String jumpType, SpecialExtra extra) throws SpecialException, Exception {
|
| | |
|
| | | Long cardId = record.getCardId();
|
| | | if (cardId == null) {
|
| | |
| | | record.setParams(null);
|
| | | } else if (!StringUtil.isJson(params)) {
|
| | | throw new SpecialException(1, "跳转参数非JSON格式");
|
| | | }
|
| | |
|
| | | String startTime_str = record.getStartTime_str();
|
| | | if (record.isTimeTask() && (startTime_str == null || startTime_str.length() == 0)) {
|
| | | throw new SpecialException(1, "控制时间不能为空");
|
| | | } else {
|
| | | record.setParams(params.trim());
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(jumpType)) {
|
| | |
| | | }
|
| | |
|
| | | // 时间转换
|
| | | conversionTime(record);
|
| | | handleTime(record);
|
| | |
|
| | | Long state = record.getState();
|
| | | if (state == null) {
|
| | |
| | | record.setUpdatetime(new Date());
|
| | | specialMapper.insert(record);
|
| | |
|
| | | extra.setId(record.getId());
|
| | | |
| | | Special s = new Special();
|
| | | s.setId(record.getId());
|
| | | s.setOrderby(Integer.parseInt(s.getId() + ""));
|
| | |
| | |
|
| | | record.setUpdatetime(new Date());
|
| | | specialMapper.updateByPrimaryKey(record);
|
| | | |
| | | extra.setId(record.getId());
|
| | | }
|
| | | |
| | | // 添加补充信息
|
| | | specialExtraService.saveExtraInfo(extra);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | *
|
| | | * @param record
|
| | | */
|
| | | public void conversionTime(Special record) throws SpecialException, Exception {
|
| | | // 是否时间控制
|
| | | if (!record.isTimeTask()) {
|
| | | record.setStartTime(null);
|
| | | record.setEndTime(null);
|
| | | } else {
|
| | | String startTime_str = record.getStartTime_str();
|
| | | String endTime_str = record.getEndTime_str();
|
| | |
|
| | | if ((startTime_str == null || startTime_str.trim().length() == 0)
|
| | | && (endTime_str == null || endTime_str.trim().length() == 0)) {
|
| | | throw new HomeNavbarException(1, "请输入控制时间");
|
| | | } else {
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
| | | if (startTime_str != null && startTime_str.trim().length() > 0) {
|
| | | startTime_str = startTime_str.replaceAll("T", " ");
|
| | | record.setStartTime(format.parse(startTime_str));
|
| | | }
|
| | |
|
| | | if (endTime_str != null && endTime_str.trim().length() > 0) {
|
| | | endTime_str = endTime_str.replaceAll("T", " ");
|
| | | record.setEndTime(format.parse(endTime_str));
|
| | | }
|
| | | }
|
| | | private void handleTime(Special record) throws SpecialException, Exception {
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
| | | |
| | | String startTime_str = record.getStartTime_str();
|
| | | if (!StringUtil.isNullOrEmpty(startTime_str)) {
|
| | | startTime_str = startTime_str.replaceAll("T", " ");
|
| | | record.setStartTime(format.parse(startTime_str));
|
| | | }
|
| | | |
| | | String endTime_str = record.getEndTime_str();
|
| | | if (!StringUtil.isNullOrEmpty(endTime_str)) {
|
| | | endTime_str = endTime_str.replaceAll("T", " ");
|
| | | record.setEndTime(format.parse(endTime_str));
|
| | | }
|
| | | |
| | | if (record.getEndTime() != null && record.getStartTime() != null
|
| | | && record.getStartTime().getTime() > record.getEndTime().getTime()) {
|
| | | throw new SpecialException(1, "起始时间不能小于结束时间");
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | |
|
| | | // 文件路径
|
| | | String filePath = "/img/special/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String filePath = FilePathEnum.special.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | String fileLink = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | |
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void updateOrder(Long id, Integer moveType, Integer sex) throws SpecialException {
|
| | |
|
| | | if (id == null || moveType == null || (!moveType.equals(1) && !moveType.equals(-1)) || sex == null) {
|
| | |
| | | COSManager.getInstance().deleteFile(subPicture);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | if (listSpecial != null)
|
| | | for (Special special : listSpecial) {
|
| | | List<AdActivityVersionControl> versionList = adActivityVersionControlService
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Special> listQueryByCard(long start, int count, Long card, String key, Integer sex) {
|
| | |
|
| | | public List<SpecialVO> listQueryByCard(long start, int count, Long card, String key, Integer sex) {
|
| | | List<Special> list = specialMapper.listQueryByCard(start, count, card, key, sex);
|
| | | if (list == null || list.size() == 0) {
|
| | | return list;
|
| | | if (list == null) {
|
| | | return null;
|
| | | }
|
| | |
|
| | | // 跳转链接
|
| | | List<SpecialVO> listvo = new ArrayList<SpecialVO>();
|
| | | for (Special special : list) {
|
| | |
|
| | | Date startTime = special.getStartTime();
|
| | | Date endTime = special.getEndTime();
|
| | |
|
| | | if (startTime == null && endTime == null) {
|
| | | special.setTimeTask(false);
|
| | | special.setStartTime_str("");
|
| | | special.setEndTime_str("");
|
| | | SpecialVO specialVO = new SpecialVO();
|
| | | try {
|
| | | PropertyUtils.copyProperties(specialVO, special);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | continue;
|
| | | }
|
| | | |
| | | if (specialVO.getState() != null && specialVO.getState().longValue() == 0) {
|
| | | specialVO.setState(1L);
|
| | | } else {
|
| | | special.setTimeTask(true);
|
| | |
|
| | | specialVO.setState(0L);
|
| | | }
|
| | | |
| | | Date startTime = specialVO.getStartTime();
|
| | | Date endTime = specialVO.getEndTime();
|
| | | if (startTime == null && endTime == null) {
|
| | | specialVO.setStartTime_str("");
|
| | | specialVO.setEndTime_str("");
|
| | | } else {
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
|
| | | if (startTime == null) {
|
| | | special.setStartTime_str("");
|
| | | specialVO.setStartTime_str("");
|
| | | } else {
|
| | | special.setStartTime_str(sdf.format(startTime));
|
| | | specialVO.setStartTime_str(sdf.format(startTime));
|
| | | }
|
| | |
|
| | | if (endTime == null) {
|
| | | special.setEndTime_str("");
|
| | | specialVO.setEndTime_str("");
|
| | | } else {
|
| | | special.setEndTime_str(sdf.format(endTime));
|
| | | specialVO.setEndTime_str(sdf.format(endTime));
|
| | | }
|
| | | }
|
| | |
|
| | | String params = special.getParams();
|
| | | String params = specialVO.getParams();
|
| | | if (StringUtil.isNullOrEmpty(params)) {
|
| | | special.setParams("");
|
| | | specialVO.setParams("");
|
| | | }
|
| | |
|
| | | String remark = special.getRemark();
|
| | | String remark = specialVO.getRemark();
|
| | | if (StringUtil.isNullOrEmpty(remark)) {
|
| | | special.setRemark("");
|
| | | specialVO.setRemark("");
|
| | | }
|
| | |
|
| | | JumpDetailV2 jumpDetail = special.getJumpDetail();
|
| | | JumpDetailV2 jumpDetail = specialVO.getJumpDetail();
|
| | | if (jumpDetail == null) {
|
| | | // 默认未选择
|
| | | JumpDetailV2 jumpDetailV2 = new JumpDetailV2();
|
| | | jumpDetailV2.setName("-未选择-");
|
| | | jumpDetailV2.setType("default");
|
| | | special.setJumpDetail(jumpDetailV2);
|
| | | specialVO.setJumpDetail(jumpDetailV2);
|
| | | }
|
| | | |
| | | // 补充信息
|
| | | SpecialExtra extra = specialExtraService.selectByPrimaryKey(specialVO.getId());
|
| | | if (extra == null) {
|
| | | specialVO.setNeedSpin(false);
|
| | | specialVO.setComment("");
|
| | | } else {
|
| | | specialVO.setNeedSpin(extra.getNeedSpin());
|
| | | if (StringUtil.isNullOrEmpty(extra.getComment())) {
|
| | | specialVO.setComment("");
|
| | | } else {
|
| | | specialVO.setComment(extra.getComment());
|
| | | }
|
| | | }
|
| | | |
| | | listvo.add(specialVO);
|
| | | }
|
| | | return list;
|
| | | return listvo;
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | if (hour < 6) {// 0-6点之间不进入自购立减的页面
|
| | | s.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
|
| | | JSONObject params = new JSONObject();
|
| | | params.put("url", configService.get("tlj_own_buy_nogoods"));
|
| | | params.put("url", configService.get(ConfigKeyEnum.tljOwnBuyNogoods.getKey()));
|
| | | s.setParams(params.toString());
|
| | | } else {
|
| | | // 查询专题详情
|
| | |
| | | s.setParams(special.getParams());
|
| | | }
|
| | | }
|
| | |
|
| | | if (s.getJumpDetail() != null) {
|
| | | s.getJumpDetail().setNeedLogin(s.isJumpLogin()
|
| | | | (s.getJumpDetail().getNeedLogin() != null && s.getJumpDetail().getNeedLogin()));
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | // 数据处理
|
| | | handlelist(listArc);
|
| | | // handlelist(listArc);
|
| | | arcMap.put("list", JsonUtil.getApiCommonGson().toJson(listArc));
|
| | |
|
| | | // 首页-活动区域(女王节)
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | @Override
|
| | | public void switchState(Long id) throws SpecialException {
|
| | | if (id == null) {
|
| | | throw new SpecialException(1, "请传递正确参数");
|
| | | }
|
| | | |
| | | Special resultObj = specialMapper.selectByPrimaryKey(id);
|
| | | if (resultObj == null) {
|
| | | throw new SpecialException(1, "此内容已不存在");
|
| | | }
|
| | | |
| | | Long state = resultObj.getState();
|
| | | if (state == null || state == 0) {
|
| | | state = 1L;
|
| | | } else {
|
| | | state = 0L;
|
| | | }
|
| | | |
| | | Special updateObj = new Special();
|
| | | updateObj.setId(id);
|
| | | updateObj.setState(state);
|
| | | updateObj.setJumpLogin(resultObj.isJumpLogin());
|
| | | specialMapper.updateByPrimaryKeySelective(updateObj);
|
| | | }
|
| | | |
| | | }
|