Commit 1535edf6 authored by hezhen's avatar hezhen

修改后台

parent 3f5111c7
package com.xxfc.platform.tour.biz;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.wxiaoqi.security.admin.entity.BaseUserMemberLevel;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.constant.RestCode;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
......@@ -17,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -33,13 +38,16 @@ import java.util.Map;
public class TourGoodBiz extends BaseBiz<TourGoodMapper, TourGood> {
@Autowired
private TourGoodBannerMapper bannerMapper;
private TourGoodBannerBiz bannerBiz;
@Autowired
private TourGoodSiteMapper siteMapper;
private TourGoodSiteBiz siteBiz;
@Autowired
private TourGoodTagMapper tagMapper;
private TourGoodTagBiz tagBiz;
@Autowired
private TourGoodSpePriceMapper priceMapper;
private TourGoodSpeBiz speBiz;
@Autowired
private UserFeign userFeign;
/**
* 查询旅游路线列表
......@@ -86,9 +94,12 @@ public class TourGoodBiz extends BaseBiz<TourGoodMapper, TourGood> {
}
TourGood good=new TourGood();
try {
Long times=System.currentTimeMillis();
BeanUtils.copyProperties(good,dto);
Integer goodId=good.getId();
good.setUpdTime(times);
if(goodId==null||goodId==0){
good.setCrtTime(times);
mapper.insertSelective(good);
goodId=good.getId();
}else {
......@@ -103,9 +114,9 @@ public class TourGoodBiz extends BaseBiz<TourGoodMapper, TourGood> {
BeanUtils.copyProperties(goodBanner,bannerDTO);
goodBanner.setGoodId(goodId);
if(bannerId==null||bannerId==0){
bannerMapper.insertSelective(goodBanner);
bannerBiz.insertSelective(goodBanner);
}else {
bannerMapper.updateByPrimaryKeySelective(goodBanner);
bannerBiz.updateSelectiveById(goodBanner);
}
}
}
......@@ -117,9 +128,9 @@ public class TourGoodBiz extends BaseBiz<TourGoodMapper, TourGood> {
BeanUtils.copyProperties(site,siteDTO);
site.setGoodId(goodId);
if(siteId==null||siteId==0){
siteMapper.insertSelective(site);
siteBiz.insertSelective(site);
}else {
siteMapper.updateByPrimaryKeySelective(site);
siteBiz.updateById(site);
}
}
}
......@@ -132,9 +143,9 @@ public class TourGoodBiz extends BaseBiz<TourGoodMapper, TourGood> {
BeanUtils.copyProperties(tag,tagDTO);
tag.setGoodId(goodId);
if(tagId==null||tagId==0){
tagMapper.insertSelective(tag);
tagBiz.insertSelective(tag);
}else {
tagMapper.updateByPrimaryKeySelective(tag);
tagBiz.updateById(tag);
}
}
}
......@@ -149,11 +160,31 @@ public class TourGoodBiz extends BaseBiz<TourGoodMapper, TourGood> {
spePrice.setPrice(price);
spePrice.setChildPrice(childPrice);
spePrice.setGoodId(goodId);
List<BaseUserMemberLevel> levelsList=userFeign.levels();
if(levelsList.size()>0){
JSONArray array=new JSONArray();
for(BaseUserMemberLevel memberLevel :levelsList){
JSONObject obj=new JSONObject();
Integer level=memberLevel.getLevel();
Integer discount=memberLevel.getDiscount();
BigDecimal price1=price.multiply(new BigDecimal(discount+"")).divide(new BigDecimal("100"))
.setScale(2, RoundingMode.HALF_UP);
BigDecimal price2=childPrice.multiply(new BigDecimal(discount+"")).divide(new BigDecimal("100"))
.setScale(2, RoundingMode.HALF_UP);
obj.put("level",level);
obj.put("price",price1);
obj.put("childPrice",price2);
array.add(obj);
}
if(array.size()>0){
String json=array.toJSONString();
spePrice.setMemberPrice(json);
}
}
if(priceId==null||priceId==0){
priceMapper.insertSelective(spePrice);
speBiz.insertSelective(spePrice);
}else {
priceMapper.updateByPrimaryKeySelective(spePrice);
speBiz.updateById(spePrice);
}
}
}
......
package com.xxfc.platform.tour.rest.admin;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.xxfc.platform.tour.biz.TourGoodBiz;
import com.xxfc.platform.tour.dto.GoodSearchDTO;
import com.xxfc.platform.tour.dto.TourGoodDTO;
import com.xxfc.platform.tour.entity.TourGood;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("good")
@IgnoreClientToken
public class TouGoodAdminController extends BaseController<TourGoodBiz, TourGood> {
@ApiOperation("后台查询旅游路线列表")
@RequestMapping(value = "/admin/goodList", method = RequestMethod.GET)
public ObjectRestResponse<TourGood> goodList(@RequestBody GoodSearchDTO dto) {
return ObjectRestResponse.succ(baseBiz.getAll(dto));
}
@ApiOperation("后台查询旅游路线列表")
@RequestMapping(value = "/admin/goodEdit", method = RequestMethod.GET)
public ObjectRestResponse<TourGood> goodEdit(@RequestBody TourGoodDTO dto) {
return ObjectRestResponse.succ(baseBiz.goodsEdit(dto));
}
}
\ No newline at end of file
......@@ -4,6 +4,8 @@ import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.xxfc.platform.tour.biz.TourGoodBiz;
import com.xxfc.platform.tour.dto.GoodSearchDTO;
import com.xxfc.platform.tour.dto.TourGoodDTO;
import com.xxfc.platform.tour.entity.TourGood;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
......@@ -13,25 +15,17 @@ import org.springframework.web.bind.annotation.*;
@IgnoreClientToken
public class TourGoodAdminController extends BaseController<TourGoodBiz, TourGood> {
/**
* 查询旅游路线列表
*
* @param page
* @param limit
* @param query
* @param latitude
* @param longitude
* @param tagId
* @param distance
* @return
*/
@ApiOperation("查询旅游路线列表")
@RequestMapping(value = "//getGoodList", method = RequestMethod.GET)
@ApiOperation("后台查询旅游路线列表")
@RequestMapping(value = "/admin/goodList", method = RequestMethod.GET)
public ObjectRestResponse<TourGood> goodList(@RequestBody GoodSearchDTO dto) {
return ObjectRestResponse.succ(baseBiz.getAll(dto));
}
public ObjectRestResponse<TourGood> getGoodList(@RequestParam(value = "page", required = true) Integer page, @RequestParam(value = "limit", required = true) Integer limit,
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "latitude", required = false) Double latitude,
@RequestParam(value = "longitude", required = false) Double longitude, @RequestParam(value = "tagId", required = false) Integer tagId,
@RequestParam(value = "distance", defaultValue = "10.00") Double distance) {
return baseBiz.getGoodList(page, limit, query, latitude, longitude, tagId, distance);
@ApiOperation("后台查询旅游路线列表")
@RequestMapping(value = "/admin/goodEdit", method = RequestMethod.GET)
public ObjectRestResponse<TourGood> goodEdit(@RequestBody TourGoodDTO dto) {
return ObjectRestResponse.succ(baseBiz.goodsEdit(dto));
}
}
\ No newline at end of file
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