| | |
| | |
|
| | | import java.io.InputStream;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.UUID;
|
| | |
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | | import sun.security.krb5.internal.ccache.CCacheInputStream;
|
| | |
|
| | | @Service
|
| | | public class SpecialServiceImpl implements SpecialService {
|
| | |
| | | String name = record.getName();
|
| | | if (name == null || name.trim().length() == 0) {
|
| | | throw new SpecialException(1, "专题名称不能为空");
|
| | | }
|
| | |
|
| | | Integer sex = record.getSex();
|
| | | if (sex == null) {
|
| | | throw new SpecialException(1, "性别不能为空");
|
| | | }
|
| | |
|
| | | String params = record.getParams();
|
| | |
| | | record.setPicture(picture);
|
| | | record.setSubPicture(subPicture);
|
| | |
|
| | | int maxOrder = specialMapper.getMaxOrderByCard(cardId);
|
| | | record.setOrderby(maxOrder + 1);
|
| | | // 排序
|
| | | record.setOrderby(specialMapper.getDefaultMaxOrder(cardId) + 1);
|
| | | record.setOrderMan(specialMapper.getManMaxOrder(cardId) + 1);
|
| | | record.setOrderWoman(specialMapper.getWomanMaxOrder(cardId) + 1);
|
| | |
|
| | | record.setCreatetime(new Date());
|
| | | record.setUpdatetime(new Date());
|
| | | specialMapper.insert(record);
|
| | |
|
| | | Special s = new Special();
|
| | | s.setId(record.getId());
|
| | | s.setOrderby(Integer.parseInt(s.getId() + ""));
|
| | | s.setOrderMan(Integer.parseInt(s.getId() + ""));
|
| | | s.setOrderWoman(Integer.parseInt(s.getId() + ""));
|
| | | specialMapper.updateByPrimaryKeySelective(s);
|
| | | } else {
|
| | | // 修改
|
| | | Special resultObj = specialMapper.selectByPrimaryKey(id);
|
| | |
| | | }
|
| | |
|
| | | record.setOrderby(resultObj.getOrderby());
|
| | | record.setOrderMan(resultObj.getOrderMan());
|
| | | record.setOrderWoman(resultObj.getOrderWoman());
|
| | | record.setCreatetime(resultObj.getCreatetime());
|
| | |
|
| | | record.setUpdatetime(new Date());
|
| | | specialMapper.updateByPrimaryKey(record);
|
| | | }
|
| | |
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public void updateOrder(Long id, Integer moveType) throws SpecialException {
|
| | | public void updateOrder(Long id, Integer moveType, Integer sex) throws SpecialException {
|
| | |
|
| | | if (id == null || moveType == null || (!moveType.equals(1) && !moveType.equals(-1))) {
|
| | | if (id == null || moveType == null || (!moveType.equals(1) && !moveType.equals(-1)) || sex == null) {
|
| | | throw new SpecialException(1, "请传递正确参数");
|
| | | }
|
| | |
|
| | |
| | | throw new SpecialException(1, "此内容已不存在");
|
| | | }
|
| | |
|
| | | Integer order = resultObj.getOrderby();
|
| | | Long cardId = resultObj.getCardId();
|
| | |
|
| | | // 获取交换对象
|
| | | Special exchangeObject = specialMapper.getOrderByCardID(cardId, moveType, order);
|
| | | if (exchangeObject == null) {
|
| | | if (moveType == 1) {
|
| | | throw new SpecialException(1, "在相同使用地方中优先级已经最低了");
|
| | | } else {
|
| | | throw new SpecialException(1, "在相同使用地方中优先级已经最高了");
|
| | | Special exchangeObject = null;
|
| | | if (Special.SEX_ALL == sex || Special.SEX_DEFAULT == sex) {
|
| | | Integer orderby = resultObj.getOrderby();
|
| | | exchangeObject = specialMapper.getOrderByCardID(cardId, moveType, orderby, sex);
|
| | | if (exchangeObject == null) {
|
| | | throw new SpecialException(1, "没有找到可交换的位置");
|
| | | }
|
| | | }
|
| | |
|
| | | resultObj.setOrderby(exchangeObject.getOrderby());
|
| | | exchangeObject.setOrderby(order);
|
| | | resultObj.setOrderby(exchangeObject.getOrderby());
|
| | | exchangeObject.setOrderby(orderby);
|
| | | } else if (Special.SEX_MAN == sex) {
|
| | | Integer orderMan = resultObj.getOrderMan();
|
| | | exchangeObject = specialMapper.getOrderByCardID(cardId, moveType, orderMan, sex);
|
| | | if (exchangeObject == null) {
|
| | | throw new SpecialException(1, "没有找到可交换的位置");
|
| | | }
|
| | |
|
| | | resultObj.setOrderMan(exchangeObject.getOrderMan());
|
| | | exchangeObject.setOrderMan(orderMan);
|
| | | } else if (Special.SEX_WOMAN == sex) {
|
| | | Integer orderWoman = resultObj.getOrderWoman();
|
| | | exchangeObject = specialMapper.getOrderByCardID(cardId, moveType, orderWoman, sex);
|
| | |
|
| | | if (exchangeObject == null) {
|
| | | throw new SpecialException(1, "没有找到可交换的位置");
|
| | | }
|
| | |
|
| | | resultObj.setOrderWoman(exchangeObject.getOrderWoman());
|
| | | exchangeObject.setOrderWoman(orderWoman);
|
| | | } else {
|
| | | throw new SpecialException(1, "sex参数不正确");
|
| | | }
|
| | |
|
| | | specialMapper.updateByPrimaryKey(resultObj);
|
| | | specialMapper.updateByPrimaryKey(exchangeObject);
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Special> listQueryByCard(long start, int count, Long card, String key) {
|
| | | public List<Special> listQueryByCard(long start, int count, Long card, String key, Integer sex) {
|
| | |
|
| | | List<Special> list = specialMapper.listQueryByCard(start, count, card, key);
|
| | | List<Special> list = specialMapper.listQueryByCard(start, count, card, key, sex);
|
| | | if (list == null || list.size() == 0) {
|
| | | return list;
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public long countlistQueryByCard(Long card, String key) {
|
| | | return specialMapper.countlistQueryByCard(card, key);
|
| | | public long countlistQueryByCard(Long card, String key, Integer sex) {
|
| | | return specialMapper.countlistQueryByCard(card, key, sex);
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Cacheable(value = "configCache", key = "'listBySystemAndCard-'+#card+'-'+#systemId")
|
| | | @Cacheable(value = "specialCache", key = "'listBySystemAndCard-'+#card+'-'+#systemId")
|
| | | public List<Special> listBySystemAndCard(String card, Long systemId) {
|
| | | return specialMapper.listBySystemAndCard(card, systemId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Cacheable(value = "configCache", key = "'listPageBySystemAndCard-'+#start+'-'+#count+'-'+#card+'-'+#systemId")
|
| | | @Cacheable(value = "specialCache", key = "'listPageBySystemAndCard-'+#start+'-'+#count+'-'+#card+'-'+#systemId")
|
| | | public List<Special> listPageBySystemAndCard(long start, int count, String card, Long systemId) {
|
| | | return specialMapper.listPageBySystemAndCard(start, count, card, systemId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Cacheable(value = "configCache", key = "'listCacheSpecialToIndex'+#acceptData.platform+'-'+#acceptData.version")
|
| | | public JSONObject listCacheSpecialToIndex(AcceptData acceptData) throws Exception {
|
| | | @Cacheable(value = "specialCache", key = "'listCacheSpecialToIndex'+#acceptData.platform+'-'+#acceptData.version+'-'+#sex")
|
| | | public JSONObject listCacheSpecialToIndex(AcceptData acceptData, Integer sex) throws Exception {
|
| | |
|
| | | // 首页-5圆形2排区域
|
| | | JSONObject arcMap = new JSONObject();
|
| | | List<Special> listArc = specialMapper.listByPlaceKey("index_arc");
|
| | |
|
| | | String indexArc = "index_arc";
|
| | | 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);
|
| | | 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 {
|
| | | s.setJumpDetail(jumpDetailV2Service.getByTypeCache("tlj_own_buy"));
|
| | | s.setParams(null);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) {
|
| | | // 如果IOS当前版本处于审核状态就不返回
|
| | | } else {
|
| | | listActivity = specialMapper.listByPlaceKey("index_activity");
|
| | | listActivity = specialMapper.listByPlaceKey("index_activity", null);
|
| | | }
|
| | |
|
| | | if (listActivity == null) {
|
| | |
| | | activityMap.put("list", JsonUtil.getApiCommonGson().toJson(listActivity));
|
| | |
|
| | | // 首页-方形专题(品牌券、母婴...)
|
| | | String indexBlock = "index_block";
|
| | | if (VersionUtil.greaterThan_1_5_60(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | indexBlock = "index_block_1.5.6";
|
| | |
|
| | | JSONObject blockJsonMap = new JSONObject();
|
| | | List<Special> listBlock = specialMapper.listByPlaceKey("index_block");
|
| | | List<Special> listBlock = specialMapper.listByPlaceKey(indexBlock, sex);
|
| | | if (listBlock == null) {
|
| | | listBlock = new ArrayList<Special>();
|
| | | } else if (listBlock.size() > 0) {
|
| | |
| | |
|
| | | @Override
|
| | | public List<Special> listByPlaceKey(String placeKey) {
|
| | | return specialMapper.listByPlaceKey(placeKey);
|
| | | return specialMapper.listByPlaceKey(placeKey, null);
|
| | | }
|
| | |
|
| | | /**
|