| | |
| | | package com.yeshi.fanli.service.impl.homemodule;
|
| | |
|
| | | import java.io.InputStream;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.UUID;
|
| | |
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.Special;
|
| | | import com.yeshi.fanli.entity.common.JumpDetailV2;
|
| | | 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.SpecialCardService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SpecialPlaceService;
|
| | |
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private AppVersionService appVersionService;
|
| | |
|
| | | @Override
|
| | | public Special selectByPrimaryKey(Long id) {
|
| | |
| | | } 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, "控制时间不能为空");
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(jumpType)) {
|
| | | List<JumpDetailV2> listByType = jumpDetailV2Service.listByType(jumpType);
|
| | |
| | | record.setJumpDetail(listByType.get(0));
|
| | | }
|
| | | }
|
| | | |
| | | // 时间转换
|
| | | conversionTime(record);
|
| | |
|
| | | Long state = record.getState();
|
| | | if (state == null) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * web段时间转换
|
| | | * @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));
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 上传图片
|
| | | *
|
| | |
| | |
|
| | | // 跳转链接
|
| | | 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("");
|
| | | } else {
|
| | | special.setTimeTask(true);
|
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
|
| | | if (startTime == null) {
|
| | | special.setStartTime_str("");
|
| | | } else {
|
| | | special.setStartTime_str(sdf.format(startTime));
|
| | | }
|
| | | |
| | | if (endTime == null) {
|
| | | special.setEndTime_str("");
|
| | | } else {
|
| | | special.setEndTime_str(sdf.format(endTime));
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | String params = special.getParams();
|
| | | if (StringUtil.isNullOrEmpty(params)) {
|
| | | special.setParams("");
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | @Cacheable(value = "specialCache", key = "'listByVersion-'+#start+'-'+#count+'-'+#card+'-'+#platform+'-'+#versionCode")
|
| | | public List<Special> listByVersion(long start, int count, String card, Integer platform, Integer versionCode) {
|
| | | return specialMapper.listByVersion(start, count, card, platform, versionCode);
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Cacheable(value = "specialCache", key = "'listCacheSpecialToIndex'+#acceptData.platform+'-'+#acceptData.version+'-'+#sex")
|
| | | public JSONObject listCacheSpecialToIndex(AcceptData acceptData, Integer sex) throws Exception {
|
| | |
|
| | |
| | | JSONObject arcMap = new JSONObject();
|
| | |
|
| | | String indexArc = "index_arc";
|
| | | if (VersionUtil.greaterThan_1_6_0(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | if (VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | indexArc = "index_arc_1.6.5";
|
| | | else if (VersionUtil.greaterThan_1_6_0(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | indexArc = "index_arc_1.6.0";
|
| | | else if (VersionUtil.greaterThan_1_5_70(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | indexArc = "index_arc_1.5.7";
|
| | | else if (VersionUtil.greaterThan_1_5_60(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | indexArc = "index_arc_1.5.6";
|
| | |
|
| | | List<Special> listArc = specialMapper.listByPlaceKey(indexArc, sex);
|
| | | int platformCode = Constant.getPlatformCode(acceptData.getPlatform());
|
| | | int version = Integer.parseInt(acceptData.getVersion());
|
| | | |
| | | List<Special> listArc = specialMapper.listByPlaceKey(indexArc, sex, platformCode, version);
|
| | | if (listArc == null) {
|
| | | listArc = new ArrayList<Special>();
|
| | | } else if (listArc.size() > 0) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
|
| | |
|
| | | // 处理9.9包邮
|
| | | if (listArc != null && VersionUtil.greaterThan_1_5_50(acceptData.getPlatform(), acceptData.getVersion())
|
| | | && !Constant.IS_TEST)
|
| | | if (listArc != null && VersionUtil.greaterThan_1_5_50(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | for (Special s : listArc) {
|
| | | if (s.getName().contains("9.9")) {// 9块9
|
| | | s.setJumpDetail(jumpDetailV2Service.getByTypeCache("common_template"));
|
| | |
| | | params.put("key", CommonContentTypeEnum._9k9.name());
|
| | | params.put("title", CommonContentTypeEnum._9k9.getDesc());
|
| | | s.setParams(params.toString());
|
| | | } else if (s.getName().contains("自购立减")) {
|
| | | if (hour < 6) {// 0-6点之间不进入自购立减的页面
|
| | | s.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
|
| | | JSONObject params = new JSONObject();
|
| | | params.put("url", configService.get("tlj_own_buy_nogoods"));
|
| | | s.setParams(params.toString());
|
| | | } else {
|
| | | // 查询专题详情
|
| | | Special special = specialMapper.selectByPrimaryKey(s.getId());
|
| | | s.setJumpDetail(special.getJumpDetail());
|
| | | s.setParams(special.getParams());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) {
|
| | | // 如果IOS当前版本处于审核状态就不返回
|
| | | } else {
|
| | | listActivity = specialMapper.listByPlaceKey("index_activity", null);
|
| | | listActivity = specialMapper.listByPlaceKey("index_activity", null, platformCode, version);
|
| | | }
|
| | |
|
| | | if (listActivity == null) {
|
| | |
| | | indexBlock = "index_block_1.5.6";
|
| | |
|
| | | JSONObject blockJsonMap = new JSONObject();
|
| | | List<Special> listBlock = specialMapper.listByPlaceKey(indexBlock, sex);
|
| | | List<Special> listBlock = specialMapper.listByPlaceKey(indexBlock, sex, platformCode, version);
|
| | | if (listBlock == null) {
|
| | | listBlock = new ArrayList<Special>();
|
| | | } else if (listBlock.size() > 0) {
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Special> listByPlaceKey(String placeKey) {
|
| | | return specialMapper.listByPlaceKey(placeKey, null);
|
| | | public List<Special> listByPlaceKey(String placeKey, Integer platform, Integer versionCode) {
|
| | | return specialMapper.listByPlaceKey(placeKey, null, platform, versionCode);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public List<Special> listByPlaceKeyList(long start, int count, List<String> list, Integer platform, Integer versionCode) {
|
| | | return specialMapper.listByPlaceKeyList(start, count, list, null, platform, versionCode);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public long countByPlaceKeyList(List<String> list, Integer platform, Integer versionCode) {
|
| | | return specialMapper.countByPlaceKeyList(list, null, platform, versionCode);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | @Cacheable(value = "specialCache", key = "'listByPlaceKeyHasLabel'+#start+'-'+#platform+'-'+#versionCode+'-'+#list")
|
| | | public List<Special> listByPlaceKeyHasLabel(long start, int count, List<String> list, Integer platform, Integer versionCode) {
|
| | | return specialMapper.listByPlaceKeyHasLabel(start, count, list, null, platform, versionCode);
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 处理 数据
|