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

添加退款价格计算接口

parent 5612dbd2
...@@ -24,6 +24,10 @@ public class CommonBaseController { ...@@ -24,6 +24,10 @@ public class CommonBaseController {
@Autowired @Autowired
public HttpServletRequest request; public HttpServletRequest request;
public HttpServletRequest getRequest() {
return request;
}
public String getCurrentUserName(){ public String getCurrentUserName(){
return BaseContextHandler.getUsername(); return BaseContextHandler.getUsername();
} }
......
...@@ -36,7 +36,7 @@ public class Query extends LinkedHashMap<String, Object> { ...@@ -36,7 +36,7 @@ public class Query extends LinkedHashMap<String, Object> {
*/ */
public Query(PageParam pageParam){ public Query(PageParam pageParam){
this.putAll(BeanUtil.beanToMap(pageParam)); this.putAll(BeanUtil.beanToMap(pageParam));
//分页参数 //分页参数
if(pageParam.getPage() != null) { if(pageParam.getPage() != null) {
this.page = pageParam.getPage(); this.page = pageParam.getPage();
} }
......
...@@ -4,7 +4,7 @@ import java.util.HashMap; ...@@ -4,7 +4,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
public enum OrderTypeEnum { public enum OrderTypeEnum {
RentVehicle(1, "租车订单"), RENT_VEHICLE(1, "租车订单"),
TOUR(2, "旅游订单"), TOUR(2, "旅游订单"),
MEMBER(3, "会员订单"), MEMBER(3, "会员订单"),
; ;
...@@ -18,13 +18,6 @@ public enum OrderTypeEnum { ...@@ -18,13 +18,6 @@ public enum OrderTypeEnum {
private String desc; private String desc;
private static Map<Integer,String> codeAndDesc = new HashMap<Integer, String>(); private static Map<Integer,String> codeAndDesc = new HashMap<Integer, String>();
//Maps.newHashMap();
// static{
// for(VehicleBookRecordStatus constantType : VehicleBookRecordStatus.values()){
// codeAndDesc.put(constantType.getCode(),constantType.getDesc());
// }
// }
OrderTypeEnum(Integer code, String desc){ OrderTypeEnum(Integer code, String desc){
this.code=code; this.code=code;
...@@ -50,4 +43,13 @@ public enum OrderTypeEnum { ...@@ -50,4 +43,13 @@ public enum OrderTypeEnum {
public static Boolean exists(Integer code){ public static Boolean exists(Integer code){
return codeAndDesc.containsKey(code); return codeAndDesc.containsKey(code);
} }
public static OrderTypeEnum get(Integer code) {
for(OrderTypeEnum enumE : OrderTypeEnum.values()) {
if (enumE.getCode().equals(code)) {
return enumE;
}
}
return null;
}
} }
\ No newline at end of file
...@@ -9,7 +9,7 @@ import javax.persistence.Id; ...@@ -9,7 +9,7 @@ import javax.persistence.Id;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
@Data @Data
public class AddMemberDTO { public class AddMemberDTO extends AddOrderCommonDTO{
public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd"); public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
@ApiModelProperty(value = "会员等级id") @ApiModelProperty(value = "会员等级id")
...@@ -18,9 +18,4 @@ public class AddMemberDTO { ...@@ -18,9 +18,4 @@ public class AddMemberDTO {
@ApiModelProperty(value = "会员等级") @ApiModelProperty(value = "会员等级")
private Integer memberLevel; private Integer memberLevel;
/**
* 优惠券ids
*/
@ApiModelProperty(value = "优惠券ids")
private String couponIds;
} }
package com.xxfc.platform.order.pojo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class AddOrderCommonDTO {
/**
*
*/
@ApiModelProperty(value = "下单来源,1--app;2--小程序")
private Integer orderOrigin;
/**
* 优惠券ids
*/
@ApiModelProperty(value = "优惠券ids")
private String couponIds;
}
...@@ -10,7 +10,7 @@ import java.time.ZoneOffset; ...@@ -10,7 +10,7 @@ import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
@Data @Data
public class AddRentVehicleDTO{ public class AddRentVehicleDTO extends AddOrderCommonDTO{
public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd"); public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
//开始时间 //开始时间
...@@ -94,19 +94,6 @@ public class AddRentVehicleDTO{ ...@@ -94,19 +94,6 @@ public class AddRentVehicleDTO{
@ApiModelProperty(value = "是否使用出租免费天数") @ApiModelProperty(value = "是否使用出租免费天数")
private Integer rentFreeDay; private Integer rentFreeDay;
/**
*
*/
@ApiModelProperty(value = "下单来源,1--app;2--小程序")
private Integer orderOrigin;
/**
* 优惠券ids
*/
@ApiModelProperty(value = "优惠券ids")
private String couponIds;
public void setStartTime(Long startTime) { public void setStartTime(Long startTime) {
this.startTime = startTime; this.startTime = startTime;
this.bookStartDate = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startTime), ZoneOffset.ofHours(8))); this.bookStartDate = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startTime), ZoneOffset.ofHours(8)));
......
...@@ -10,7 +10,7 @@ import java.time.ZoneOffset; ...@@ -10,7 +10,7 @@ import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
@Data @Data
public class AddTourDTO { public class AddTourDTO extends AddOrderCommonDTO{
public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd"); public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
//开始时间 //开始时间
......
...@@ -2,7 +2,6 @@ package com.xxfc.platform.order.biz; ...@@ -2,7 +2,6 @@ package com.xxfc.platform.order.biz;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.github.wxiaoqi.security.admin.dto.UserMemberDTO; import com.github.wxiaoqi.security.admin.dto.UserMemberDTO;
import com.github.wxiaoqi.security.admin.entity.AppUserLogin;
import com.github.wxiaoqi.security.admin.feign.UserFeign; import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
...@@ -97,7 +96,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> { ...@@ -97,7 +96,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
private static Map<Integer, List<Integer>> cancelAble; private static Map<Integer, List<Integer>> cancelAble;
static { static {
cancelAble = new HashMap<Integer, List<Integer>>(); cancelAble = new HashMap<Integer, List<Integer>>();
cancelAble.put(OrderTypeEnum.RentVehicle.getCode(), new LinkedList<Integer>(){{ cancelAble.put(OrderTypeEnum.RENT_VEHICLE.getCode(), new LinkedList<Integer>(){{
add(OrderStatusEnum.ORDER_UNPAY.getCode()); add(OrderStatusEnum.ORDER_UNPAY.getCode());
add(OrderStatusEnum.ORDER_TOSTART.getCode()); add(OrderStatusEnum.ORDER_TOSTART.getCode());
}}); }});
...@@ -186,7 +185,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> { ...@@ -186,7 +185,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
//判断是否已支付 //判断是否已支付
if(SYS_TRUE.equals(baseOrder.getHasPay())) { if(SYS_TRUE.equals(baseOrder.getHasPay())) {
//判断订单类型 //判断订单类型
if(OrderTypeEnum.RentVehicle.getCode().equals(baseOrder.getType())) { if(OrderTypeEnum.RENT_VEHICLE.getCode().equals(baseOrder.getType())) {
OrderRentVehicleDetail orvd = orderRentVehicleBiz.selectOne(new OrderRentVehicleDetail(){{ OrderRentVehicleDetail orvd = orderRentVehicleBiz.selectOne(new OrderRentVehicleDetail(){{
setOrderId(baseOrder.getId()); setOrderId(baseOrder.getId());
}}); }});
...@@ -221,7 +220,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> { ...@@ -221,7 +220,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
} }
//处理取消流程 //处理取消流程
if(OrderTypeEnum.RentVehicle.getCode().equals(baseOrder.getType())) { if(OrderTypeEnum.RENT_VEHICLE.getCode().equals(baseOrder.getType())) {
OrderRentVehicleDetail orvd = orderRentVehicleBiz.selectOne(new OrderRentVehicleDetail(){{ OrderRentVehicleDetail orvd = orderRentVehicleBiz.selectOne(new OrderRentVehicleDetail(){{
setOrderId(baseOrder.getId()); setOrderId(baseOrder.getId());
}}); }});
...@@ -267,24 +266,33 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> { ...@@ -267,24 +266,33 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
} }
/** /**
* 租车退款流程(含押金) * 租车(包括旅游)退款流程(含押金)
* @param baseOrder * @param baseOrder
* @param depositAmont * @param depositAmount
* @param timeLag 与开始时间的时间差 * @param timeLag 与开始时间的时间差
* @param dicParentKey * @param dicParentKey
*/ */
private void rentRefundProcess(BaseOrder baseOrder, BigDecimal depositAmont, Long timeLag, String dicParentKey) { private void rentRefundProcess(BaseOrder baseOrder, BigDecimal depositAmount, Long timeLag, String dicParentKey) {
//计算退款金额 //计算退款金额
// 1、押金 + 租金(规则扣除) // 1、押金 + 租金(规则扣除)
BigDecimal refundGoodsAmount = baseOrder.getGoodsAmount(); //BigDecimal refundGoodsAmount = baseOrder.getGoodsAmount();
String refundDesc = "取消订单退款:"; String refundDesc = "取消订单退款:";
BigDecimal refundGoodsAmont = baseOrder.getGoodsAmount(); if(null == depositAmount) {
if(null == depositAmont) { depositAmount = BigDecimal.ZERO;
depositAmont = BigDecimal.ZERO;
} }
BigDecimal refundGoodsAmount = calculateRefund(baseOrder.getGoodsAmount(), timeLag, dicParentKey, refundDesc);
//退款金额
BigDecimal refundAmount = depositAmount.add(refundGoodsAmount);
//退款子流程: 订单基础,退款描述,退款金额
refundSubProcess(baseOrder, refundDesc, refundAmount, RefundTypeEnum.RentVehicle.getCode(), RefundStatusEnum.ALL.getCode());
}
public BigDecimal calculateRefund(BigDecimal goodsAmount, Long timeLag, String dicParentKey, String refundDesc) {
BigDecimal refundGoodsAmount = goodsAmount;
//根据时间处理goodsAmount //根据时间处理goodsAmount
//获取出发时间 到现在 距离时间 //获取出发时间 到现在 距离时间
Integer hourLag = Long.valueOf(timeLag/(1000L * 60L * 60L)).intValue(); Integer hourLag = Long.valueOf(timeLag/(1000L * 60L * 60L)).intValue();
Map<String, com.xxfc.platform.universal.entity.Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData(); Map<String, com.xxfc.platform.universal.entity.Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
...@@ -301,40 +309,37 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> { ...@@ -301,40 +309,37 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
//符合范围 //符合范围
if(IntervalUtil.staticIsInTheInterval(hourLag.toString(), names[0])){ if(IntervalUtil.staticIsInTheInterval(hourLag.toString(), names[0])){
refundGoodsAmont = new BigDecimal((IntervalUtil.evaluate(dic.getDetail(), new MapContext(){{ refundGoodsAmount = new BigDecimal((IntervalUtil.evaluate(dic.getDetail(), new MapContext(){{
//ga : goodsAmount //ga : goodsAmount
set("ga", baseOrder.getGoodsAmount()); set("ga", goodsAmount);
}})).toString()); }})).toString());
refundDesc = names[1]+ ","+ refundDesc; refundDesc = names[1]+ ","+ refundDesc;
break; break;
} }
} }
//退款金额 return refundGoodsAmount;
BigDecimal refundAmont = depositAmont.add(refundGoodsAmont);
//退款子流程: 订单基础,退款描述,退款金额
refundSubProcess(baseOrder, refundDesc, refundAmont, RefundTypeEnum.RentVehicle.getCode(), RefundStatusEnum.ALL.getCode());
} }
/** /**
* 退款子流程 * 退款子流程
* @param baseOrder * @param baseOrder
* @param refundDesc * @param refundDesc
* @param refundAmont * @param refundAmount
* @param refundType * @param refundType
* @param refundStatus * @param refundStatus
*/ */
public void refundSubProcess(BaseOrder baseOrder, String refundDesc, BigDecimal refundAmont, Integer refundType, Integer refundStatus) { public void refundSubProcess(BaseOrder baseOrder, String refundDesc, BigDecimal refundAmount, Integer refundType, Integer refundStatus) {
OrderRefundVo orv = new OrderRefundVo(){{ OrderRefundVo orv = new OrderRefundVo(){{
setAmount(baseOrder.getRealAmount().multiply(new BigDecimal("100")).intValue()); setAmount(baseOrder.getRealAmount().multiply(new BigDecimal("100")).intValue());
setOrderNo(baseOrder.getNo()); setOrderNo(baseOrder.getNo());
}}; }};
orv.setRefundDesc(refundDesc+ refundAmont.toString()); orv.setRefundDesc(refundDesc+ refundAmount.toString());
orv.setRefundAmount(refundAmont.multiply(new BigDecimal("100")).intValue()); orv.setRefundAmount(refundAmount.multiply(new BigDecimal("100")).intValue());
String refundTradeNo = thirdFeign.refund(orv).getData(); String refundTradeNo = thirdFeign.refund(orv).getData();
//记录订单退款记录 //记录订单退款记录
Integer flag = addOrderRefund(baseOrder.getId(), refundDesc, refundAmont, refundTradeNo, refundType); Integer flag = addOrderRefund(baseOrder.getId(), refundDesc, refundAmount, refundTradeNo, refundType);
//更新订单的退款状态和退款时间 //更新订单的退款状态和退款时间
if(SYS_TRUE.equals(flag) && null != refundStatus) { if(SYS_TRUE.equals(flag) && null != refundStatus) {
...@@ -351,10 +356,10 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> { ...@@ -351,10 +356,10 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
* 记录订单退款记录 * 记录订单退款记录
* @param orderId * @param orderId
* @param refundDesc * @param refundDesc
* @param refundAmont * @param refundAmount
* @param refundTradeNo * @param refundTradeNo
*/ */
private Integer addOrderRefund(Integer orderId, String refundDesc, BigDecimal refundAmont, String refundTradeNo, Integer refundType) { private Integer addOrderRefund(Integer orderId, String refundDesc, BigDecimal refundAmount, String refundTradeNo, Integer refundType) {
//如果返回的流水为空,则当做失败 //如果返回的流水为空,则当做失败
Integer refundStatus = SYS_TRUE; Integer refundStatus = SYS_TRUE;
if(StrUtil.isBlank(refundTradeNo)) { if(StrUtil.isBlank(refundTradeNo)) {
...@@ -368,7 +373,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> { ...@@ -368,7 +373,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
setTradeNo(refundTradeNo); setTradeNo(refundTradeNo);
setRefundType(RefundTypeEnum.RentVehicle.getCode()); setRefundType(RefundTypeEnum.RentVehicle.getCode());
}}; }};
orderRefund.setRefundAmount(refundAmont); orderRefund.setRefundAmount(refundAmount);
orderRefund.setRefundDesc(refundDesc); orderRefund.setRefundDesc(refundDesc);
orderRefund.setRefundStatus(refundStatus); orderRefund.setRefundStatus(refundStatus);
orderRefund.setRefundType(refundType); orderRefund.setRefundType(refundType);
...@@ -415,7 +420,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> { ...@@ -415,7 +420,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
setTotalNumber(omd.getRentFreeNum()); setTotalNumber(omd.getRentFreeNum());
}}); }});
log.info("orr.getStatus() : " + orr.getStatus() ); log.info("orr.getStatus() : " + orr.getStatus() );
}else if(OrderTypeEnum.RentVehicle.getCode().equals(baseOrder.getType())) { }else if(OrderTypeEnum.RENT_VEHICLE.getCode().equals(baseOrder.getType())) {
updateOrder.setStatus(OrderStatusEnum.ORDER_TOSTART.getCode()); updateOrder.setStatus(OrderStatusEnum.ORDER_TOSTART.getCode());
OrderRentVehicleDetail orvd = orderRentVehicleBiz.selectOne(new OrderRentVehicleDetail(){{ OrderRentVehicleDetail orvd = orderRentVehicleBiz.selectOne(new OrderRentVehicleDetail(){{
setOrderId(baseOrder.getId()); setOrderId(baseOrder.getId());
......
...@@ -56,7 +56,8 @@ public class WebConfiguration implements WebMvcConfigurer { ...@@ -56,7 +56,8 @@ public class WebConfiguration implements WebMvcConfigurer {
"/orderRentVehicle/**", "/orderRentVehicle/**",
"/baseOrder/**", "/baseOrder/**",
"/orderTour/**", "/orderTour/**",
"/orderMember/**" "/orderMember/**",
"/orderRefund/**"
}; };
Collections.addAll(list, urls); Collections.addAll(list, urls);
return list; return list;
......
...@@ -61,7 +61,7 @@ public class RentDepositHandler extends IJobHandler { ...@@ -61,7 +61,7 @@ public class RentDepositHandler extends IJobHandler {
if(IntervalUtil.staticIsInTheInterval(String.valueOf(i), idLastNumInterval)) { if(IntervalUtil.staticIsInTheInterval(String.valueOf(i), idLastNumInterval)) {
List<BaseOrder> lists = baseOrderBiz.selectByExample(new Example.Builder(BaseOrder.class) List<BaseOrder> lists = baseOrderBiz.selectByExample(new Example.Builder(BaseOrder.class)
//订单已完成的租车订单 //订单已完成的租车订单
.where(WeekendSqls.<BaseOrder>custom().andEqualTo(BaseOrder::getType, OrderTypeEnum.RentVehicle) .where(WeekendSqls.<BaseOrder>custom().andEqualTo(BaseOrder::getType, OrderTypeEnum.RENT_VEHICLE)
.andEqualTo(BaseOrder::getStatus, OrderStatusEnum.ORDER_FINISH) .andEqualTo(BaseOrder::getStatus, OrderStatusEnum.ORDER_FINISH)
.andLike(BaseOrder::getId, "%"+ String.valueOf(i))).build()); .andLike(BaseOrder::getId, "%"+ String.valueOf(i))).build());
...@@ -89,7 +89,7 @@ public class RentDepositHandler extends IJobHandler { ...@@ -89,7 +89,7 @@ public class RentDepositHandler extends IJobHandler {
}else if(RefundStatusEnum.RESIDUE_ILLEGAL.getCode().equals(baseOrder.getRefundStatus())){ }else if(RefundStatusEnum.RESIDUE_ILLEGAL.getCode().equals(baseOrder.getRefundStatus())){
//判断是否违章 //判断是否违章
//扣违章的钱 //扣违章的钱
//baseOrderBiz.refundSubProcess(baseOrder, refundDesc, refundAmont, RefundTypeEnum.RentVehicle.getCode(), RefundStatusEnum.RESIDUE_ILLEGAL.getCode()); //baseOrderBiz.refundSubProcess(baseOrder, refundDesc, refundAmont, RefundTypeEnum.RENT_VEHICLE.getCode(), RefundStatusEnum.RESIDUE_ILLEGAL.getCode());
} }
// baseOrderBiz.refundSubProcess(baseOrder, refundDesc, refundAmont); // baseOrderBiz.refundSubProcess(baseOrder, refundDesc, refundAmont);
} }
......
...@@ -25,6 +25,7 @@ import com.xxfc.platform.order.entity.BaseOrder; ...@@ -25,6 +25,7 @@ import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.mqhandler.RabbitProduct; import com.xxfc.platform.order.mqhandler.RabbitProduct;
import com.xxfc.platform.order.pojo.order.*; import com.xxfc.platform.order.pojo.order.*;
import com.xxfc.platform.order.pojo.pay.OrderPayDTO; import com.xxfc.platform.order.pojo.pay.OrderPayDTO;
import com.xxfc.platform.order.rest.common.CommonInterface;
import com.xxfc.platform.universal.constant.DictionaryKey; import com.xxfc.platform.universal.constant.DictionaryKey;
import com.xxfc.platform.universal.entity.Dictionary; import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.feign.ThirdFeign; import com.xxfc.platform.universal.feign.ThirdFeign;
...@@ -57,7 +58,7 @@ import static com.xxfc.platform.universal.constant.DictionaryKey.APP_ORDER; ...@@ -57,7 +58,7 @@ import static com.xxfc.platform.universal.constant.DictionaryKey.APP_ORDER;
@RequestMapping("baseOrder") @RequestMapping("baseOrder")
@Api(value = "订单", tags = {"订单"}) @Api(value = "订单", tags = {"订单"})
@Slf4j @Slf4j
public class BaseOrderController extends CommonBaseController { public class BaseOrderController extends CommonBaseController implements CommonInterface {
public static final Integer STATUS_SUCCESS = 1; public static final Integer STATUS_SUCCESS = 1;
@Autowired @Autowired
...@@ -74,6 +75,11 @@ public class BaseOrderController extends CommonBaseController { ...@@ -74,6 +75,11 @@ public class BaseOrderController extends CommonBaseController {
@Autowired @Autowired
OrderMemberDetailBiz orderMemberDetailBiz; OrderMemberDetailBiz orderMemberDetailBiz;
@Override
public UserFeign getUserFeign() {
return userFeign;
}
@Value("${gateway.insideHost}") @Value("${gateway.insideHost}")
String insideHost; String insideHost;
...@@ -237,11 +243,9 @@ public class BaseOrderController extends CommonBaseController { ...@@ -237,11 +243,9 @@ public class BaseOrderController extends CommonBaseController {
@ResponseBody @ResponseBody
public ObjectRestResponse<OrderPageVO> get(@PathVariable String no) { public ObjectRestResponse<OrderPageVO> get(@PathVariable String no) {
log.info("no:"+ no + ",时间戳:"+ System.currentTimeMillis()); log.info("no:"+ no + ",时间戳:"+ System.currentTimeMillis());
//查询列表数据 checkAppUser();
if (StringUtils.isBlank(BaseContextHandler.getUserID())) {
throw new BaseException(ResultCode.AJAX_WECHAT_NOTEXIST_CODE);
}
//查询列表数据
Query query = initQuery(no); Query query = initQuery(no);
PageDataVO<OrderPageVO> page = PageDataVO.pageInfo(query, () -> baseOrderBiz.pageByParm(query.getSuper())); PageDataVO<OrderPageVO> page = PageDataVO.pageInfo(query, () -> baseOrderBiz.pageByParm(query.getSuper()));
if (page.getData().isEmpty()) { if (page.getData().isEmpty()) {
......
package com.xxfc.platform.order.rest; package com.xxfc.platform.order.rest;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
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.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.vo.PageParam;
import com.xxfc.platform.order.biz.BaseOrderBiz;
import com.xxfc.platform.order.biz.OrderRefundBiz; import com.xxfc.platform.order.biz.OrderRefundBiz;
import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
import com.xxfc.platform.order.entity.OrderRefund; import com.xxfc.platform.order.entity.OrderRefund;
import com.xxfc.platform.order.pojo.order.OrderPageVO;
import com.xxfc.platform.order.rest.common.CommonInterface;
import com.xxfc.platform.universal.constant.DictionaryKey;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.math.BigDecimal;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE;
@Controller @Controller
@RequestMapping("orderRefund") @RequestMapping("orderRefund")
public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRefund> { public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRefund> implements CommonInterface {
@Autowired
BaseOrderBiz baseOrderBiz;
@Autowired
UserFeign userFeign;
@Override
public UserFeign getUserFeign() {
return userFeign;
}
@RequestMapping(value = "/price/calculate/{type}/{no}", method = RequestMethod.GET)
@ResponseBody
@IgnoreClientToken
public ObjectRestResponse getOrderParam(@PathVariable(value = "no") String type, @PathVariable(value = "no") String no) {
checkAppUser();
//根据no 查订单
OrderPageVO orderPageVO = baseOrderBiz.pageByParm(new Query(new PageParam(){{
setLimit(1);
setPage(1);
}}){{put("no", no); }}.getSuper()).get(0);
OrderRefundPriceVO orp = new OrderRefundPriceVO(){{
setRealAmount(orderPageVO.getRealAmount());
}};
OrderTypeEnum orderTypeEnum = OrderTypeEnum.get(orderPageVO.getType());
switch (orderTypeEnum) {
case RENT_VEHICLE:
// orp.setRefundGoodsAmount(baseOrderBiz.calculateRefund(orderPageVO.getGoodsAmount()
// , System.currentTimeMillis() - orderPageVO.getOrderRentVehicleDetail().getStartTime()
// , DictionaryKey.APP_ORDER+ "_"+ DictionaryKey.RENT_REFUND
// , "取消订单退款:"));
break;
case TOUR:
String dicParentKey = DictionaryKey.APP_ORDER+ "_"+ DictionaryKey.TOUR_REFUND;
//不是省外,
if(SYS_FALSE.equals(orderPageVO.getOrderTourDetail().getIsOutside())) {
dicParentKey = DictionaryKey.APP_ORDER+ "_"+ DictionaryKey.TOUR_IN_REFUND;
}
orp.setRefundAmount(baseOrderBiz.calculateRefund(orderPageVO.getGoodsAmount()
, System.currentTimeMillis() - orderPageVO.getOrderRentVehicleDetail().getStartTime()
, DictionaryKey.APP_ORDER+ "_"+ DictionaryKey.RENT_REFUND
, "取消订单退款:"));
break;
default:
// orp.setRefundAmount(orderPageVO);
break;
}
return null;
}
@Data
public class OrderRefundPriceVO {
BigDecimal refundAmount;
BigDecimal realAmount;
BigDecimal cutAmount;
public void setRefundAmount(BigDecimal refundAmount) {
this.refundAmount = refundAmount;
this.cutAmount = realAmount.multiply(refundAmount);
}
}
} }
\ No newline at end of file
package com.xxfc.platform.order.rest.common;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.common.context.BaseContextHandler;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import javax.servlet.http.HttpServletRequest;
public interface CommonInterface {
public UserFeign getUserFeign();
public HttpServletRequest getRequest();
default AppUserDTO getAppUser(){
return getUserFeign().userDetailByToken(BaseContextHandler.getToken()).getData();
}
default void checkAppUser(){
if(null == getAppUser()) {
throw new BaseException(ResultCode.DB_OPERATION_FAIL_CODE);
}
}
}
...@@ -26,7 +26,6 @@ import com.xxfc.platform.vehicle.entity.VehicleBookRecord; ...@@ -26,7 +26,6 @@ import com.xxfc.platform.vehicle.entity.VehicleBookRecord;
import com.xxfc.platform.vehicle.entity.VehicleModel; import com.xxfc.platform.vehicle.entity.VehicleModel;
import com.xxfc.platform.vehicle.feign.VehicleFeign; import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.RentVehicleBookDTO; import com.xxfc.platform.vehicle.pojo.RentVehicleBookDTO;
import lombok.extern.log4j.Log4j;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -70,7 +69,7 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -70,7 +69,7 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
@PostConstruct @PostConstruct
public void init(){ public void init(){
this.orderTypeEnum = OrderTypeEnum.RentVehicle; this.orderTypeEnum = OrderTypeEnum.RENT_VEHICLE;
} }
......
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