Commit a1748e7b authored by 周健威's avatar 周健威

Merge remote-tracking branch 'origin/base-modify' into base-modify

parents 1635e387 1a48b14a
......@@ -26,11 +26,11 @@ public class TourSpePriceDto {
//儿童人数
@ApiModelProperty(value = "儿童人数")
private String childNumber;
private Integer childNumber;
//"成人人数
@ApiModelProperty(value = "成人人数")
private String endTime;
private Integer number;
}
package com.xxfc.platform.tour.feign;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.tour.dto.TourSpePriceDto;
import com.xxfc.platform.tour.vo.TourSpePriceVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
/**
* ${DESCRIPTION}
*
* @author wanghaobin
* @create 2017-06-21 8:11
*/
@FeignClient(value = "xx-tour")
public interface TourFeign {
@RequestMapping(value = "/spe/user/prices", method = RequestMethod.POST)
public ObjectRestResponse<TourSpePriceVo> refund(@RequestBody TourSpePriceDto spePriceDto);
}
package com.xxfc.platform.tour.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* 等级金额表
*
* @author zjw
* @email nishijjo@qq.com
* @date 2019-06-06 11:41:51
*/
@Data
public class TourSpePriceVo {
//用户id
@ApiModelProperty(value = "/用户id")
private Integer userId;
//等级
@ApiModelProperty(value = "等级")
private Integer level;
//大人单价"
@ApiModelProperty(value = "大人单价")
private BigDecimal price;
//大人总价
@ApiModelProperty(value = "大人总价")
private BigDecimal totalPrice;
//儿童单价
@ApiModelProperty(value = "儿童单价")
private BigDecimal childPrice;
//儿童总价
@ApiModelProperty(value = "儿童总价")
private BigDecimal totaiChildPrice;
}
......@@ -14,7 +14,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@EnableDiscoveryClient
@EnableScheduling
@EnableAceAuthClient
@EnableFeignClients({"com.github.wxiaoqi.security.auth.client.feign","com.github.wxiaoqi.security.admin.feign"})
@EnableFeignClients({"com.github.wxiaoqi.security.auth.client.feign","com.github.wxiaoqi.security.admin.feign","com.xxfc.platform.tour.feign"})
@EnableAceCache
@tk.mybatis.spring.annotation.MapperScan(basePackages = "com.xxfc.platform.tour.mapper")
public class TourApplication {
......
package com.xxfc.platform.tour.biz;
import com.xxfc.platform.tour.mapper.TourGoodSpeMapper;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.tour.dto.TourSpePriceDto;
import com.xxfc.platform.tour.entity.TourGoodSpePrice;
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.stereotype.Service;
import com.xxfc.platform.tour.entity.TourGoodSpe;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import java.math.BigDecimal;
import java.math.RoundingMode;
/**
* 旅游商品规格表
*
......@@ -14,5 +24,55 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
* @date 2019-06-06 11:41:51
*/
@Service
public class TourGoodSpeBiz extends BaseBiz<TourGoodSpeMapper,TourGoodSpe> {
@Slf4j
public class TourGoodSpeBiz extends BaseBiz<TourGoodSpePriceMapper, TourGoodSpePrice> {
public ObjectRestResponse<TourSpePriceVo> getPricesByuserid(TourSpePriceDto priceDto) {
if (priceDto == null || priceDto.getUserId() == null || priceDto.getUserId() == 0 ||
priceDto.getNumber() == null || priceDto.getNumber() == 0||priceDto.getSpeId()==null) {
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数为空");
}
TourSpePriceVo priceVo = new TourSpePriceVo();
Integer speId = priceDto.getSpeId();
Integer number = priceDto.getNumber();
Integer childNumber = priceDto.getChildNumber() == null ? 0 : priceDto.getChildNumber();
if (speId != null) {
TourGoodSpePrice spePrice = mapper.selectByPrimaryKey(speId);
if (spePrice != null) {
Integer level = priceDto.getLevel();
priceVo.setUserId(priceDto.getUserId());
priceVo.setLevel(priceDto.getLevel());
BigDecimal price = spePrice.getPrice();
BigDecimal childPrice = spePrice.getChildPrice();
if (level != null && level > 0) {
String memberPrice = spePrice.getMemberPrice();
JSONArray array = JSONArray.parseArray(memberPrice);
if (array.size() > 0) {
for (Object obj : array) {
JSONObject jsonObject = JSONObject.parseObject(obj.toString());
Integer levels = jsonObject.getInteger("level");
if (level == levels) {
String money = jsonObject.getString("price");
price = new BigDecimal(StringUtils.isNotBlank(money) ? money : "0.00");
String childMoney = jsonObject.getString("child_price");
childPrice = new BigDecimal(StringUtils.isNotBlank(childMoney) ? childMoney : "0.00");
break;
}
}
}
}
BigDecimal totalPrice = price.multiply(new BigDecimal(number)).setScale(2, RoundingMode.HALF_UP);
BigDecimal totalChildPrice = childNumber > 0 ? price.multiply(new BigDecimal(childNumber)).setScale(2, RoundingMode.HALF_UP): new BigDecimal("0.00");
priceVo.setPrice(price);
priceVo.setChildPrice(childPrice);
priceVo.setTotalPrice(totalPrice);
priceVo.setTotaiChildPrice(totalChildPrice);
return ObjectRestResponse.succ(priceVo);
}
}
return ObjectRestResponse.createDefaultFail();
}
}
\ No newline at end of file
......@@ -6,10 +6,9 @@ import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.tour.biz.TourGoodSpeBiz;
import com.xxfc.platform.tour.common.TourBaseController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.xxfc.platform.tour.dto.TourSpePriceDto;
import com.xxfc.platform.tour.vo.TourSpePriceVo;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("spe")
......@@ -20,9 +19,8 @@ public class TourGoodSpeController extends TourBaseController<TourGoodSpeBiz> {
//获取商品详情
@RequestMapping(value = "/user/prices", method = RequestMethod.GET)
public ObjectRestResponse user() {
AppUserDTO userDTO=getUserInfo();
return ObjectRestResponse.succ(userDTO);
public ObjectRestResponse<TourSpePriceVo> user(@RequestBody TourSpePriceDto priceDto) {
return baseBiz.getPricesByuserid(priceDto);
}
}
\ 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