Commit ef4f04d0 authored by hezhen's avatar hezhen

Merge branch 'dev' into hz_dev

parents cf6dedc5 91fd84dc
......@@ -234,4 +234,14 @@ public class AuthController {
return JsonResultUtil.createSuccessResultWithObj(authService.loginImiWithToken());
}
/**
* 检查token是否失效
* @param token
* @return
*/
@RequestMapping(value = "checkToken", method = RequestMethod.GET)
public ObjectRestResponse checkToken(String token){
return authService.checkToken(token);
}
}
......@@ -37,4 +37,6 @@ public interface AuthService {
JSONObject appletRegistry(String username,String headimgurl,String nickname,Integer userid);
String loginImiWithToken();
ObjectRestResponse checkToken(String token);
}
......@@ -3,6 +3,7 @@ package com.github.wxiaoqi.security.auth.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.api.vo.user.AppUserInfo;
import com.github.wxiaoqi.security.api.vo.user.UserInfo;
import com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo;
import com.github.wxiaoqi.security.auth.common.util.jwt.JWTInfo;
import com.github.wxiaoqi.security.auth.feign.IUserService;
import com.github.wxiaoqi.security.auth.service.AuthService;
......@@ -11,6 +12,7 @@ import com.github.wxiaoqi.security.auth.util.user.JwtTokenUtil;
import com.github.wxiaoqi.security.common.constant.RequestTypeConstants;
import com.github.wxiaoqi.security.common.exception.auth.UserInvalidException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
......@@ -117,4 +119,22 @@ public class AppAuthServiceImpl implements AuthService {
return userService.loginImiWithToken();
}
@Override
public ObjectRestResponse checkToken(String token) {
try {
if (StringUtils.isEmpty(token)){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE,"参数不能为空");
}
IJWTInfo ijwtInfo=jwtTokenUtil.getInfoFromToken(token);
if (ijwtInfo==null){
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE,"token失效");
}
return ObjectRestResponse.succ();
}catch (Exception e){
e.printStackTrace();
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE,"token失效");
}
}
}
......@@ -2,6 +2,7 @@ package com.github.wxiaoqi.security.auth.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.api.vo.user.UserInfo;
import com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo;
import com.github.wxiaoqi.security.auth.common.util.jwt.JWTInfo;
import com.github.wxiaoqi.security.auth.feign.IUserService;
import com.github.wxiaoqi.security.auth.service.AuthService;
......@@ -10,6 +11,7 @@ import com.github.wxiaoqi.security.auth.util.user.JwtTokenUtil;
import com.github.wxiaoqi.security.common.constant.RequestTypeConstants;
import com.github.wxiaoqi.security.common.exception.auth.UserInvalidException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
......@@ -113,4 +115,22 @@ public class AuthServiceImpl implements AuthService {
public String loginImiWithToken() {
return userService.loginImiWithToken();
}
@Override
public ObjectRestResponse checkToken(String token) {
try {
if (StringUtils.isEmpty(token)){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE,"参数不能为空");
}
IJWTInfo ijwtInfo=jwtTokenUtil.getInfoFromToken(token);
if (ijwtInfo==null){
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE,"token失效");
}
return ObjectRestResponse.succ();
}catch (Exception e){
e.printStackTrace();
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE,"token失效");
}
}
}
......@@ -40,8 +40,8 @@ public class RandomUtil
* @param n
* @param set
*/
public static void randomSet(int max, int n, Set<Integer> set) {
if (n > (max + 1) || max < 0) {
public static void randomSet(int max, int n, Set<Integer> set, int total) {
if (n > (max) || max < 0) {
return;
}
for (int i = 0; i < n; i++) {
......@@ -50,8 +50,8 @@ public class RandomUtil
}
int setSize = set.size();
// 如果存入的数小于指定生成的个数,则调用递归再生成剩余个数的随机数,如此循环,直到达到指定大小
if (setSize < n) {
randomSet( max, n-setSize, set);// 递归
if (setSize < total) {
randomSet(max, total - setSize, set, total);// 递归
}
}
......@@ -63,9 +63,9 @@ public class RandomUtil
public static void main(String[] args) {
int max = 20;
int n = 5;
int n = 20;
Set<Integer> set = new HashSet<>();
randomSet(max, n, set);
randomSet(max, n, set, n);
for(Integer a : set) {
System.out.println(a);
}
......
......@@ -16,7 +16,7 @@ spring:
cloud:
nacos:
config:
server-addr: 127.0.0.1:8848,10.1.37.166:8848
server-addr: 127.0.0.1:8848
#共用配置,暂定一个
shared-dataids: common-dev.yaml,mongodb-log-dev.yaml
---
......
......@@ -102,7 +102,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>0.2.1.RELEASE</version>
<version>0.2.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
......
......@@ -6,7 +6,6 @@
<groupId>com.xxfc.common</groupId>
<artifactId>xx-common-platform-web</artifactId>
<version>2.0-SNAPSHOT</version>
<relativePath>../../xx-common/xx-common-platform-web/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxfc.platform</groupId>
......
......@@ -105,4 +105,9 @@ public class Banner {
* 位置 banner位置0 所有 1:推荐 2:拍拍 3:短视频 4:问答
*/
private Integer location;
/**
* 平台 0:APP 1:欣欣房车官网 2:滴房车官网
*/
private Integer platform;
}
......@@ -19,6 +19,9 @@ public interface ConfigFeign {
*/
public static final int TYPE_CUS_SER = 400;
//旅游提前天数
public static final int TYPE_TOUR_DAYS=99;
@RequestMapping(value = "/cofig/app/unauth/types",method = RequestMethod.GET)
ObjectRestResponse<List<Cofig>> getAllByType(@RequestParam("types") String types);
......
......@@ -6,7 +6,6 @@
<groupId>com.xxfc.common</groupId>
<artifactId>xx-common-platform-web</artifactId>
<version>2.0-SNAPSHOT</version>
<relativePath>../../xx-common/xx-common-platform-web/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxfc.platform</groupId>
......
......@@ -21,20 +21,9 @@ import java.util.List;
@Service
public class BannerBiz extends BaseBiz<BannerMapper,Banner> {
/* @CacheClear(key = RedisKey.CONSTANT_CODE_PREFIX_BANNER)
public void update(Banner banner) {
this.updateSelectiveById(banner);
}
@CacheClear(key = RedisKey.CONSTANT_CODE_PREFIX_BANNER)
public void remove(int id) {
this.deleteById(id);
}*/
public List<BannerVo> findBannerList(Integer type,Integer location) {
public List<BannerVo> findBannerList(Integer type,Integer location,Integer platform) {
List<BannerVo> bannerVos = new ArrayList<>();
List<Banner> banners = mapper.findBannerListByType(type,location);
List<Banner> banners = mapper.findBannerListByType(type,location,platform);
banners.forEach(banner -> {
BannerVo bannerVo = new BannerVo();
bannerVo.setCover(banner.getCover());
......@@ -46,30 +35,14 @@ public class BannerBiz extends BaseBiz<BannerMapper,Banner> {
return bannerVos;
}
/*
*/
/**
* 更改banner信息
* @param banner
* @param userInfo
* @return
*//*
public int update(Banner banner, UserDTO userInfo) {
banner.setUpdName(userInfo.getUsername());
banner.setUpdTime(Instant.now().toEpochMilli());
return mapper.updateByPrimaryKeySelective(banner);
}
*/
/**
* 分页查询banner
* @param pageNo
* @param pageSize
* @return
*/
public PageDataVO<Banner> findBannePage(Integer pageNo, Integer pageSize) {
return PageDataVO.pageInfo(pageNo, pageSize, () -> mapper.findBannerListByisDelOrderByRank(Banner.builder().isDel(0).build()));
public PageDataVO<Banner> findBannePage(Integer pageNo, Integer pageSize,Integer platform) {
return PageDataVO.pageInfo(pageNo, pageSize, () -> mapper.findBannerListByisDelOrderByRank(Banner.builder().isDel(0).platform(platform).build()));
}
/**
......
......@@ -19,10 +19,10 @@ import java.util.List;
@Repository
public interface BannerMapper extends Mapper<Banner> {
@Select("select * from `banner` where is_del=#{isDel} order by rank ASC")
@Select("select * from `banner` where is_del=#{isDel} and `platform`=#{platform} order by rank ASC")
List<Banner> findBannerListByisDelOrderByRank(Banner banner);
List<Banner> findBannerListByType(@Param("type") Integer type,@Param("location") Integer location);
List<Banner> findBannerListByType(@Param("type") Integer type,@Param("location") Integer location,@Param("platform") Integer platform);
}
......@@ -21,19 +21,22 @@ import java.util.List;
@RequestMapping("/banner")
public class BannerController {
@Autowired
private BannerBiz bannerBiz;
@Autowired
private BannerBiz bannerBiz;
/**
*查询banner图
* 查询banner图
*
* @return
*/
@GetMapping("/app/unauth/findBannerlist")
public ObjectRestResponse findBannerlist(@RequestParam("type") Integer type,@RequestParam(required = false,value = "location") Integer location){
if (type==null) {
public ObjectRestResponse findBannerlist(@RequestParam(value = "type") Integer type,
@RequestParam(required = false, value = "location") Integer location,
@RequestParam(value = "platform",required = false,defaultValue = "0") Integer platform) {
if (type == null) {
return ObjectRestResponse.createDefaultFail();
}
List<BannerVo> bannerList = bannerBiz.findBannerList(type,location);
return ObjectRestResponse.succ(bannerList);
List<BannerVo> bannerList = bannerBiz.findBannerList(type, location,platform);
return ObjectRestResponse.succ(bannerList);
}
}
......@@ -21,22 +21,23 @@ import org.springframework.web.bind.annotation.*;
*/
@RestController
@RequestMapping("/admin/banner")
@Api(value = "banner后台接口",tags = "banner后台接口")
@Api(value = "banner后台接口", tags = "banner后台接口")
public class BannerAdminController {
@Autowired
private BannerBiz bannerBiz;
@Autowired
private BannerBiz bannerBiz;
/**
* 修改
*
* @param banner
* @return
*/
@PutMapping
@ApiOperation(value = "banner修改",notes = "修改")
public ObjectRestResponse<Banner> update(@RequestBody Banner banner, UserDTO userInfo){
int effectRows = bannerBiz.save(banner,userInfo);
if (effectRows>0){
@ApiOperation(value = "banner修改", notes = "修改")
public ObjectRestResponse<Banner> update(@RequestBody Banner banner, UserDTO userInfo) {
int effectRows = bannerBiz.save(banner, userInfo);
if (effectRows > 0) {
return ObjectRestResponse.succ();
}
return ObjectRestResponse.createDefaultFail();
......@@ -44,47 +45,51 @@ public class BannerAdminController {
/**
* 根据id查询banner
*
* @param id
* @return
*/
@GetMapping("/{id}")
@ApiOperation(value = "根据id查询banner图",notes = "根据id查询banner图")
public ObjectRestResponse<Banner> findBannerById(@PathVariable Integer id){
@ApiOperation(value = "根据id查询banner图", notes = "根据id查询banner图")
public ObjectRestResponse<Banner> findBannerById(@PathVariable Integer id) {
Banner Banner = bannerBiz.selectById(id);
return ObjectRestResponse.succ(Banner);
}
/**
* 分页查询banner
*
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("/page")
@ApiOperation(value = "banner分页查询",notes = "banner分页查询")
@ApiOperation(value = "banner分页查询", notes = "banner分页查询")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "pageNo",paramType = "query",required = false,dataType = "integer",defaultValue = "0"),
@ApiImplicitParam(name = "pageSize",paramType = "query",required = false,dataType = "integer",defaultValue = "10")
@ApiImplicitParam(name = "pageNo", paramType = "query", required = false, dataType = "integer", defaultValue = "0"),
@ApiImplicitParam(name = "pageSize", paramType = "query", required = false, dataType = "integer", defaultValue = "10")
})
public ObjectRestResponse<PageDataVO> findBannerPage(@RequestParam(name = "pageNo",defaultValue = "0",required = false) Integer pageNo,
@RequestParam(name = "pageSize",defaultValue = "10",required = false) Integer pageSize){
public ObjectRestResponse<PageDataVO> findBannerPage(@RequestParam(name = "pageNo", defaultValue = "0", required = false) Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10", required = false) Integer pageSize,
@RequestParam(name = "platform", defaultValue = "0", required = false) Integer platform) {
PageDataVO<Banner> pageDataVO = bannerBiz.findBannePage(pageNo,pageSize);
PageDataVO<Banner> pageDataVO = bannerBiz.findBannePage(pageNo, pageSize, platform);
return ObjectRestResponse.succ(pageDataVO);
}
/**
* 保存banner
*
* @param banner
* @return
*/
@ApiOperation(value = "banner保存",notes = "banner保存")
@ApiOperation(value = "banner保存", notes = "banner保存")
@PostMapping
public ObjectRestResponse<Void> saveBanner(@RequestBody Banner banner,UserDTO userDTO){
public ObjectRestResponse<Void> saveBanner(@RequestBody Banner banner, UserDTO userDTO) {
banner.setIsDel(0);
int effectRows = bannerBiz.save(banner,userDTO);
if (effectRows>0){
int effectRows = bannerBiz.save(banner, userDTO);
if (effectRows > 0) {
return ObjectRestResponse.succ();
}
return ObjectRestResponse.createDefaultFail();
......@@ -93,14 +98,15 @@ public class BannerAdminController {
/**
* 逻辑删除
*
* @param id
* @return
*/
@DeleteMapping("/{id}")
@ApiOperation(value = "banner逻辑删除",notes = "banner逻辑删除")
public ObjectRestResponse<Void> deleteBannerById(@PathVariable Integer id,UserDTO userDTO){
int effectRows = bannerBiz.updateBannerStatus(id,1,userDTO);
if (effectRows>0){
@ApiOperation(value = "banner逻辑删除", notes = "banner逻辑删除")
public ObjectRestResponse<Void> deleteBannerById(@PathVariable Integer id, UserDTO userDTO) {
int effectRows = bannerBiz.updateBannerStatus(id, 1, userDTO);
if (effectRows > 0) {
return ObjectRestResponse.succ();
}
return ObjectRestResponse.createDefaultFail();
......@@ -108,11 +114,12 @@ public class BannerAdminController {
/**
* 真实删除
*
* @param id
* @return
*/
@DeleteMapping("/del/{id}")
public ObjectRestResponse<Void> deleteReallyBannerById(@PathVariable(value = "id") Integer id){
public ObjectRestResponse<Void> deleteReallyBannerById(@PathVariable(value = "id") Integer id) {
bannerBiz.deleteById(id);
return ObjectRestResponse.succ();
}
......
......@@ -15,6 +15,7 @@
<result property="url" column="url"/>
<result property="isDel" column="is_del"/>
<result property="location" column="location"/>
<result property="platform" column="platform"/>
</resultMap>
<select id="findBannerListByType" resultMap="bannerMap">
......@@ -22,6 +23,9 @@
<if test="location != null">
and `location`=#{location}
</if>
<if test="platform != null">
and `platform`=#{platform}
</if>
order by rank asc
</select>
</mapper>
\ No newline at end of file
......@@ -6,7 +6,6 @@
<groupId>com.xxfc.common</groupId>
<artifactId>xx-common-platform</artifactId>
<version>2.0-SNAPSHOT</version>
<relativePath>../../xx-common/xx-common-platform/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxfc.platform</groupId>
......
......@@ -3,6 +3,9 @@ package com.xxfc.platform.campsite.feign;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.GoodDataVO;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.campsite.vo.CampsiteShopDetailVo;
import com.xxfc.platform.campsite.vo.CampsiteShopPageVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -14,13 +17,31 @@ import java.util.List;
* Created by ace on 2017/9/15.
*/
//@FeignClient(value = "${auth.serviceId}",configuration = {})
@FeignClient("xx-campsite")
@FeignClient(name = "xx-campsite",path = "/campsiteShop")
public interface CampsiteFeign {
@ApiOperation("首页营地列表")
@GetMapping(value = "/campsiteShop/app/shopList")
public List<GoodDataVO> goodList(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit",defaultValue = "4") Integer limit);
@GetMapping(value = "/campsiteShop/app/unauth/findRandomVehicle")
public ObjectRestResponse findRandomVehicle(@RequestParam(value = "number")Integer number);
@GetMapping(value = "/app/shopList")
List<GoodDataVO> goodList(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit", defaultValue = "4") Integer limit);
@GetMapping(value = "/app/unauth/findRandomVehicle")
ObjectRestResponse findRandomVehicle(@RequestParam(value = "number") Integer number);
@ApiOperation("分页查询营地列表")
@GetMapping("/app/unauth/shops")
ObjectRestResponse<PageDataVO<CampsiteShopPageVo>> findCampsiteShopPageByType(@RequestParam(value = "type", required = false) Integer type,
@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", required = false, defaultValue = "6") Integer pageSize);
/**
* @param longitude 经度
* @param latitude 纬度
* @return
*/
@ApiOperation("查询营地详情")
@GetMapping("/app/unauth/shop")
ObjectRestResponse<CampsiteShopDetailVo> findCampsiteShopDetailById(@RequestParam(value = "id") Integer id,
@RequestParam(value = "longitude", required = false) Double longitude,
@RequestParam(value = "latitude", required = false) Double latitude);
}
......@@ -6,7 +6,6 @@
<groupId>com.xxfc.common</groupId>
<artifactId>xx-common-platform-web</artifactId>
<version>2.0-SNAPSHOT</version>
<relativePath>../../xx-common/xx-common-platform-web/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxfc.platform</groupId>
......
......@@ -164,12 +164,14 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper, CampsiteShop> {
}
campsiteShopDetailVo.setTypeNames(shopTagDTOS == null ? Collections.EMPTY_LIST : shopTagDTOS.stream().map(CampsiteShopTagDTO::getName).collect(Collectors.toList()));
//根据经纬度算距离
if (campsiteShopDetailDTO.getLongitude() != null && campsiteShopDetailDTO.getLatitude() != null) {
double distance = getDistance(campsiteShopDetailDTO.getLongitude(), campsiteShopDetailDTO.getLatitude(), longitude, latitude);
if (log.isDebugEnabled()) {
log.debug("根据店铺经度=【{}】,纬度=【{}】和自己所在位置的经度=【{}】,纬度=【{}】计算出的距离:【{}km】", campsiteShopDetailDTO.getLongitude(), campsiteShopDetailDTO.getLatitude(), longitude, latitude, distance);
if(Objects.nonNull(latitude) && Objects.nonNull(longitude)) {
if (campsiteShopDetailDTO.getLongitude() != null && campsiteShopDetailDTO.getLatitude() != null) {
double distance = getDistance(campsiteShopDetailDTO.getLongitude(), campsiteShopDetailDTO.getLatitude(), longitude, latitude);
if (log.isDebugEnabled()) {
log.debug("根据店铺经度=【{}】,纬度=【{}】和自己所在位置的经度=【{}】,纬度=【{}】计算出的距离:【{}km】", campsiteShopDetailDTO.getLongitude(), campsiteShopDetailDTO.getLatitude(), longitude, latitude, distance);
}
campsiteShopDetailVo.setDistance(String.format("%.1f", distance));
}
campsiteShopDetailVo.setDistance(String.format("%.1f", distance));
}
campsiteValueOperations.set(String.format("%s%d", CAMSITE_DETAIL_CACHE_PREKEY, id), JSONObject.toJSONString(campsiteShopDetailVo));
return campsiteShopDetailVo;
......@@ -345,7 +347,7 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper, CampsiteShop> {
return ObjectRestResponse.succ(list);
}
Set<Integer> set = new HashSet<>();
RandomUtil.randomSet(list.size(), number, set);
RandomUtil.randomSet(list.size(), number, set, number);
for(Integer i : set) {
resultList.add(list.get(i));
}
......
......@@ -48,7 +48,9 @@ public class CampsiteShopController extends BaseController<CampsiteShopBiz, Camp
*/
@ApiOperation("查询营地详情")
@GetMapping("/app/unauth/shop")
public ObjectRestResponse<CampsiteShopDetailVo> findCampsiteShopDetailById(@RequestParam("id") Integer id, @RequestParam("longitude") Double longitude, @RequestParam("latitude") Double latitude) {
public ObjectRestResponse<CampsiteShopDetailVo> findCampsiteShopDetailById(@RequestParam(value = "id") Integer id,
@RequestParam(value = "longitude",required = false) Double longitude,
@RequestParam(value = "latitude",required = false) Double latitude) {
CampsiteShopDetailVo campsiteShopDetailVo = getBaseBiz().findCampsiteShopDetailById(id, longitude, latitude);
return ObjectRestResponse.succ(campsiteShopDetailVo);
}
......
......@@ -6,7 +6,6 @@
<artifactId>xx-common-platform-web</artifactId>
<groupId>com.xxfc.common</groupId>
<version>2.0-SNAPSHOT</version>
<relativePath>../../xx-common/xx-common-platform-web/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -145,7 +145,7 @@ public class OrderTourService extends AbstractOrderHandle<OrderTourDetailBiz, To
//扣減庫存
ObjectRestResponse<TourSpePriceVo> response = tourFeign.stock(bo.getSpePriceId(), bo.getTotalNumber(), TourFeign.STOCK_SUBTRACT);
if(!SYS_JSON_TRUE.equals(response.getStatus())) {
throw new BaseException(ResultCode.PARAM_EPIRE_CODE, Sets.newSet("库存不足"));
throw new BaseException(ResultCode.PARAM_EPIRE_CODE, Sets.newSet(response.getMessage()));
}
......
......@@ -7,6 +7,7 @@ import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.tour.dto.TourSpePriceDTO;
import com.xxfc.platform.tour.entity.TourGood;
import com.xxfc.platform.tour.entity.TourGoodVerification;
import com.xxfc.platform.tour.entity.TourTag;
import com.xxfc.platform.tour.entity.TourUser;
import com.xxfc.platform.tour.vo.TourGoodOrderFindVo;
import com.xxfc.platform.tour.vo.TourGoodOrderVo;
......@@ -107,4 +108,24 @@ public interface TourFeign {
@GetMapping(value = "/tourGood/app/unauth/findRandomVehicle")
public ObjectRestResponse findRandomVehicle(@RequestParam(value = "number")Integer number);
//查询旅游路线列表
@RequestMapping(value = "/gw/app/unauth/getGoodList", method = RequestMethod.GET)
ObjectRestResponse getGoodList(@RequestParam(value = "page",defaultValue = "1") Integer page,
@RequestParam(value = "limit",defaultValue = "10") Integer limit,
@RequestParam(value = "tagId", required = false) Integer tagId);
//获取公司详情
@GetMapping("/gw/app/unauth/detail/{id}")
ObjectRestResponse getOne(@PathVariable Integer id);
//首页旅游列表
@GetMapping(value = "/gw/app/shopList")
List<GoodDataVO> goodListAll(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit",defaultValue = "4") Integer limit);
//旅游标签列表
@GetMapping(value = "/gw/tagList")
List<TourTag> tagList(@RequestParam(value = "isHot",defaultValue = "0")Integer isHot);
}
......@@ -18,6 +18,13 @@
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.xxfc.platform</groupId>
<artifactId>xx-app-api</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
......
......@@ -338,7 +338,7 @@ public class TourGoodBiz extends BaseBiz<TourGoodMapper, TourGood> {
return ObjectRestResponse.succ(list);
}
Set<Integer> set = new HashSet<>();
RandomUtil.randomSet(list.size(), number, set);
RandomUtil.randomSet(list.size(), number, set, number);
for(Integer i : set) {
resultList.add(list.get(i));
}
......
......@@ -4,6 +4,8 @@ import com.github.wxiaoqi.security.admin.entity.BaseUserMemberLevel;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.app.entity.Cofig;
import com.xxfc.platform.app.feign.ConfigFeign;
import com.xxfc.platform.tour.dto.GoodBannerDTO;
import com.xxfc.platform.tour.dto.GoodTagDTO;
import com.xxfc.platform.tour.entity.TourGood;
......@@ -45,6 +47,8 @@ public class TourGoodDetailBiz extends BaseBiz<TourGoodMapper, TourGood> {
private UserFeign userFeign;
@Autowired
TourGoodBannerMapper bannerMapper;
@Autowired
ConfigFeign configFeign;
//获取商品详情
public ObjectRestResponse<TourGoodDetailVo> getGoodDetaileById(Integer id) {
......@@ -79,7 +83,7 @@ public class TourGoodDetailBiz extends BaseBiz<TourGoodMapper, TourGood> {
List<GoodBannerDTO> bannerList = bannerMapper.getBannerList(id);
detailVo.setBannerDTOS(bannerList);
//获取出行时间
List<TourDepartTimeVo> timelist = priceMapper.getAllByGoodId(id);
List<TourDepartTimeVo> timelist = priceMapper.getAllByGoodId(id,getTourDays());
detailVo.setTourDepartTimeVo(timelist);
Integer stock=priceMapper.getTotalStock(id);
detailVo.setStock(stock);
......@@ -109,7 +113,7 @@ public class TourGoodDetailBiz extends BaseBiz<TourGoodMapper, TourGood> {
BeanUtils.copyProperties(detailVo, TourGood);
BigDecimal price = detailVo.getPrice();
//获取出行时间
List<TourDepartTimeVo> timelist = priceMapper.getAllByGoodId(id);
List<TourDepartTimeVo> timelist = priceMapper.getAllByGoodId(id,getTourDays());
detailVo.setTourDepartTimeVo(timelist);
//获取出发地点
List<TourDepartVo> departList = siteMapper.getlistByGoodId(id);
......@@ -135,5 +139,19 @@ public class TourGoodDetailBiz extends BaseBiz<TourGoodMapper, TourGood> {
return selectById(id);
}
//获取旅游天数
public Integer getTourDays(){
try {
List<Cofig> list=configFeign.getAllByType(ConfigFeign.TYPE_TOUR_DAYS+"").getData();
if (list!=null && list.size()>0){
String params=list.get(0).getValue();
return Integer.parseInt(params);
}
}catch (Exception e){
e.printStackTrace();
}
return 0;
}
}
\ No newline at end of file
......@@ -11,11 +11,13 @@ import com.xxfc.platform.tour.mapper.TourGoodSpePriceMapper;
import com.xxfc.platform.tour.vo.TourSpePriceVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
......@@ -30,6 +32,9 @@ import java.util.List;
@Slf4j
public class TourGoodSpeBiz extends BaseBiz<TourGoodSpePriceMapper, TourGoodSpePrice> {
@Autowired
TourGoodDetailBiz goodDetailBiz;
public ObjectRestResponse<TourSpePriceVo> getPricesByuserid(TourSpePriceDTO priceDto) {
if (priceDto == null || priceDto.getUserId() == null || priceDto.getUserId() == 0 ||
priceDto.getNumber() == null || priceDto.getNumber() == 0||priceDto.getSpeId()==null) {
......@@ -89,6 +94,9 @@ public class TourGoodSpeBiz extends BaseBiz<TourGoodSpePriceMapper, TourGoodSpeP
TourGoodSpePrice spePrice = mapper.selectByPrimaryKey(speId);
if(type==1){
if (spePrice != null && spePrice.getStock() > 0 && spePrice.getStock() >= number) {
if (!checkTime(spePrice.getStartTime())){
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "该日期已超过系统限制");
}
mapper.updStockById(speId, number,type);
} else {
return ObjectRestResponse.createFailedResult(ResultCode.STOCK_CODE, "库存不足");
......@@ -109,4 +117,25 @@ public class TourGoodSpeBiz extends BaseBiz<TourGoodSpePriceMapper, TourGoodSpeP
TourGoodSpePrice spePrice = mapper.selectOne(tourGoodSpePrice);
return spePrice.getStartTime();
}
public boolean checkTime(Date startTime){
try {
Date endTime=new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
long startDateTime = dateFormat.parse(dateFormat.format(startTime)).getTime();
long endDateTime = dateFormat.parse(dateFormat.format(endTime)).getTime();
if (startDateTime<=endDateTime){
return false;
}
int days=(int)((startDateTime - endDateTime) / (1000 * 3600 * 24));
int tourDays=goodDetailBiz.getTourDays();
if (days>0&&days>=tourDays){
return true;
}
return false;
}catch (Exception e){
e.printStackTrace();
return false;
}
}
}
\ No newline at end of file
......@@ -49,6 +49,16 @@ public class TourTagBiz extends BaseBiz<TourTagMapper,TourTag> {
return mapper.findHotListTag(tag);
}
public List<TourTag> getTagList(Integer isHot) {
TourTag tag = new TourTag();
tag.setIsDel(0);
if (isHot!=null&&isHot==1){
tag.setIsHot(1);
return mapper.findHotListTag(tag);
}
return mapper.findAllByIsDel(tag);
}
public PageDataVO<TourTag> findPage(Map map) {
......
......@@ -16,7 +16,7 @@ import java.util.List;
*/
public interface TourGoodSpePriceMapper extends Mapper<TourGoodSpePrice> {
List<TourDepartTimeVo> getAllByGoodId(@Param("goodId") Integer goodId);
List<TourDepartTimeVo> getAllByGoodId(@Param("goodId") Integer goodId,Integer days);
//获取总库存
Integer getTotalStock(@Param("goodId") Integer goodId);
......
......@@ -2,6 +2,7 @@ package com.xxfc.platform.tour.rest;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.tour.biz.TourGoodSpeBiz;
import com.xxfc.platform.tour.common.TourBaseController;
import com.xxfc.platform.tour.dto.TourSpePriceDTO;
......@@ -31,7 +32,13 @@ public class TourGoodSpeController extends TourBaseController<TourGoodSpeBiz> {
@RequestParam(value = "number",defaultValue = "0") Integer number,
@RequestParam(value = "type",defaultValue = "1") Integer type
){
return baseBiz.cutStock(speId,number,type);
try {
return baseBiz.cutStock(speId,number,type);
}catch (Exception e){
e.printStackTrace();
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"网络异常,稍后重试");
}
}
@GetMapping("/departure_date")
......
package com.xxfc.platform.tour.rest;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.vo.GoodDataVO;
import com.xxfc.platform.tour.biz.TourGoodBiz;
import com.xxfc.platform.tour.biz.TourGoodDetailBiz;
import com.xxfc.platform.tour.biz.TourTagBiz;
import com.xxfc.platform.tour.entity.TourGood;
import com.xxfc.platform.tour.entity.TourTag;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("gw")
@IgnoreClientToken
@IgnoreUserToken
public class TourGwController extends BaseController<TourGoodBiz, TourGood> {
@Autowired
TourGoodDetailBiz goodDetailBiz;
@Autowired
TourTagBiz tourTagBiz;
/**
* 查询旅游路线列表
*
* @param page
* @param limit
* @param tagId
* @return
*/
@ApiOperation("查询旅游路线列表")
@RequestMapping(value = "/app/unauth/getGoodList", method = RequestMethod.GET)
public ObjectRestResponse getGoodList(@RequestParam(value = "page",defaultValue = "1") Integer page,
@RequestParam(value = "limit",defaultValue = "10") Integer limit,
@RequestParam(value = "tagId", required = false) Integer tagId) {
return baseBiz.getGoodList(page, limit, "", null, null, tagId, null);
}
@GetMapping("/app/unauth/detail/{id}")
public ObjectRestResponse getOne(@PathVariable Integer id) {
return goodDetailBiz.getGoodDetaileById(id);
}
@ApiOperation("首页旅游列表")
@GetMapping(value = "/shopList")
public List<GoodDataVO> goodListAll(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit",defaultValue = "4") Integer limit) {
return baseBiz.getAllByHome(page,limit);
}
@ApiOperation("旅游标签列表")
@GetMapping(value = "/tagList")
public List<TourTag> tagList(@RequestParam(value = "isHot",defaultValue = "0")Integer isHot) {
return tourTagBiz.getTagList(isHot);
}
}
\ No newline at end of file
......@@ -37,7 +37,7 @@
<!-- 获取出行时间 -->
<select id="getAllByGoodId" resultMap="tourDepartTimeVoMap">
SELECT id,good_id,DATE_FORMAT(start_time,'%Y-%m-%d') as start_time,DATE_FORMAT(end_time,'%Y-%m-%d') as end_time,spe_id,price,child_price,member_price,stock,
DATE_FORMAT(start_time,'%w') as startWeek,DATE_FORMAT(end_time,'%w') as endWeek,IF(IFNULL(DATEDIFF(start_time,NOW()),0)>0,'0','1') as overdue
DATE_FORMAT(start_time,'%w') as startWeek,DATE_FORMAT(end_time,'%w') as endWeek,IF(IFNULL(DATEDIFF(start_time,NOW()),0)>=#{days},'0','1') as overdue
FROM tour_good_spe_price WHERE good_id=#{goodId} and is_del=0 ORDER BY start_time
</select>
......
package com.xxfc.platform.uccn.comstnt;
/**
* 访问路径
* @author Administrator
*/
public enum UrlType {
OFFICIAL_WEBSITE("官网访问",1),BACKGROUND_MANAGEMENT("后台访问",2);
private String name;
private Integer code;
UrlType(String name, Integer code) {
this.name = name;
this.code = code;
}
public String getName() {
return name;
}
public Integer getCode() {
return code;
}
}
package com.xxfc.platform.uccn.dto;
import lombok.Data;
@Data
public class RandomListDto {
/**
* 列表类型 TypeEnum
*/
private Integer type;
/**
* 随机数量
*/
private Integer number;
/**
* 活动位置,1:欣欣官网 2:滴房车官网 0:无限制,
*/
private Integer location;
}
package com.xxfc.platform.uccn.dto;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/26 15:51
*/
public class SummitActivityDTO {
}
package com.xxfc.platform.uccn.dto;
import com.github.wxiaoqi.security.common.vo.PageParam;
import lombok.Data;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/26 18:55
*/
@Data
public class SummitActivityFindDTO extends PageParam {
private Long startTime;
private Long endTime;
private String title;
private Integer location;
}
package com.xxfc.platform.uccn.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/26 18:54
*/
@Data
public class SummitActivitySaveDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
@ApiModelProperty(value = "活动主标题")
private String title;
@ApiModelProperty(value = "副标题(不展示)")
private String subtitle;
@ApiModelProperty(value = "活动主图")
private String banner;
@ApiModelProperty(value = "开始时间")
private Long startTime;
@ApiModelProperty(value = "结束时间")
private Long endTime;
@ApiModelProperty(value = "报名截止时间(不展示)")
private Long regCloseTime;
@ApiModelProperty(value = "省编码")
private Integer provinceCode;
@ApiModelProperty(value = "省")
private String province;
@ApiModelProperty(value = "市编码")
private Integer cityCode;
@ApiModelProperty(value = "市")
private String city;
@ApiModelProperty(value = "县/镇 编码")
private Integer townCode;
@ApiModelProperty(value = "县/镇")
private String town;
@ApiModelProperty(value = "活动场地(地址格式)")
private String address;
@ApiModelProperty(value = "纬度(不展示)")
private BigDecimal latitude;
@ApiModelProperty(value = "经度 (不展示)")
private BigDecimal longitude;
@ApiModelProperty(value = "总人数")
private Integer limitNum;
@ApiModelProperty(value = "活动图文内容")
private String content;
@ApiModelProperty(value = "创建时间", hidden = true)
private Long crtTime;
@ApiModelProperty(value = "活动对象说明(不展示)")
private String actDesc;
@ApiModelProperty(value = "活动类型(保留,不展示)")
private Integer type;
@ApiModelProperty(value = "1:欣欣官网 2:滴房车官网 0:无限制")
private Integer location;
@ApiModelProperty(value = "排序")
private Integer rank;
}
......@@ -10,6 +10,7 @@ import tk.mybatis.mapper.annotation.KeySql;
import tk.mybatis.mapper.code.IdentityDialect;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
......@@ -26,6 +27,7 @@ public class Article {
@Id
@KeySql(dialect = IdentityDialect.MYSQL)
// @GeneratedValue(generator = "JDBC")
private Integer id;
/**
* 标题
......
......@@ -53,14 +53,14 @@ public class SummitActivity implements Serializable {
*/
@Column(name = "start_time")
@ApiModelProperty(value = "开始时间")
private Integer startTime;
private Long startTime;
/**
* 结束时间
*/
@Column(name = "end_time")
@ApiModelProperty(value = "结束时间")
private Integer endTime;
private Long endTime;
/**
* 报名截止时间(不展示)
......@@ -202,6 +202,10 @@ public class SummitActivity implements Serializable {
@ApiModelProperty(value = "创建时间", hidden = true)
private Long crtTime;
@Column(name = "upd_time")
@ApiModelProperty(value = "更新时间")
private Long updTime;
/**
* 活动对象说明(不展示)
*/
......
package com.xxfc.platform.uccn.vo;
import lombok.Data;
/**
* 新闻文章查询条件
* @author Administrator
*/
@Data
public class ArticleQuery {
private Integer page;
private Integer limit;
// private String newsContent;
}
package com.xxfc.platform.uccn.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/26 19:00
*/
@Data
public class SummitActivityAdminVo implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
@ApiModelProperty(value = "活动主标题")
private String title;
@ApiModelProperty(value = "副标题(不展示)")
private String subtitle;
@ApiModelProperty(value = "活动主图")
private String banner;
@ApiModelProperty(value = "开始时间")
private Long startTime;
@ApiModelProperty(value = "结束时间")
private Long endTime;
@ApiModelProperty(value = "报名截止时间(不展示)")
private Long regCloseTime;
@ApiModelProperty(value = "省编码")
private Integer provinceCode;
@ApiModelProperty(value = "省")
private String province;
@ApiModelProperty(value = "市编码")
private Integer cityCode;
@ApiModelProperty(value = "市")
private String city;
@ApiModelProperty(value = "县/镇 编码")
private Integer townCode;
@ApiModelProperty(value = "县/镇")
private String town;
@ApiModelProperty(value = "活动场地(地址格式)")
private String address;
@ApiModelProperty(value = "纬度(不展示)")
private BigDecimal latitude;
@ApiModelProperty(value = "经度 (不展示)")
private BigDecimal longitude;
@ApiModelProperty(value = "总人数")
private Integer limitNum;
@ApiModelProperty(value = "活动图文内容")
private String content;
@ApiModelProperty(value = "活动开关(0关,1开)")
private Integer isShow;
@ApiModelProperty(value = "报名开关(0开,1关)")
private Integer isOpenReg;
@ApiModelProperty(value = "删除(0正常,1删除)")
private Integer isDel;
@ApiModelProperty(value = "0是未发布,1是已发布")
private Integer isPublish;
@ApiModelProperty(value = "0是普通,1是置顶(首页展示)")
private Integer isHomePage;
@ApiModelProperty(value = "创建时间", hidden = true)
private Long crtTime;
@ApiModelProperty(value = "更新时间")
private Long updTime;
@ApiModelProperty(value = "活动对象说明(不展示)")
private String actDesc;
@ApiModelProperty(value = "活动类型(保留,不展示)")
private Integer type;
@ApiModelProperty(value = "报名人数(不展示)")
private Integer willNum;
@ApiModelProperty(value = "1:欣欣官网 2:滴房车官网 0:无限制")
private Integer location;
@ApiModelProperty(value = "排序")
private Integer rank;
}
......@@ -31,11 +31,11 @@ public class SummitActivityDetailVo implements Serializable {
@ApiModelProperty(value = "开始时间")
private Integer startTime;
private Long startTime;
@ApiModelProperty(value = "结束时间")
private Integer endTime;
private Long endTime;
@ApiModelProperty(value = "报名截止时间(不展示)")
......
......@@ -32,11 +32,11 @@ public class SummitActivityVo implements Serializable {
@ApiModelProperty(value = "开始时间")
private Integer startTime;
private Long startTime;
@ApiModelProperty(value = "结束时间")
private Integer endTime;
private Long endTime;
@ApiModelProperty(value = "省")
......
package com.xxfc.platform.uccn.vo;
import lombok.Data;
public enum TypeEnum {
VEHICLE(1, "车型"),
TOUR(2, "旅游"),
CAMPSITE(3, "营地"),
ACTIVITY(4, "活动");
private Integer code;
private String msg;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
TypeEnum(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
public static TypeEnum getByValue(Integer value){
for(TypeEnum typeEnum : values()){
if (typeEnum.getCode() == value) {
return typeEnum;
}
}
return null;
}
}
......@@ -18,12 +18,36 @@
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.wxiaoqi</groupId>
<artifactId>ace-admin-api</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
</dependency>
<dependency>
<groupId>com.xxfc.platform</groupId>
<artifactId>xx-vehicle-api</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.xxfc.platform</groupId>
<artifactId>xx-tour-api</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.xxfc.platform</groupId>
<artifactId>xx-campsite-api</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>xx-uccn</finalName>
<plugins>
<!-- 此插件用来生成通用mapper的代码 -->
<plugin>
......
......@@ -3,10 +3,12 @@ package com.xxfc.platform.uccn.biz;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.uccn.comstnt.UrlType;
import com.xxfc.platform.uccn.entity.Article;
import com.xxfc.platform.uccn.mapper.ArticleMapper;
import com.xxfc.platform.uccn.vo.ArticleQuery;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.weekend.WeekendSqls;
......@@ -21,16 +23,17 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
/**
* 随机文章条数
*/
private final Integer RANDOM_NUMBER=3;
private final Integer RANDOM_NUMBER = 3;
/**
* 首页文章条数
*/
private final Integer HOME_PAGE_NUMBER=4;
private final Integer HOME_PAGE_NUMBER = 4;
/**
* 文章列表
*
* @param page
* @param limit
* @param type
......@@ -43,24 +46,28 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
}
/**
* 获取一条数据
* 获取一条数据
*
* @param id
* @param urlType
* @return
*/
public Article getOne(Integer id) {
Example example = Example.builder(Article.class).where(
WeekendSqls.<Article>custom()
.andEqualTo(Article::getId,id)
.andEqualTo(Article::getIsDel, 0)
.andEqualTo(Article::getStatus, 1)
).build();
Article article = mapper.selectOneByExample(example);
return article;
public Article getOne(Integer id, Integer urlType) {
Example example = new Example(Article.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("id", id);
criteria.andEqualTo("isDel", 0);
if (UrlType.OFFICIAL_WEBSITE.getCode().equals(urlType)) {
criteria.andEqualTo("status", 1);
}
return mapper.selectOneByExample(example);
}
/**
* 随机获取三条连续的文章
*
* @param type
* @return
*/
......@@ -69,14 +76,14 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
List<Article> articleList = mapper.getArticleList(type);
if (!Objects.isNull(articleList)) {
int size = articleList.size();
if (RANDOM_NUMBER>=size) {
if (RANDOM_NUMBER >= size) {
return articleList;
}else {
} else {
Random random = new Random();
int r = random.nextInt(size -RANDOM_NUMBER+1);
int r = random.nextInt(size - RANDOM_NUMBER + 1);
List<Article> result = new ArrayList<>();
for (int i=0;i<RANDOM_NUMBER.intValue();i++){
int index= i+r;
for (int i = 0; i < RANDOM_NUMBER.intValue(); i++) {
int index = i + r;
result.add(articleList.get(index));
}
return result;
......@@ -88,20 +95,83 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
/**
* 首页文章列表
*
* @param type
* @return
*/
public List getHomePageArticle(Integer type){
public List getHomePageArticle(Integer type) {
List<Article> articleList = mapper.getArticleList(type);
if (Objects.isNull(articleList)) {
return new ArrayList();
}else {
if (articleList.size()>HOME_PAGE_NUMBER) {
return articleList.subList(0,HOME_PAGE_NUMBER);
}else {
} else {
if (articleList.size() > HOME_PAGE_NUMBER) {
return articleList.subList(0, HOME_PAGE_NUMBER);
} else {
return articleList;
}
}
}
@Transactional(rollbackFor = Exception.class)
public void add(Article article) {
if (article == null) {
return;
}
article.setIsDel(0);
if (article.getStatus() == null) {
article.setStatus(0);
}
if (article.getType() == null) {
article.setType(0);
}
article.setCreTime(new Date());
mapper.insertSelective(article);
}
public PageInfo findAll(ArticleQuery query) {
PageHelper.startPage(query.getPage(),query.getLimit());
Example exa = Example.builder(Article.class).where(
WeekendSqls.<Article>custom()
.andEqualTo(Article::getIsDel,0)
).orderByAsc("weight").orderByDesc("addTime").build();
List<Article> articles = mapper.selectByExample(exa);
return PageInfo.of(articles);
}
@Override
@Transactional(rollbackFor = Exception.class)
public int updateSelectiveByIdRe(Article article){
article.setUpdTime(new Date());
return mapper.updateByPrimaryKeySelective(article);
}
public int putaway(Integer id) {
Article article = new Article();
article.setId(id);
article.setUpdTime(new Date());
article.setAddTime(new Date());
article.setStatus(1);
return mapper.updateByPrimaryKeySelective(article);
}
public int soldOut(Integer id) {
Article article = new Article();
article.setId(id);
article.setUpdTime(new Date());
article.setStatus(0);
return mapper.updateByPrimaryKeySelective(article);
}
public int remove(Integer id) {
Article article = new Article();
article.setId(id);
article.setUpdTime(new Date());
article.setIsDel(1);
return mapper.updateByPrimaryKeySelective(article);
}
}
package com.xxfc.platform.uccn.biz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.campsite.feign.CampsiteFeign;
import com.xxfc.platform.tour.feign.TourFeign;
import com.xxfc.platform.uccn.vo.TypeEnum;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 获取随机数量的车型、旅游、营地、活动
*/
@Service
@Slf4j
public class RandomListBiz {
@Autowired
VehicleFeign vehicleFeign;
@Autowired
TourFeign tourFeign;
@Autowired
CampsiteFeign campsiteFeign;
@Autowired
SummitActivityBiz summitActivityBiz;
/**
* @param type 类型
* @param number 随机数,默认是2
* @return
*/
public ObjectRestResponse getRandomList(Integer type, Integer number, Integer location) {
if(type != null) {
number = number == null ? 2 : number;
switch (TypeEnum.getByValue(type)) {
case VEHICLE:
return vehicleFeign.findRandomVehicle(number);
case TOUR:
return tourFeign.findRandomVehicle(number);
case CAMPSITE:
return campsiteFeign.findRandomVehicle(number);
case ACTIVITY:
return ObjectRestResponse.succ(summitActivityBiz.getHostWithSummitActivity(number, location));
}
}
return ObjectRestResponse.succ();
}
}
......@@ -4,12 +4,11 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.xxfc.platform.uccn.biz.ArticleBiz;
import com.xxfc.platform.uccn.entity.Article;
import com.xxfc.platform.uccn.vo.ArticleQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* 文章
......@@ -21,31 +20,89 @@ import java.util.Map;
@Api(tags = {"文章"})
public class ArticleController extends BaseController<ArticleBiz, Article> {
@GetMapping("/list")
@GetMapping("/app/unauth/list")
@ApiOperation(value = "获取文章列表")
public ObjectRestResponse getArticleList(
@RequestParam(name = "page", defaultValue = "1") Integer page,
@RequestParam(name = "limit", defaultValue = "10") Integer limit,
@RequestParam(name = "type", defaultValue = "0") Integer type) {
@RequestParam(name = "type", defaultValue = "1") Integer type) {
return ObjectRestResponse.succ(baseBiz.getArticleList(page, limit, type));
}
@GetMapping("/one/{id}")
@GetMapping("/app/unauth/one")
@ApiOperation(value = "获取一条数据")
public ObjectRestResponse getOne(@PathVariable Integer id) {
return ObjectRestResponse.succ(baseBiz.getOne(id));
public ObjectRestResponse getOne(@RequestParam Integer id,
@RequestParam(required = false) Integer urlType) {
return ObjectRestResponse.succ(baseBiz.getOne(id,urlType));
}
@GetMapping("/three/{type}")
@GetMapping("/app/unauth/three/{type}")
@ApiOperation(value = "随机获取三条数据")
public ObjectRestResponse randomAccessToThreeData(@PathVariable Integer type){
return ObjectRestResponse.succ(baseBiz.getThree(type));
}
@GetMapping("/homePage/{type}")
@GetMapping("/app/unauth/homePage/{type}")
@ApiOperation(value = "获取首页文章列表")
public ObjectRestResponse getHomePageArticle(@PathVariable Integer type){
return ObjectRestResponse.succ(baseBiz.getHomePageArticle(type));
}
@Override
@PostMapping("/add")
@ApiOperation(value = "添加")
public ObjectRestResponse add(@RequestBody Article article){
baseBiz.add(article);
return ObjectRestResponse.succ();
}
@PostMapping("/all")
@ApiOperation(value = "获取新闻列表")
public ObjectRestResponse<Article> findAll(@RequestBody ArticleQuery query){
return ObjectRestResponse.succ(baseBiz.findAll(query));
}
@Override
@PutMapping("/update")
@ApiOperation(value = "修改")
public ObjectRestResponse update(@RequestBody Article article){
int flag = baseBiz.updateSelectiveByIdRe(article);
if (flag==1) {
return ObjectRestResponse.succ();
}
return ObjectRestResponse.createDefaultFail();
}
@PutMapping("/putaway/{id}")
@ApiOperation(value = "上架")
public ObjectRestResponse putaway(@PathVariable Integer id){
int flag = baseBiz.putaway(id);
if (flag==1) {
return ObjectRestResponse.succ();
}
return ObjectRestResponse.createDefaultFail();
}
@PutMapping("/soldOut/{id}")
@ApiOperation(value = "下架")
public ObjectRestResponse soldOut(@PathVariable Integer id){
int flag = baseBiz.soldOut(id);
if (flag==1) {
return ObjectRestResponse.succ();
}
return ObjectRestResponse.createDefaultFail();
}
@PutMapping("/remove/{id}")
@ApiOperation(value = "删除")
public ObjectRestResponse remove(@PathVariable Integer id){
int flag = baseBiz.remove(id);
if (flag==1) {
return ObjectRestResponse.succ();
}
return ObjectRestResponse.createDefaultFail();
}
}
package com.xxfc.platform.uccn.rest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.campsite.feign.CampsiteFeign;
import com.xxfc.platform.campsite.vo.CampsiteShopDetailVo;
import com.xxfc.platform.campsite.vo.CampsiteShopPageVo;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/28 10:05
*/
@RestController
@RequestMapping("/app/unauth/campsite")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class CampsiteUccnController {
private final CampsiteFeign campsiteFeign;
@ApiOperation("分页查询营地列表")
@GetMapping("/shops")
public ObjectRestResponse<PageDataVO<CampsiteShopPageVo>> findCampsiteShopPageByType(@RequestParam(value = "type", required = false) Integer type,
@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", required = false, defaultValue = "6") Integer pageSize) {
return campsiteFeign.findCampsiteShopPageByType(type, pageNo, pageSize);
}
/**
* @param longitude 经度
* @param latitude 纬度
* @return
*/
@ApiOperation("查询营地详情")
@GetMapping("/shop")
public ObjectRestResponse<CampsiteShopDetailVo> findCampsiteShopDetailById(@RequestParam(value = "id") Integer id,
@RequestParam(value = "longitude", required = false) Double longitude,
@RequestParam(value = "latitude", required = false) Double latitude) {
return campsiteFeign.findCampsiteShopDetailById(id, longitude, latitude);
}
}
package com.xxfc.platform.uccn.rest;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.CommonBaseController;
import com.xxfc.platform.tour.feign.TourFeign;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("app/unauth/tour")
@Slf4j
@IgnoreClientToken
public class GwTourController extends CommonBaseController {
@Autowired
TourFeign tourFeign;
@ApiOperation("查询旅游路线列表")
@RequestMapping(value = "/getGoodList", method = RequestMethod.GET)
@IgnoreUserToken
public ObjectRestResponse getGoodList(@RequestParam(value = "page",defaultValue = "1") Integer page, @RequestParam(value = "limit",defaultValue = "10") Integer limit,
@RequestParam(value = "tagId", required = false) Integer tagId) {
return tourFeign.getGoodList(page, limit, tagId);
}
@GetMapping("/detail/{id}")
@IgnoreUserToken
public ObjectRestResponse getOne(@PathVariable Integer id) {
return tourFeign.getOne(id);
}
@ApiOperation("首页旅游列表")
@GetMapping(value = "/shopList")
@IgnoreUserToken
public ObjectRestResponse goodListAll(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit",defaultValue = "4") Integer limit) {
return ObjectRestResponse.succ(tourFeign.goodListAll(page,limit));
}
@GetMapping("/tagList")
@IgnoreUserToken
public ObjectRestResponse getTagList(@RequestParam(value = "isHot",defaultValue = "0")Integer isHot) {
return ObjectRestResponse.succ(tourFeign.tagList(isHot));
}
}
package com.xxfc.platform.uccn.rest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.uccn.biz.RandomListBiz;
import com.xxfc.platform.uccn.dto.RandomListDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/random/list")
public class RandomListController {
@Autowired
RandomListBiz randomListBiz;
@GetMapping("/app/unauth/get")
public ObjectRestResponse getRandomList(RandomListDto randomListDto) {
if(randomListDto == null) {
return ObjectRestResponse.paramIsEmpty();
}
return randomListBiz.getRandomList(randomListDto.getType(), randomListDto.getNumber(), randomListDto.getLocation());
}
}
package com.xxfc.platform.uccn.rest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.uccn.biz.SummitActivityBiz;
import com.xxfc.platform.uccn.vo.SummitActivityDetailVo;
import com.xxfc.platform.uccn.vo.SummitActivityVo;
......@@ -15,29 +16,48 @@ import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @description
* @data 2019/8/26 15:36
*/
@RestController
@RequestMapping("/summitActivity/app/unauth")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Api("峰会")
public class SummitActivityController{
public class SummitActivityController {
private final SummitActivityBiz summitActivityBiz;
private final SummitActivityBiz summitActivityBiz;
@ApiOperation("官网首页展示")
@GetMapping("/home")
public ObjectRestResponse<List<SummitActivityVo>> findSummitActivityForHomePage(@RequestParam(defaultValue = "5",required = false) Integer limit){
@ApiOperation("官网首页展示")
@GetMapping("/home")
public ObjectRestResponse<List<SummitActivityVo>> findSummitActivityForHomePage(@RequestParam(value = "limit",defaultValue = "5", required = false) Integer limit,
@RequestParam(value = "location", defaultValue = "1", required = false) Integer location) {
List<SummitActivityVo> summitActivityVos = summitActivityBiz.findSummitActivityForHomePage(limit);
return ObjectRestResponse.succ(summitActivityVos);
}
List<SummitActivityVo> summitActivityVos = summitActivityBiz.findSummitActivityForHomePage(limit, location);
return ObjectRestResponse.succ(summitActivityVos);
}
@ApiOperation("峰会活动详情")
@GetMapping("/{id}")
public ObjectRestResponse<SummitActivityDetailVo> findSummitActivityDetailById(@PathVariable(value = "id") Integer id) {
SummitActivityDetailVo summitActivityDetailVo = summitActivityBiz.findSummitActivityDetailById(id);
return ObjectRestResponse.succ(summitActivityDetailVo);
}
@ApiOperation("热门推荐获取")
@GetMapping("/hot")
public ObjectRestResponse<List<SummitActivityVo>> findHotWithSummitActivity(@RequestParam(value = "num", required = false, defaultValue = "2") Integer num,
@RequestParam(value = "location", defaultValue = "1", required = false) Integer location) {
List<SummitActivityVo> summitActivityVos = summitActivityBiz.getHostWithSummitActivity(num, location);
return ObjectRestResponse.succ(summitActivityVos);
}
@ApiOperation("官网活动列表")
@GetMapping("/list")
public ObjectRestResponse<PageDataVO<SummitActivityVo>> findSummitActivityWithPage(@RequestParam(value = "page", defaultValue = "1", required = false) Integer page,
@RequestParam(value = "limit", defaultValue = "6", required = false) Integer limit,
@RequestParam(value = "location", defaultValue = "0", required = false) Integer location) {
PageDataVO<SummitActivityVo> pageDataVO = summitActivityBiz.findSummitActivityWithPage(page, limit,location);
return ObjectRestResponse.succ(pageDataVO);
}
@ApiOperation("峰会活动详情")
@GetMapping("/{id}")
public ObjectRestResponse<SummitActivityDetailVo> findSummitActivityDetailById(@PathVariable(value = "id") Integer id){
SummitActivityDetailVo summitActivityDetailVo = summitActivityBiz.findSummitActivityDetailById(id);
return ObjectRestResponse.succ(summitActivityDetailVo);
}
}
\ No newline at end of file
package com.xxfc.platform.uccn.rest;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.CommonBaseController;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.entity.VehicleModel;
import com.xxfc.platform.vehicle.entity.VehiclePlatCata;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.VModelDetailVO;
import com.xxfc.platform.vehicle.pojo.VehicleModelQueryCondition;
import com.xxfc.platform.vehicle.pojo.VehicleModelVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/vehicleModel/app/unauth")
@Slf4j
@IgnoreClientToken
@Api(tags = "房车车型", value = "房车车型")
public class VehicleModelController extends CommonBaseController {
@Autowired
VehicleFeign vehicleFeign;
/**
* 车型详情
*
* @param name
* @return
*/
@ApiOperation("车型详情")
@RequestMapping(value = "/detail/{name}", method = RequestMethod.GET)
@IgnoreUserToken
public ObjectRestResponse<VModelDetailVO> detail(@PathVariable("name") @ApiParam("车型名称") String name) {
return vehicleFeign.detailByParam(BeanUtil.beanToMap(new VehicleModel(){{
setName(name);
}}, false, true));
}
/**
* 车型列表查
*
* @param vmqc 条件
* @return
*/
@ApiOperation("车型列表")
@GetMapping(value = "/findVehicleModelPage")
@IgnoreUserToken
public ObjectRestResponse<PageDataVO<VehicleModelVo>> findVehicleModelPageUnauthfind(VehicleModelQueryCondition vmqc) {
ObjectRestResponse<PageDataVO<VehicleModelVo>> objectRestResponse = vehicleFeign.findVehicleModelPageUnauthfind(vmqc);
PageDataVO<VehicleModelVo> pageDataVOs = objectRestResponse.getData();
pageDataVOs.getData().forEach( v -> {
List<VehiclePlatCata> vehiclePlatCataList = vehicleFeign.getCatasByIds(v.getConfig()).getData();
StrUtil.splitToInt("14,7,11", ",");
v.setUccnCataList(vehiclePlatCataList.parallelStream().filter(v1 -> {return ArrayUtil.contains(StrUtil.splitToInt("14,7,11", ","), v1.getParentId());}).sorted(Comparator.comparing(VehiclePlatCata::getParentId, (x, y) -> {
int xx = 0,yy = 0;
int[] array = StrUtil.splitToInt("14,7,11", ",");
for(int i = 0; i < array.length; i++) {
if(x == array[i]) {
xx = i;
}else if(y == array[i]) {
yy = i;
}
}
return (xx - yy);
})).collect(Collectors.toList()));
});
return objectRestResponse;
}
}
package com.xxfc.platform.uccn.rest.admin;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.uccn.biz.SummitActivityBiz;
import com.xxfc.platform.uccn.dto.SummitActivityFindDTO;
import com.xxfc.platform.uccn.dto.SummitActivitySaveDTO;
import com.xxfc.platform.uccn.vo.SummitActivityAdminVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -16,35 +22,72 @@ import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/admin/summitActivity")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Api("峰会活动*后台")
public class SummitActivityAdminController {
private final SummitActivityBiz summitActivityBiz;
@ApiOperation("活动列表")
@PostMapping("/list")
public ObjectRestResponse<PageDataVO<SummitActivityAdminVo>> listSummitActivityWithPage(@RequestBody SummitActivityFindDTO summitActivityFindDTO){
PageDataVO<SummitActivityAdminVo> pageDataVO = summitActivityBiz.listSummitActivityWithPage(summitActivityFindDTO);
return ObjectRestResponse.succ(pageDataVO);
}
@ApiOperation("编辑查询")
@GetMapping("/{id}")
public ObjectRestResponse<SummitActivitySaveDTO> selectToEdit(@PathVariable(value = "id") Integer id){
SummitActivitySaveDTO summitActivitySaveDTO = summitActivityBiz.selectSummitActivityById(id);
return ObjectRestResponse.succ(summitActivitySaveDTO);
}
@ApiOperation("保存或编辑")
@PostMapping("/save")
public ObjectRestResponse<Void> saveSummitActivity(){
public ObjectRestResponse<Void> saveSummitActivity(@RequestBody SummitActivitySaveDTO summitActivitySaveDTO, UserDTO userDTO){
summitActivityBiz.saveSummitActivity(summitActivitySaveDTO,userDTO);
return ObjectRestResponse.succ();
}
@ApiOperation("活动发布设置")
@PutMapping("/publish/{id}/{state}")
public ObjectRestResponse<Void> publishSummitActivity(@PathVariable(value = "id") Integer id,@PathVariable(value = "state") Integer state){
summitActivityBiz.publishSummitActivityById(id,state);
return ObjectRestResponse.succ();
}
@ApiOperation("发布活动")
@PutMapping("/publish/{id}")
public ObjectRestResponse<Void> publishSumitActivity(@PathVariable(value = "id") Integer id){
@ApiOperation("上下架活动")
@PutMapping("/soldout/{id}/{state}")
public ObjectRestResponse<Void> soldOutSummitActivity(@PathVariable(value = "id") Integer id,@PathVariable(value = "state") Integer state){
summitActivityBiz.soldOutSummitAcitivityById(id,state);
return ObjectRestResponse.succ();
}
@ApiOperation("首页展示设置")
@PutMapping("/home_page/{id}/{state}")
public ObjectRestResponse<Void> setShowOnHomePage(@PathVariable(value = "id") Integer id,@PathVariable(value = "state") Integer state){
summitActivityBiz.setShowOnHomePageById(id,state);
return ObjectRestResponse.succ();
}
@ApiOperation("下架活动")
@PutMapping("/soldout/{id}")
public ObjectRestResponse<Void> soldOutSumitActivity(@PathVariable(value = "id") Integer id){
@ApiOperation("报名开关设置")
@PutMapping("/reg_state/{id}/{state}")
public ObjectRestResponse<Void> setRegStateWithSummitActivity(@PathVariable(value = "id") Integer id,@PathVariable(value = "state") Integer state){
summitActivityBiz.setRegSateWithSummitActivityById(id,state);
return ObjectRestResponse.succ();
}
@ApiOperation("更改排序")
@PutMapping("/rank/{id}/{rank}")
public ObjectRestResponse<Void> setSummitActivityRank(@PathVariable(value = "id") Integer id,@PathVariable("rank") Integer rank){
summitActivityBiz.updateSummitActivityRankById(id,rank);
return ObjectRestResponse.succ();
}
@ApiOperation("删除活动")
@DeleteMapping("/{id}")
public ObjectRestResponse<Void> deleteSummitActivityById(@PathVariable(value = "id") Integer id){
public ObjectRestResponse<Void> deleteSummitActivity(@PathVariable(value = "id") Integer id){
summitActivityBiz.deleteSummitActivityById(id);
return ObjectRestResponse.succ();
}
}
\ No newline at end of file
......@@ -5,7 +5,7 @@
<select id="getArticleList" resultType="com.xxfc.platform.uccn.entity.Article">
select title,epitome,add_time,cover_image from article
where is_del=0 and status=1 and (type=#{type} or type=0) order by weight DESC,add_time DESC
where is_del=0 and status=1 and (type=#{type} or type=0) order by weight ASC ,add_time DESC
</select>
</mapper>
\ No newline at end of file
......@@ -156,4 +156,12 @@ public class VehicleModel implements Serializable {
@Column(name = "poster_background")
@ApiModelProperty(value = "海报背景")
private String posterBackground;
@Column(name = "sort")
@ApiModelProperty(value = "排序")
private Integer sort;
@Column(name = "intro")
@ApiModelProperty(value = "简介")
private String intro;
}
......@@ -2,14 +2,17 @@ package com.xxfc.platform.vehicle.feign;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.GoodDataVO;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.entity.*;
import com.xxfc.platform.vehicle.pojo.*;
import com.xxfc.platform.vehicle.pojo.vo.AccompanyingItemVo;
import com.xxfc.platform.vehicle.pojo.vo.BranComanyLeaderVo;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
import java.util.Set;
......@@ -126,4 +129,20 @@ public interface VehicleFeign {
@GetMapping("/branchCompany/company")
Map<Integer, BranComanyLeaderVo> findCompanyLeaderMapByIds(@RequestParam(value = "companyIds") List<Integer> companyIds);
@GetMapping("/vehicleModel/app/unauth/detail-param")
ObjectRestResponse<VModelDetailVO> detailByParam(@RequestParam("vehicleModel") Map<String, Object> vehicleModel);
@PostMapping("/vehicleModel/app/unauth/findVehicleModelPage")
public ObjectRestResponse<PageDataVO<VehicleModelVo>> findVehicleModelPageUnauthfind(@RequestBody VehicleModelQueryCondition vmqc);
//cata
/**
* 查询当前车型拥有的标签
* @param ids
* @return
*/
@GetMapping("/cata/add/getCatasByIds/{ids}")
public ObjectRestResponse<List<VehiclePlatCata>> getCatasByIds(@PathVariable("ids") String ids);
}
......@@ -2,6 +2,7 @@ package com.xxfc.platform.vehicle.pojo;
import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.entity.VehicleModel;
import com.xxfc.platform.vehicle.entity.VehiclePlatCata;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -12,6 +13,7 @@ import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
......@@ -25,128 +27,6 @@ import java.util.Date;
@Table(name = "vehicle_model")
public class VehicleModelVo extends VehicleModel implements Serializable {
private static final long serialVersionUID = 1L;
//主键
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("主键")
private Integer id;
//名称
@Column(name = "name")
@ApiModelProperty(value = "名称")
private String name;
//房车配置,code逗号分割
@Column(name = "config")
@ApiModelProperty(value = "房车配置,code逗号分割")
private String config;
@Column(name = "number")
@ApiModelProperty(value = "乘卧数id")
private String number;
@Column(name = "brand")
@ApiModelProperty(value = "品牌id")
private String brand;
//关键标签,code逗号分割
@Column(name = "keyword")
@ApiModelProperty(value = "关键标签,code逗号分割")
private String keyword;
//车型详情
@Column(name = "models_details")
@ApiModelProperty(value = "车型详情")
private String modelsDetails;
//参数
@Column(name = "model_param")
@ApiModelProperty(value = "参数")
private String modelParam;
//图片地址 多张为逗号分割
@Column(name = "picture")
@ApiModelProperty(value = "图片地址 多张为逗号分割")
private String picture;
//价格
@Column(name = "price")
@ApiModelProperty(value = "价格")
private BigDecimal price;
//总押金
@Column(name = "deposit")
@ApiModelProperty(value = "总押金")
private BigDecimal deposit;
//违章押金
@Column(name = "vio_deposit")
@ApiModelProperty(value = "违章押金")
private BigDecimal vioDeposit;
//创建时间
@Column(name = "crt_time")
@ApiModelProperty(value = "创建时间", hidden = true )
private Date crtTime;
//创建者id
@Column(name = "crt_user")
@ApiModelProperty(value = "创建者id")
private Integer crtUser;
//创建者名称
@Column(name = "crt_name")
@ApiModelProperty(value = "创建者名称")
private String crtName;
//创建者host
@Column(name = "crt_host")
@ApiModelProperty(value = "创建者host")
private String crtHost;
//修改时间
@Column(name = "upd_time")
@ApiModelProperty(value = "修改时间", hidden = true )
private Date updTime;
//修改者
@Column(name = "upd_user")
@ApiModelProperty(value = "修改者")
private Integer updUser;
//修改者名称
@Column(name = "upd_name")
@ApiModelProperty(value = "修改者名称")
private String updName;
//修改者host
@Column(name = "upd_host")
@ApiModelProperty(value = "修改者host")
private String updHost;
//评分
@Column(name = "score")
@ApiModelProperty(value = "评分")
private Integer score;
@Column(name = "hot_sign")
@ApiModelProperty(value = "热度标记,1--热门;2--非热门")
private Integer hotSign;
@ApiModelProperty(value = "是否删除")
private Integer isdel;
@Column(name = "rent_discount_status")
@ApiModelProperty(value = "租车优惠状态 0--没有优惠;1--会员折扣;2--固定值")
private Integer rentDiscountStatus;
@Column(name = "rent_discount_price")
@ApiModelProperty(value = "租车优惠价格")
private String rentDiscountPrice;
@Column(name = "buy_price")
@ApiModelProperty(value = "购买价格")
private BigDecimal buyPrice;
@ApiModelProperty(value = "总数量")
private Integer sum;
......@@ -168,13 +48,6 @@ public class VehicleModelVo extends VehicleModel implements Serializable {
@ApiModelProperty(value = "品牌")
private String brandName;
// @Column(name = "status")
// @ApiModelProperty(value = "状态 0--下架;1--上架")
// private String status;
// @Column(name = "cover_pic")
// @ApiModelProperty(value = "封面图")
// private String coverPic;
List<VehiclePlatCata> UccnCataList;
}
......@@ -85,7 +85,6 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
private VehicleBiz vehicleBiz;
/**
* 按主键获取公司
*
......@@ -120,7 +119,7 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
* @param id
* @return
*/
@Cache(key = RedisKey.BRANCH_COMPANY_CACHE+ "{1}")
@Cache(key = RedisKey.BRANCH_COMPANY_CACHE + "{1}")
public CompanyDetail getDetailById(Integer id) {
BranchCompany branchCompany = this.getById(id);
CompanyDetail detail = null;
......@@ -161,35 +160,35 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
}
public PageDataVO<BranchCompany> getAll(Integer page, Integer limit, Integer addrProvince, Integer addrCity,
Integer addrTown,Integer zoneId, UserDTO userDTO) {
Integer addrTown, Integer zoneId, UserDTO userDTO) {
Example example = new Example(BranchCompany.class);
Example.Criteria criteria = example.createCriteria();
String provinceIds="";
if (Objects.nonNull(zoneId)){
String provinceIds = "";
if (Objects.nonNull(zoneId)) {
Area area = areaBiz.selectById(zoneId);
provinceIds = area.getProvinceIds();
provinceIds = area.getProvinceIds();
}
if (StringUtils.isNotEmpty(provinceIds)){
if (StringUtils.isNotEmpty(provinceIds)) {
List<String> provinceIdList = Arrays.asList(provinceIds.split(","));
if (Objects.nonNull(addrProvince)){
if (provinceIdList.contains(String.valueOf(addrProvince))){
criteria.andEqualTo("addrProvince",addrProvince);
}else {
return new PageDataVO<BranchCompany>();
if (Objects.nonNull(addrProvince)) {
if (provinceIdList.contains(String.valueOf(addrProvince))) {
criteria.andEqualTo("addrProvince", addrProvince);
} else {
return new PageDataVO<BranchCompany>();
}
}else {
criteria.andIn("addrProvince",provinceIdList);
} else {
criteria.andIn("addrProvince", provinceIdList);
}
}else {
} else {
if (addrProvince != null) {
criteria.andEqualTo("addrProvince",addrProvince);
criteria.andEqualTo("addrProvince", addrProvince);
}
}
if (addrCity != null) {
criteria.andEqualTo("addrCity",addrCity);
criteria.andEqualTo("addrCity", addrCity);
}
if (addrTown != null) {
criteria.andEqualTo("addrTown",addrTown);
criteria.andEqualTo("addrTown", addrTown);
}
if (userDTO != null && DATA_ALL_FALSE.equals(userDTO.getDataAll())) {
if (StringUtils.isNotBlank(userDTO.getDataZone())) {
......@@ -361,15 +360,15 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
}
public Map<Integer, BranComanyLeaderVo> findCompanyLeaderMapByIds(List<Integer> companyIds) {
Map<Integer,BranComanyLeaderVo> companyIdAndLeaderMap = new HashMap<>(companyIds.size());
Map<Integer, BranComanyLeaderVo> companyIdAndLeaderMap = new HashMap<>(companyIds.size());
List<BranchCompany> branchCompanies = mapper.selectByIdList(companyIds);
if (CollectionUtils.isEmpty(branchCompanies)){
if (CollectionUtils.isEmpty(branchCompanies)) {
return companyIdAndLeaderMap;
}
return branchCompanies.stream().collect(Collectors.toMap(BranchCompany::getId,branchCompany -> {
return branchCompanies.stream().collect(Collectors.toMap(BranchCompany::getId, branchCompany -> {
BranComanyLeaderVo branComanyLeaderVo = new BranComanyLeaderVo();
BeanUtils.copyProperties(branchCompany,branComanyLeaderVo);
return branComanyLeaderVo;
BeanUtils.copyProperties(branchCompany, branComanyLeaderVo);
return branComanyLeaderVo;
}));
}
......@@ -377,14 +376,14 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
PageDataVO<BranchCompanyListVO> pageDataVO = new PageDataVO<>();
PageDataVO<BranchCompanyListDTO> dataVO = PageDataVO.pageInfo(branchCompanyFindDTO.getPage(), branchCompanyFindDTO.getLimit(), () -> mapper.findBranchCompanys(branchCompanyFindDTO.getAddrProvince(), branchCompanyFindDTO.getAddrCity()));
List<BranchCompanyListDTO> data = dataVO.getData();
if (CollectionUtils.isEmpty(data)){
if (CollectionUtils.isEmpty(data)) {
return pageDataVO;
}
List<BranchCompanyListVO> branchCompanyListVOS = new ArrayList<>();
BranchCompanyListVO branchCompanyListVO;
for (BranchCompanyListDTO companyListDTO : data) {
branchCompanyListVO = new BranchCompanyListVO();
BeanUtils.copyProperties(companyListDTO,branchCompanyListVO);
branchCompanyListVO = new BranchCompanyListVO();
BeanUtils.copyProperties(companyListDTO, branchCompanyListVO);
branchCompanyListVOS.add(branchCompanyListVO);
}
pageDataVO.setData(branchCompanyListVOS);
......
......@@ -123,11 +123,16 @@ public class CompanyBaseBiz extends BaseBiz<CompanyBaseMapper, CompanyBase> {
|| companyVo.getAddrCity()==null||companyVo.getAddrCity()==0){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE,"参数不能为空");
}
Area area=areaBiz.selectById(companyVo.getZoneId());
Integer provinc=companyVo.getAddrProvince();
if (area==null||StringUtils.isBlank(area.getProvinceIds())||!area.getProvinceIds().contains(provinc+"")){
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"片区和省份不一致");
}
Integer state=companyVo.getState()==null?2:companyVo.getState();
BigDecimal latitude=companyVo.getLatitude();
BigDecimal longitude=companyVo.getLongitude();
if (state==1&&(StringUtils.isBlank(companyVo.getAddrDetail())||StringUtils.isBlank(companyVo.getImages())||StringUtils.isBlank(companyVo.getDescribes())
||StringUtils.isBlank(companyVo.getLeaderContactInfo())||latitude==null||longitude==null)){
||latitude==null||longitude==null)){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE,"上架时参数不能为空");
}
CompanyBase companyBase=new CompanyBase();
......
......@@ -41,19 +41,19 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
public static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd");
public Map<String, Integer> getPredictableHours(String bookStartDate, String bookEndDate, Boolean notCheckTimeLegal) {
public Map<String, Integer> getPredictableHours(String bookStartDate, String bookEndDate, Boolean notCheckTimeLegal) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date startDate = null;
Date endDate = null;
try{
try {
startDate = simpleDateFormat.parse(bookStartDate);
endDate = simpleDateFormat.parse(bookEndDate);
}catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
//判定时间是否合法
if(!Boolean.TRUE.equals(notCheckTimeLegal)) {
if (!Boolean.TRUE.equals(notCheckTimeLegal)) {
if (bookStartDate.compareTo(DateTime.now().toString(DEFAULT_DATE_TIME_FORMATTER)) < 0) {
throw new BaseException(ResultCode.ONLY_BOOK_FROM_TODAY);
}
......@@ -67,28 +67,28 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
int endHour = new DateTime(endDate).hourOfDay().get();
//获取开始天的预定小时
int startPredictableHour = 0;
for (int curentHour = hour; curentHour <= 23; curentHour++) {
startPredictableHour |= 1 << (curentHour);
}
for (int curentHour = hour; curentHour <= 23; curentHour++) {
startPredictableHour |= 1 << (curentHour);
}
//获取结束天的预定小时
int endPredictableHour = 0;
for (int curentHour = 0; curentHour <= endHour; curentHour++) {
endPredictableHour |= 1 << (curentHour);
}
for (int curentHour = 0; curentHour <= endHour; curentHour++) {
endPredictableHour |= 1 << (curentHour);
}
DateTime startDay = DateTime.parse(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), DATE_TIME_FORMATTER);
DateTime endDay = DateTime.parse(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), DATE_TIME_FORMATTER);
if(startPredictableHour == 0) { //如果是0点就直接预订全天
if (startPredictableHour == 0) { //如果是0点就直接预订全天
startPredictableHour = 16777215;
}
if(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER).equals(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER))) {//同一天预定
if (DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER).equals(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER))) {//同一天预定
//如果开始时间是0点开始
predictableHours.put(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), startPredictableHour & endPredictableHour);
predictableHours.put(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), startPredictableHour & endPredictableHour);
} else { //非同一天开始
predictableHours.put(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), startPredictableHour);
predictableHours.put(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), endPredictableHour);
}
if(endDay.getDayOfMonth() - startDay.getDayOfMonth() > 1){ //
if (endDay.getMillis() - startDay.getMillis() > 24 * 3600 * 1000) { //
for (DateTime curDate = startDay.plusDays(1); curDate.compareTo(endDay) < 0; curDate = curDate.plusDays(1)) {
String curDateStr = curDate.toString(DATE_TIME_FORMATTER);
//全天预定
......@@ -115,14 +115,14 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
@Transactional
@CacheClear(key = "vehicle.hourInfo")
public ObjectRestResponse save(VehicleBookHourInfoDto vehicleBookHourInfoDto) {
if(vehicleBookHourInfoDto == null) {
if (vehicleBookHourInfoDto == null) {
return ObjectRestResponse.paramIsEmpty();
}
List<VehicleBookHourInfo> vehicleBookHourInfos = mapper.selectByVehicleAndDate(vehicleBookHourInfoDto);
//有数据直接更新
if(vehicleBookHourInfos.size() >=1) {
for(VehicleBookHourInfo vehicleBookHourInfo : vehicleBookHourInfos) {
if(vehicleBookHourInfo.getBookedHour().equals(vehicleBookHourInfoDto.getBookedHour())) {
if (vehicleBookHourInfos.size() >= 1) {
for (VehicleBookHourInfo vehicleBookHourInfo : vehicleBookHourInfos) {
if (vehicleBookHourInfo.getBookedHour().equals(vehicleBookHourInfoDto.getBookedHour())) {
return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_IS_BOOKED_TODAY.getCode(), ResCode.VEHICLE_IS_BOOKED_TODAY.getDesc());
} else {
vehicleBookHourInfo.setBookedHour(vehicleBookHourInfo.getBookedHour() | vehicleBookHourInfoDto.getBookedHour());
......@@ -138,6 +138,7 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
/**
* 删除预定车辆小时记录信息
*
* @param vehicleId 车辆Id
* @param dateList 日期列表
* @return
......@@ -145,26 +146,26 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
@Transactional
@CacheClear(key = "vehicle.hourInfo")
public ObjectRestResponse delete(String vehicleId, List<String> dateList) {
if(StringUtils.isBlank(vehicleId) || dateList.size() <= 0) {
return ObjectRestResponse.paramIsEmpty();
}
Map<String, Object> param = Maps.newHashMap();
param.put("vehicleId", vehicleId);
param.put("list", dateList);
List<VehicleBookHourInfo> list = mapper.selectByVehicleAndDateList(param);
list.forEach((a) -> mapper.delete(a));
return ObjectRestResponse.succ();
if (StringUtils.isBlank(vehicleId) || dateList.size() <= 0) {
return ObjectRestResponse.paramIsEmpty();
}
Map<String, Object> param = Maps.newHashMap();
param.put("vehicleId", vehicleId);
param.put("list", dateList);
List<VehicleBookHourInfo> list = mapper.selectByVehicleAndDateList(param);
list.forEach((a) -> mapper.delete(a));
return ObjectRestResponse.succ();
}
public ObjectRestResponse checkBookHourInfo() {
public ObjectRestResponse checkBookHourInfo() {
List<VehicleBookHourInfoDto> vehicleBookHourInfos = new ArrayList<>();
List<VehicleBookRecord> list = vehicleBookRecordBiz.selectListAll();
if(CollectionUtils.isNotEmpty(list)) {
for(VehicleBookRecord vehicleBookRecord : list) {
if (CollectionUtils.isNotEmpty(list)) {
for (VehicleBookRecord vehicleBookRecord : list) {
VehicleDepartureLogVo vehicleDepartureLog = vehicleDepartureService.getByRecordId(vehicleBookRecord.getId());
if((vehicleDepartureLog == null || vehicleDepartureLog.getState() != 1) && (vehicleBookRecord.getStatus() == 2 || vehicleBookRecord.getStatus() == 1)) { //未出车或未还车
if ((vehicleDepartureLog == null || vehicleDepartureLog.getState() != 1) && (vehicleBookRecord.getStatus() == 2 || vehicleBookRecord.getStatus() == 1)) { //未出车或未还车
Map<String, Integer> map = getPredictableHours(new DateTime(vehicleBookRecord.getBookStartDate()).toString(DEFAULT_DATE_TIME_FORMATTER), new DateTime(vehicleBookRecord.getBookEndDate()).toString(DEFAULT_DATE_TIME_FORMATTER), Boolean.TRUE);
for(Map.Entry<String, Integer> entry : map.entrySet()) {
for (Map.Entry<String, Integer> entry : map.entrySet()) {
VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto();
vehicleBookHourInfoDto.setVehicleId(vehicleBookRecord.getVehicleId());
vehicleBookHourInfoDto.setYearMonthDay(entry.getKey());
......@@ -204,10 +205,10 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
}
public static void main(String[] args) throws Exception{
public static void main(String[] args) throws Exception {
VehicleBookHourInfoBiz vehicleBookHourInfoBiz = new VehicleBookHourInfoBiz();
Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours("2019-08-26 10:00:00", "2019-08-27 10:00:00", Boolean.TRUE);
for(Map.Entry<String, Integer> entry : map.entrySet()) {
for (Map.Entry<String, Integer> entry : map.entrySet()) {
System.out.println(entry.getKey());
System.out.println(entry.getValue());
}
......
......@@ -29,7 +29,7 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
public static final DateTimeFormatter YEARMONTH_DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM");
public static final Integer DEL_BATCH_SIZE = 1000;
public static final Integer COPY_BATCH_SIZE = 100;
public static final int MONTH_INTERVAL=2;
public static final int MONTH_INTERVAL = 2;
@Autowired
private RedisTemplate customRedisTemplate;
......@@ -40,14 +40,14 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
*/
@Scheduled(cron = "0 0 0 1 * ?")//每月1号0点触发
@Transactional
public void transfer2HistoryTb(){
public void transfer2HistoryTb() {
//获取表格名称
String tbName = getTbNameNow();
DateTime now = DateTime.now();//当前获取的时间为标准
log.info("开始预定信息迁移至历史表的定时任务。");
//每月初将上月数据复制到历史表
Boolean needRun= copyDataLastMoth(now,tbName);
if(needRun) {
Boolean needRun = copyDataLastMoth(now, tbName);
if (needRun) {
//每月初将上上月数据从当前信息表中删除
delDataTheMonthBeforeLast(now, tbName);
}
......@@ -57,14 +57,14 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
* 获取上月数据,并复制到历史表
*/
@Transactional
public Boolean copyDataLastMoth(DateTime now,String tbName){
public Boolean copyDataLastMoth(DateTime now, String tbName) {
String lastMonthStr = now.plusMonths(-1).toString(YEARMONTH_DATE_TIME_FORMATTER);
String redisKey = RedisKey.DEL_BOOK_INFO_LOCK_PREFIX +lastMonthStr;
String redisKey = RedisKey.DEL_BOOK_INFO_LOCK_PREFIX + lastMonthStr;
Boolean hasSuc = customRedisTemplate.opsForValue().setIfAbsent(redisKey,String.valueOf(DateTime.now().getMillis()));
if(hasSuc){//设置1天后过期
customRedisTemplate.expire(redisKey,1, TimeUnit.DAYS);
}else{
Boolean hasSuc = customRedisTemplate.opsForValue().setIfAbsent(redisKey, String.valueOf(DateTime.now().getMillis()));
if (hasSuc) {//设置1天后过期
customRedisTemplate.expire(redisKey, 1, TimeUnit.DAYS);
} else {
log.info("[预定信息迁移]乐观锁获取失败,该线程不执行任务。");
return Boolean.FALSE;
}
......@@ -78,9 +78,9 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
params.put("pageStart", (curPageNo - 1) * COPY_BATCH_SIZE);
params.put("pageSize", COPY_BATCH_SIZE);
vehicleBookInfoList = mapper.getByPage4YearMonth(params);
if(CollectionUtils.isNotEmpty(vehicleBookInfoList)){
if (CollectionUtils.isNotEmpty(vehicleBookInfoList)) {
//插入数据到历史表
for(VehicleBookInfo vehicleBookInfo : vehicleBookInfoList){
for (VehicleBookInfo vehicleBookInfo : vehicleBookInfoList) {
Map<String, Object> insertHisParams = Maps.newHashMap();
insertHisParams.put("tbName", tbName);
insertHisParams.put("id", vehicleBookInfo.getId());
......@@ -91,17 +91,18 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
}
}
curPageNo++;
log.info("【复制上月预定信息至历史表中】,当前复制页【"+curPageNo+"】,页大小【"+COPY_BATCH_SIZE+"】");
}while(CollectionUtils.isNotEmpty(vehicleBookInfoList));
log.info("复制上月预定信息至历史表中完成,总页数【"+(curPageNo-1)+"】");
; return Boolean.TRUE;
log.info("【复制上月预定信息至历史表中】,当前复制页【" + curPageNo + "】,页大小【" + COPY_BATCH_SIZE + "】");
} while (CollectionUtils.isNotEmpty(vehicleBookInfoList));
log.info("复制上月预定信息至历史表中完成,总页数【" + (curPageNo - 1) + "】");
;
return Boolean.TRUE;
}
/**
* 删除上上月数据
*/
@Transactional
public void delDataTheMonthBeforeLast(DateTime now,String tbName){
public void delDataTheMonthBeforeLast(DateTime now, String tbName) {
String theMonthBeforeLastStr = now.plusMonths(-2).toString(YEARMONTH_DATE_TIME_FORMATTER);
Integer effected = 0;
Integer total = 0;
......@@ -110,21 +111,21 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
params.put("batchSize", DEL_BATCH_SIZE);
do {
effected = mapper.del4YearMoth(params);
total+=effected;
log.info("开始删除预定信息数据,删除总数【"+total+"】");
}while(effected!=0);
total += effected;
log.info("开始删除预定信息数据,删除总数【" + total + "】");
} while (effected != 0);
log.info("删除预定信息数据完成");
}
private String getTbNameNow(){
return TB_NAME_PREFIX+ DateTime.now().toString(YEAR_DATE_TIME_FORMATTER);
private String getTbNameNow() {
return TB_NAME_PREFIX + DateTime.now().toString(YEAR_DATE_TIME_FORMATTER);
}
/**
* 创建当年相关表格
*/
private void createTbIfNotExists(String tbName){
private void createTbIfNotExists(String tbName) {
mapper.createTbIfNotExists(tbName);
}
......
......@@ -201,7 +201,7 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
PageDataVO<VehicleBookRecordVo> vehicleBookRecordVoPageDataVO = PageDataVO.pageInfo(vehicleBookRecordVoPageInfo);
vehicleBookRecordVoPageDataVO.setPageNum(pageNo);
vehicleBookRecordVoPageDataVO.setPageSize(pageSize);
vehicleBookRecordVoPageDataVO.setTotalCount((long)vehicleBookRecordVoPageInfo.getList().size());
vehicleBookRecordVoPageDataVO.setTotalCount((long) vehicleBookRecordVoPageInfo.getList().size());
vehicleBookRecordVoPageDataVO.setTotalPage((vehicleBookRecordVoPageInfo.getList().size() + pageSize - 1) / pageSize);
vehicleBookRecordVoPageDataVO.setData(getData(vehicleBookRecordVoPageInfo.getList(), pageNo, pageSize));
return RestResponse.suc(vehicleBookRecordVoPageDataVO);
......@@ -212,7 +212,7 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
}
public void removeStatus2(List<VehicleBookRecordVo> list) {
if(list != null && list.size() > 0) {
if (list != null && list.size() > 0) {
Iterator<VehicleBookRecordVo> iterator = list.iterator();
while (iterator.hasNext()) {
if (iterator.next().getVehicleDepartureLogVo() != null) {
......@@ -360,29 +360,30 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
/**
* 检验数据库预定记录日期是否和时间,日期表中的二进制数据一致
*
* @return
*/
public ObjectRestResponse checkDateInvalide(){
public ObjectRestResponse checkDateInvalide() {
List<VehicleBookRecord> list = mapper.selectAll();
List<VehicleBookRecord> unRightList = new ArrayList<>();
if(list != null && list.size() > 0) {
for(VehicleBookRecord vehicleBookRecord : list) {
if (list != null && list.size() > 0) {
for (VehicleBookRecord vehicleBookRecord : list) {
log.info("vehicleBookRecord = {}", vehicleBookRecord);
Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours(DateUtil.dateToStr(vehicleBookRecord.getBookStartDate(), "yyyy-MM-dd HH:mm:ss"), DateUtil.dateToStr(vehicleBookRecord.getBookStartDate(), "yyyy-MM-dd HH:mm:ss"), Boolean.TRUE);
log.info("转换为时间二进制:map = {}", map);
//检验数据有效性
if(vehicleBookRecord.getStatus() == 2) {
if (vehicleBookRecord.getStatus() == 2) {
VehicleDepartureLogVo vehicleDepartureLog = vehicleDepartureService.getByRecordId(vehicleBookRecord.getId());
if(vehicleDepartureLog == null || vehicleDepartureLog.getState() != 1) { //未出车或未还车
for(Map.Entry<String, Integer> entry : map.entrySet()) {
if (vehicleDepartureLog == null || vehicleDepartureLog.getState() != 1) { //未出车或未还车
for (Map.Entry<String, Integer> entry : map.entrySet()) {
VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto();
vehicleBookHourInfoDto.setVehicleId(vehicleBookRecord.getVehicleId());
vehicleBookHourInfoDto.setYearMonthDay(entry.getKey());
List<VehicleBookHourInfo> vehicleBookHourInfos = vehicleBookHourInfoBiz.selectByVehicleAndDate(vehicleBookHourInfoDto);
log.info("预定时间信息:vehicleBookHourInfos = {}", vehicleBookHourInfos);
if(vehicleBookHourInfos != null && vehicleBookHourInfos.size() > 0) {
if (vehicleBookHourInfos != null && vehicleBookHourInfos.size() > 0) {
//检验数据是否存在
if((vehicleBookHourInfos.get(0).getBookedHour() & entry.getValue()) == entry.getValue()) {
if ((vehicleBookHourInfos.get(0).getBookedHour() & entry.getValue()) == entry.getValue()) {
log.info("时间正确,已经存在");
} else {
log.info("时间不正确");
......
......@@ -86,7 +86,7 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper,
} else {
vehicleDepartureLog.setUpdateTime(new Date());
VehicleDepartureLog oldValue = mapper.selectByPrimaryKey(vehicleDepartureLog);
if(oldValue != null) {
if (oldValue != null) {
log.info("更新出行记录: vehicleDepartureLog = {}", oldValue);
BeanUtil.copyProperties(vehicleDepartureLog, oldValue, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
oldValue.setUpdateTime(new Date());
......@@ -104,7 +104,6 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper,
}
public ObjectRestResponse findOne(Integer vid) throws Exception {
Example exm = Example.builder(VehicleDepartureLog.class)
.where(WeekendSqls.<VehicleDepartureLog>custom()
......@@ -116,7 +115,7 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper,
List<VehicleDepartureLog> vehicleDepartureLogs = mapper.selectByExample(exm);
if (vehicleDepartureLogs.size() == 1) {
VehicleDepartureLog vehicleDepartureLog = vehicleDepartureLogs.get(0);
if (vehicleDepartureLog!=null) {
if (vehicleDepartureLog != null) {
return ObjectRestResponse.succ(vehicleDepartureLog);
}
}
......@@ -124,11 +123,11 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper,
}
@Transactional
public ObjectRestResponse collect(VehicleDepartureLog vdl){
vdl.setArrivalTime(new Date());
vdl.setState(1);
updateSelectiveById(vdl);
return ObjectRestResponse.succ();
public ObjectRestResponse collect(VehicleDepartureLog vdl) {
vdl.setArrivalTime(new Date());
vdl.setState(1);
updateSelectiveById(vdl);
return ObjectRestResponse.succ();
}
......
......@@ -87,7 +87,7 @@ public class VehicleModelBiz extends BaseBiz<VehicleModelMapper, VehicleModel> {
return ObjectRestResponse.succ(list);
}
Set<Integer> set = new HashSet<>();
RandomUtil.randomSet(list.size(), number, set);
RandomUtil.randomSet(list.size(), number, set, number);
for(Integer i : set) {
resultList.add(list.get(i));
}
......
......@@ -410,7 +410,7 @@ public class VehiclePlatCataBiz extends BaseBiz<VehiclePlatCataMapper, VehiclePl
* @param ids
* @return
*/
public ObjectRestResponse getCatasByIds(String ids) {
public ObjectRestResponse<List<VehiclePlatCata>> getCatasByIds(String ids) {
Example exa = Example.builder(VehiclePlatCata.class).where(
WeekendSqls.<VehiclePlatCata>custom()
.andIn(VehiclePlatCata::getId, Arrays.asList(ids.split(",")))
......
......@@ -9,6 +9,7 @@ import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import com.xxl.job.core.log.XxlJobLogger;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -25,16 +26,14 @@ import java.util.stream.Collectors;
*/
@JobHandler(value = "vehicle_job_handler")
@Component("vehicle_job_handler")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class VehicleJobHandler extends IJobHandler {
@Autowired
private VehicleBiz vehicleBiz;
private final VehicleBiz vehicleBiz;
@Autowired
private VehicleBookInfoBiz vehicleBookInfoBiz;
private final VehicleBookInfoBiz vehicleBookInfoBiz;
@Autowired
private ThirdFeign thirdFeign;
private final ThirdFeign thirdFeign;
private static final String DIC_VEHICLE_TYPE="VEHICLE";
......@@ -46,12 +45,10 @@ public class VehicleJobHandler extends IJobHandler {
List<String> existVehicleIds = vehicleBiz.findExistVehicleIds();
Dictionary dictionary = thirdFeign.findDictionaryByTypeAndCode(DIC_VEHICLE_TYPE, DIC_VEHICLE_CODE);
LocalDate date = LocalDate.now();
date = date.plusMonths(Integer.valueOf(dictionary.getDetail()));
int year = date.getYear();
int nowMonth = date.getMonthValue();
int betweenMonth = Integer.valueOf(dictionary.getDetail()).intValue();
int month = nowMonth + betweenMonth> 12 ? (betweenMonth + nowMonth) - 12 : nowMonth + betweenMonth;
year = month > nowMonth ? year : year + 1;
String yearAndMonth = String.format("%d-%s", year, month>=10?month:"0"+month);
int month = date.getMonthValue();
String yearAndMonth = String.format("%d-%02d", year,month);
XxlJobLogger.log("----查询到的车型ids:【{}】",existVehicleIds);
if (CollectionUtils.isNotEmpty(existVehicleIds)) {
List<VehicleBookInfo> bookInfos = existVehicleIds.stream().map(vehicleId -> {
......
......@@ -13,7 +13,7 @@ public interface VehicleDepartureLogMapper extends BaseMapper<VehicleDepartureLo
VehicleDepartureLog selectLastByVehicleId(String vehicleId);
List<VehicleDepartureLogVo> selectByVehicleId(String vehicleId);
List<VehicleDepartureLog> selectByVehicle(String vehicleId);
List<VehicleDepartureLogVo> selectVoAll(@Param("numberPlate") String numberPlate, @Param("time") String time);
List<VehicleDepartureLogVo> selectVoAllNotAllData(@Param("numberPlate") String numberPlate, @Param("time") String time, @Param("companyList") List<Integer> companyList);
......
......@@ -29,6 +29,8 @@ public interface VehicleMapper extends Mapper<Vehicle> {
int updateStatusByIdAndStatus(@Param("vehicleId") String vehicleId, @Param("status") Integer status,
@Param("lastStatus") Integer lastStatus);
int updateStatus(@Param("vehicleId") String vehicleId, @Param("status") Integer status);
Vehicle selectByNumberPlate(String numberPlate);
List<UsableVehicleModelVO> searchUsableModel(Map<String, Object> params);
......
......@@ -16,6 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/cata")
@Slf4j
......@@ -146,7 +148,7 @@ public class VehicleCataController extends VehicleBaseController<VehiclePlatCata
* @return
*/
@GetMapping("/add/getCatasByIds/{ids}")
public ObjectRestResponse getCatasByIds(@PathVariable String ids){
public ObjectRestResponse<List<VehiclePlatCata>> getCatasByIds(@PathVariable String ids){
return baseBiz.getCatasByIds(ids);
}
......@@ -184,6 +186,8 @@ public class VehicleCataController extends VehicleBaseController<VehiclePlatCata
}
/* @RequestMapping(value = "/{id}", method = RequestMethod.GET)
public RestResponse<Vehicle> get(@PathVariable String id) {
return RestResponse.data(baseBiz.get(id));
......
......@@ -71,9 +71,10 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use
private VehicleJobHandler vehicleJobHandler;
@Autowired
BranchCompanyBiz branchCompanyBiz;
private VehicleBookHourInfoBiz vehicleBookHourInfoBiz;
@Autowired
VehicleBookHourInfoBiz vehicleBookHourInfoBiz;
BranchCompanyBiz branchCompanyBiz;
public UserFeign getUserFeign() {
return userFeign;
......
......@@ -3,7 +3,7 @@
<mapper namespace="com.xxfc.platform.vehicle.mapper.CompanyBaseMapper" >
<select id="getList" parameterType="com.xxfc.platform.vehicle.pojo.vo.CompanyVo" resultType="com.xxfc.platform.vehicle.pojo.vo.CompanyVo">
SELECT
SELECT
c.id as companyId,
c.`name` as companyName,
c.addr_detail as addrDetail,
......@@ -16,14 +16,14 @@
c.longitude,
c.vehice_service_phone as vehiceServicePhone,
c.tour_service_phone as tourServicePhone,
c.zone_id as zoneId,
b.zone_id as zoneId,
a.name as zoneName,
c.addr_province as addrProvince,
c.province_name as provinceName,
c.addr_city as addrCity,
c.city_name as cityName,
c.addr_town as addrTown,
c.town_name as townName,
b.addr_province as addrProvince,
b.province_name as provinceName,
b.addr_city as addrCity,
b.city_name as cityName,
b.addr_town as addrTown,
b.town_name as townName,
b.cover,
b.id,
b.`name`,
......@@ -34,25 +34,25 @@
r.total,
r.type,
r.price
FROM branch_company c
LEFT JOIN company_base b ON c.company_base_id=b.id
LEFT JOIN branch_company_stock_info_right r ON c.company_base_id=r.company_base_id
LEFT JOIN area a ON c.zone_id=a.id
FROM company_base b
LEFT JOIN branch_company c ON c.company_base_id=b.id
LEFT JOIN branch_company_stock_info_right r ON b.id=r.company_base_id
LEFT JOIN area a ON b.zone_id=a.id
<where>
b.is_del=0
<if test="zoneId != null and zoneId !='' ">
and c.zone_id = #{zoneId}
and b.zone_id = #{zoneId}
</if>
<if test="addrProvince != null and addrProvince != ''">
and c.addr_province =#{addrProvince}
and b.addr_province =#{addrProvince}
</if>
<if test="addrCity != null and addrCity != ''">
and c.addr_city =#{addrCity}
and b.addr_city =#{addrCity}
</if>
<if test="name != null and name != ''">
and b.`name` like CONCAT('%',#{name},'%')
and (b.`name` like CONCAT('%',#{name},'%') or c.`name` like CONCAT('%',#{name},'%') )
</if>
</where>
order by c.id desc
order by b.id desc
</select>
</mapper>
\ No newline at end of file
......@@ -380,7 +380,7 @@
</select>
<select id="selectByVehicleId" parameterType="java.lang.String"
resultType="com.xxfc.platform.vehicle.pojo.VehicleBookRecordVo">
resultMap="searchBookRecord">
SELECT v1.*,bc2.name retCompanyName from vehicle_book_record v1
LEFT JOIN branch_company bc2 on v1.ret_company = bc2.id
where v1.vehicle_id = #{vehicleId} and v1.status BETWEEN 1 and 2
......
......@@ -17,6 +17,13 @@
order by create_time desc
</select>
<select id="selectByVehicle" parameterType="java.lang.String" resultType="com.xxfc.platform.vehicle.entity.VehicleDepartureLog">
select vehicle_departure_log.*
from vehicle_departure_log
where vehicle_id = #{vehicleId}
order by create_time desc
</select>
<select id="selectByBookRecordId" parameterType="java.lang.Long" resultType="com.xxfc.platform.vehicle.pojo.VehicleDepartureLogVo">
select vehicle_departure_log.*
from vehicle_departure_log
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment