Commit 4ccbc618 authored by hanfeng's avatar hanfeng

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	ace-modules/ace-admin-api/src/main/java/com/github/wxiaoqi/security/admin/feign/UserFeign.java
#	ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rest/AppUserController.java
#	ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rpc/AppUserRest.java
#	xx-order/xx-order-server/src/main/java/com/xxfc/platform/order/biz/inner/OrderCalculateBiz.java
#	xx-order/xx-order-server/src/main/java/com/xxfc/platform/order/biz/inner/OrderCancelBiz.java
#	xx-order/xx-order-server/src/main/java/com/xxfc/platform/order/rest/OrderRefundController.java
#	xx-vehicle/xx-vehicle-api/src/main/java/com/xxfc/platform/vehicle/feign/VehicleFeign.java
parents 9e0c1ce1 81ce0510
package com.github.wxiaoqi.security.admin.feign;
import com.github.wxiaoqi.security.admin.bo.UserBo;
import com.github.wxiaoqi.security.admin.dto.UserMemberDTO;
import com.github.wxiaoqi.security.admin.entity.AppUserLogin;
import com.github.wxiaoqi.security.admin.entity.BaseUserMember;
......@@ -141,5 +142,13 @@ public interface UserFeign {
@RequestParam(value = "reason",required = false) String reason,
@RequestParam(value = "isSuccess") Boolean isSuccess);
}
@GetMapping(value = "/app/user/users")
List<Integer> findAppUserIds(@RequestParam(value = "phone",required = false) String phone,
@RequestParam(value = "leaderPhone",required = false) String leaderPhone,
@RequestParam(value = "name",required = false) String name);
@PostMapping(value = "/app/user/users/info")
List<UserBo> findUserDetailByUserBo(@RequestBody(required = false) List<UserBo> userBos);
}
......@@ -93,5 +93,6 @@ public class AppUserDTO {
private Boolean isBindWx;
private Boolean isBindAliPay;
private Boolean isBindQQ;
//用户上线
private Integer parentId;
}
......@@ -19,6 +19,7 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.msg.TableResultResponse;
import com.github.wxiaoqi.security.common.rest.CommonBaseController;
import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.order.feign.OrderFeign;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
......@@ -74,6 +75,9 @@ public class AppUserController extends CommonBaseController{
@Autowired
private AppUserAlipayBiz appUserAlipayBiz;
@Autowired
private AppUserRelationBiz relationBiz;
@GetMapping("page")
......@@ -145,7 +149,7 @@ public class AppUserController extends CommonBaseController{
throw new Exception();
}
Integer id= userVo.getId();
Integer positionId=userVo.getPositionId();
Integer positionId=userVo.getPositionId();
BeanUtils.copyProperties(userDTO,userVo);
if(userVo.getIsMember()!=null&&userVo.getIsMember()>0){
//获取用户会员信息
......@@ -159,7 +163,6 @@ public class AppUserController extends CommonBaseController{
String icon=memberLevel.getIcon();
userDTO.setIcon(icon);
userDTO.setBigIcon(memberLevel.getBigIcon());
userDTO.setItemImg(memberLevel.getItemImg());
}
}
}
......@@ -167,7 +170,20 @@ public class AppUserController extends CommonBaseController{
if (userPosition!=null&&userPosition.getLevel()>0){
userDTO.setPositionName(userPosition.getName());
}
AppUserRelation relation=relationBiz.getRelationByIdUserIdAndTime(userid);
Integer parentId=0;
if (relation!=null){
parentId=relation.getParentId();
}
userDTO.setParentId(parentId);
List<AppUserAlipay> appUserAlipays = appUserAlipayBiz.getByUserId(request);
long count = appUserAlipays.stream().filter(appUserAlipay -> appUserAlipay.getType() == 1).count();
userDTO.setIsBindAliPay(count>0);
userDTO.setId(id);
userDTO.setAliPayNickName(userDTO.getIsBindAliPay()?appUserAlipays.get(0).getNickname():"");
AppUserLogin appUserLogin = appUserLoginBiz.selectById(userid);
userDTO.setIsBindWx(StringUtils.isNotEmpty(appUserLogin.getWxOpenid()));
userDTO.setIsBindQQ(StringUtils.isNotEmpty(appUserLogin.getOpenid()));
return ObjectRestResponse.succ(userDTO);
}
......@@ -217,7 +233,7 @@ public class AppUserController extends CommonBaseController{
appUserLogin.setOpenid(userVo.getOpenid());
appUserLogin.setId(userid);
appUserLogin.setUsername(userVo.getUsername());
appUserLoginBiz.updateAppuserLogin(appUserLogin);
appUserLoginBiz.bindOpenid(appUserLogin);
//支付宝绑定
if (StringUtils.isNotEmpty(userVo.getAliCode()) && userVo.getAliCode().trim().length()>0){
appUserAlipayBiz.getUserInfo(userVo.getAliCode(),request);
......@@ -300,7 +316,7 @@ public class AppUserController extends CommonBaseController{
}
@GetMapping("/findusersByIds")
public Map<Integer,AppUserLogin> findAppUsersByUserIds(@RequestParam(value = "userIds") List<Integer> userIds){
return appUserLoginBiz.findUserIdAndUserLoginMapByMemberIds(userIds);
return appUserLoginBiz.findUserIdAndUserLoginMapByMemberIds(userIds);
}
@GetMapping("/finduserIdsByphones")
......@@ -312,8 +328,8 @@ public class AppUserController extends CommonBaseController{
@IgnoreUserToken
@IgnoreClientToken
public ObjectRestResponse<AppUserInfoVo> findUserInfoByCode(@PathVariable("code") String code){
AppUserInfoVo appUserInfoVo = userDetailBiz.findUserInfoByCode(code);
return ObjectRestResponse.succ(appUserInfoVo);
AppUserInfoVo appUserInfoVo = userDetailBiz.findUserInfoByCode(code);
return ObjectRestResponse.succ(appUserInfoVo);
}
@GetMapping("/app/unauth/getUserIdByUsername")
......@@ -331,6 +347,8 @@ public class AppUserController extends CommonBaseController{
return appUserLoginBiz.test();
}
@PostMapping("/bind")
private ObjectRestResponse accountBinding(@RequestBody AccountBindDTO accountBindDTO, HttpServletRequest request){
try {
......
......@@ -255,7 +255,7 @@ public class AppUserRest {
@ApiModelProperty("检查手机号验证码")
@GetMapping("/unauth/checkMobilecode")
public ObjectRestResponse checkMobilecode(@RequestParam(value = "phone") String phone,
@RequestParam(value = "mobilecode") String mobilecode) {
@RequestParam(value = "mobilecode") String mobilecode) {
if (StringUtils.isBlank(phone) || StringUtils.isBlank(mobilecode)) {
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数为空");
}
......@@ -264,7 +264,6 @@ public class AppUserRest {
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, "验证码错误");
}
return ObjectRestResponse.succ();
}
@ApiModelProperty("修改手机号码")
......
......@@ -215,6 +215,23 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
orv.setOrderNo(baseOrder.getNo());
orv.setRefundDesc(refundDesc+ refundAmount.toString());
orv.setRefundAmount(refundAmount.multiply(new BigDecimal("100")).intValue());
// originalRefundAmount - refundAmount
Integer freeze2PayAmount = originalRefundAmount.subtract(refundAmount).multiply(new BigDecimal("100")).intValue();
if(AccountTypeEnum.OUT_PART_DEPOSIT.getCode().equals(refundType)) {
// freeze2PayAmount - 违章保证金
for(OrderAccountDeduction deduction : oad.getDeductions()) {
if(DeductionTypeEnum.VIOLATE_TRAFFIC_KEEP.getCode().equals(deduction.getType())) {
freeze2PayAmount -= deduction.getAmount().multiply(new BigDecimal("100")).intValue();
break;
}
}
}
orv.setFreeze2PayAmount(freeze2PayAmount);
orv.setFreeze2PayDesc("");
ObjectRestResponse<String> result = thirdFeign.refund(orv);
refundTradeNo = result.getData();
if(null == refundTradeNo) {
......@@ -399,9 +416,7 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
BigDecimal originalRefundAmount = oad.getOriginDepositAmount().add(oad.getOriginOrderAmount());
//crosstown.getRestDeposit().add(crosstown.getDeductionCost()).subtract(illegalReserve);
String refundDesc = "退还押金:"+ refundAmont.toString()+ "(已扣除 违章预备金:"+ illegalReserve.toString();
refundDesc += handleDedRefundDesc;
refundDesc += ")";
String refundDesc = "退还车辆押金:"+ refundAmont.toString();
//还车扣除款 剩余的 钱,再减去违章预备金
oad.getDeductions().add(
......
......@@ -170,9 +170,9 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
OrderRentVehicleDetail orderRentVehicleDetail = orderRentVehicleBiz.selectById(baseOrder.getDetailId());
if (orderVehicleCrosstownDto.getType() == CrosstownTypeEnum.DEPARTURE.getCode()) {
boolean flag = getTodayTime(orderRentVehicleDetail.getStartTime());
boolean flag = getTodayTime(orderRentVehicleDetail.getStartTime(), orderRentVehicleDetail.getEndTime());
if (!flag) {
return ObjectRestResponse.createFailedResult(3502, "已超过预定还车时间,不能进行交车操作!");
return ObjectRestResponse.createFailedResult(3502, "今日不是交车日期");
}
if (null == userDTO.getCompanyId() || !userDTO.getCompanyId().equals(orderRentVehicleDetail.getStartCompanyId())) {
return ObjectRestResponse.createFailedResult(3501, "无交车权限");
......@@ -438,9 +438,15 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
return illegalReserve;
}
public boolean getTodayTime(Long time) {
/**
* 当前时间大于预定开始时间当天0点,小于结束时间当天时间24点 2019.11.04
* @param startTime
* @param endTime
* @return
*/
public boolean getTodayTime(Long startTime, Long endTime) {
long current = System.currentTimeMillis();
if (current <= (getDayStart(time) + 24 * 60 * 60 * 1000 - 1) && current >= getDayStart(time)) {
if (getDayStart(startTime) <= (current) && current <= getDayStart(endTime) + 1000 * 3600 * 24 - 1) {
return true;
}
return false;
......
......@@ -7,14 +7,17 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.common.constant.CommonConstants;
import com.xxfc.platform.activity.entity.Coupon;
import com.xxfc.platform.activity.feign.ActivityFeign;
import com.xxfc.platform.app.feign.ConfigFeign;
import com.xxfc.platform.order.biz.BaseOrderBiz;
import com.xxfc.platform.order.biz.OrderAccountBiz;
import com.xxfc.platform.order.biz.OrderItemBiz;
import com.xxfc.platform.order.contant.enumerate.DeductionTypeEnum;
import com.xxfc.platform.order.contant.enumerate.ItemTypeEnum;
import com.xxfc.platform.order.contant.enumerate.OrderStatusEnum;
import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.OrderItem;
import com.xxfc.platform.order.entity.OrderRentVehicleDetail;
......@@ -22,19 +25,29 @@ import com.xxfc.platform.order.pojo.account.OrderAccountDeduction;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import com.xxfc.platform.order.pojo.calculate.InProgressVO;
import com.xxfc.platform.order.pojo.order.VehicleItemDTO;
import com.xxfc.platform.order.pojo.calculate.OrderRefundPriceVO;
import com.xxfc.platform.order.pojo.order.OrderPageVO;
import com.xxfc.platform.universal.constant.DictionaryKey;
import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO;
import com.xxfc.platform.vehicle.pojo.dto.order.VMCalendarPriceCostDTO;
import lombok.extern.slf4j.Slf4j;
import org.assertj.core.util.Lists;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
import static com.xxfc.platform.universal.constant.DictionaryKey.*;
/**
* 订单退款记录表
......@@ -68,6 +81,9 @@ public class OrderCalculateBiz {
@Autowired
OrderAccountBiz orderAccountBiz;
@Autowired
BaseOrderBiz baseOrderBiz;
public InProgressVO inProgressCalculate(BaseOrder baseOrder, VehicleItemDTO vehicleItemDTO, Integer freeDays, Integer useDays, OrderAccountDetail oad, Boolean isCancel) {
BigDecimal refundAmount = BigDecimal.ZERO;
BigDecimal consumeAmount = BigDecimal.ZERO;
......@@ -263,4 +279,124 @@ public class OrderCalculateBiz {
oad.setOriginOrderAmount(baseOrder.getGoodsAmount().subtract(baseOrder.getCouponAmount()));
return inProgressVO;
}
/**
* 计算包含多少天
* @param startLong
* @param endLong
* @return
*/
public Integer getIncludeDays(Long startLong, Long endLong) {
Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
Long hourLong = (60L * 60L * 1000L);
Long dayLong = hourLong * 24;
Long bufferLong = Long.valueOf(dictionaryMap.get(APP_ORDER+ "_"+ DictionaryKey.RENT_TIME_BUFFER).getDetail()) * hourLong;
//计算:使用天数 当前时间 - 开始时间的0时0分0秒
Long bookTimeLag = endLong - startLong;
log.info("bookTimeLag {}", new BigDecimal(bookTimeLag + ""));
log.info("divide {}", new BigDecimal((24 * 60 * 60 * 1000)+ ""));
Integer bookDays = new BigDecimal(bookTimeLag + "").divide(new BigDecimal(dayLong+ ""), 0, RoundingMode.DOWN).intValue();
Long excess = bookTimeLag%dayLong;
if(excess > bufferLong) {
bookDays += 1;
}
if(0 == bookDays) {
bookDays = 1;
}
return bookDays;
}
public OrderRefundPriceVO getPriceCalculate (String no, OrderPageVO orderPageVO) {
//根据no 查订单
OrderTypeEnum orderTypeEnum = OrderTypeEnum.get(orderPageVO.getType());
BigDecimal totalRefundAmount = BigDecimal.ZERO;
BigDecimal totalDeductAmount = BigDecimal.ZERO;
StringBuilder refundDescBuilder = new StringBuilder("");
String refundDesc = "";
InProgressVO inProgressVO = new InProgressVO();
BigDecimal topAmount = BigDecimal.ZERO;
switch (orderTypeEnum) {
case RENT_VEHICLE:
DateTime nowTime = DateTime.parse(DateTime.now().toString(CommonConstants.YMR_SLASH_FORMATTER_JODA), CommonConstants.YMR_SLASH_FORMATTER_JODA);
DateTime startTime = DateTime.parse(new DateTime(orderPageVO.getOrderRentVehicleDetail().getStartTime()).toString(CommonConstants.YMR_SLASH_FORMATTER_JODA), CommonConstants.YMR_SLASH_FORMATTER_JODA);
DateTime endTime = DateTime.parse(new DateTime(orderPageVO.getOrderRentVehicleDetail().getEndTime()).toString(CommonConstants.YMR_SLASH_FORMATTER_JODA), CommonConstants.YMR_SLASH_FORMATTER_JODA);
Long timeLag = orderPageVO.getOrderRentVehicleDetail().getStartTime() - System.currentTimeMillis();
OrderItem vehicleItem = orderItemBiz.selectOne(new OrderItem(){{
setType(ItemTypeEnum.VEHICLE_MODEL.getCode());
setOrderId(orderPageVO.getId());
}});
topAmount = vehicleItem.getUnitPrice().multiply(new BigDecimal(2+ ""));
if(timeLag < 0 ) {
OrderAccountDetail oad = new OrderAccountDetail();
Integer freeDays = (null == vehicleItem.getCutNum())?0 :vehicleItem.getCutNum();
//inProgressVO = inProgressCalculate(orderPageVO, vehicleItem, freeDays, baseOrderBiz.getDaysBetweenDateTime(startTime, nowTime), new OrderAccountDetail(), Boolean.FALSE);
totalDeductAmount = oad.realTotalDeduct();
totalRefundAmount = oad.getOrderAmount().add(oad.getDepositAmount());
refundDesc = inProgressVO.getViolateDesc();
}else {
String key = RENT_REFUND;
BigDecimal deductionAmount = orderAccountBiz.calculateDeduction(vehicleItem.getBuyAmount()
, orderPageVO.getOrderRentVehicleDetail().getStartTime() - System.currentTimeMillis()
, DictionaryKey.APP_ORDER+ "_"+ key
, refundDescBuilder);
totalDeductAmount = deductionAmount;
totalRefundAmount = orderPageVO.getRealAmount().subtract(deductionAmount);
refundDesc = refundDescBuilder.toString();
}
break;
case TOUR:
//判断是省内还是省外
String key = TOUR_IN_REFUND;
if(SYS_TRUE.equals(orderPageVO.getOrderTourDetail().getIsOutside())) {
key = TOUR_REFUND;
}
OrderItem adultItem = orderItemBiz.selectOne(new OrderItem(){{
setType(ItemTypeEnum.TOUR_ADULT.getCode());
setOrderId(orderPageVO.getId());
}});
OrderItem childItem = orderItemBiz.selectOne(new OrderItem(){{
setType(ItemTypeEnum.TOUR_CHILD.getCode());
setOrderId(orderPageVO.getId());
}});
BigDecimal adultItemAmount = (null == adultItem)? BigDecimal.ZERO: adultItem.getRealAmount();
BigDecimal childItemAmount = (null == childItem)? BigDecimal.ZERO: childItem.getRealAmount();
topAmount = adultItemAmount.add(childItemAmount);
BigDecimal deductionAmount = orderAccountBiz.calculateDeduction(adultItemAmount.add(childItemAmount)
, orderPageVO.getOrderTourDetail().getStartTime() - System.currentTimeMillis()
, DictionaryKey.APP_ORDER+ "_"+ key
, refundDescBuilder);
totalDeductAmount = deductionAmount;
totalRefundAmount = orderPageVO.getRealAmount().subtract(deductionAmount);
refundDesc = refundDescBuilder.toString();
break;
default:
break;
}
OrderRefundPriceVO orpv = new OrderRefundPriceVO();
orpv.setRealAmount(orderPageVO.getRealAmount());
orpv.setRefundAmount(totalRefundAmount);
orpv.setCutAmount(totalDeductAmount);
orpv.setTopAmount(topAmount);
return orpv;
}
}
\ No newline at end of file
......@@ -115,7 +115,7 @@ public class OrderCancelBiz {
* @param baseOrder
*/
@Transactional
public void cancel(BaseOrder baseOrder) {
public void cancel(BaseOrder baseOrder, BigDecimal changeViolateAmount) {
OrderRentVehicleDetail orvd = new OrderRentVehicleDetail();
OrderTourDetail otd = new OrderTourDetail();
OrderMemberDetail omd = new OrderMemberDetail();
......@@ -149,14 +149,14 @@ public class OrderCancelBiz {
//获取出发时间 到现在 距离时间
Long timeLag = orvd.getStartTime() - System.currentTimeMillis();
if(timeLag < 0 ) {
//开始时间当天时间戳
Long beginOfStartDay = DateUtil.beginOfDay(DateUtil.date(orvd.getStartTime())).getTime();
//计算:使用天数 当前时间 - 开始时间的0时0分0秒
Long useTimeLag = System.currentTimeMillis() - beginOfStartDay;
log.info("useTimeLag {}", new BigDecimal(useTimeLag + ""));
log.info("divide {}", new BigDecimal((24 * 60 * 60 * 1000)+ ""));
Integer useDays = new BigDecimal(useTimeLag + "").divide(new BigDecimal((24 * 60 * 60 * 1000)+ ""), 0, RoundingMode.UP).intValue();
Integer useDays = orderCalculateBiz.getIncludeDays(orvd.getStartTime(), System.currentTimeMillis());
inProgressVO = orderCalculateBiz.calculateOrderComplete(baseOrder, orvd, oad, vehicleItemDTO, useDays, Boolean.TRUE);
//判断是否修改违约金
if(null != changeViolateAmount) {
oad.changeCancelViolate(changeViolateAmount);
}
//结合
//退款子流程: 订单基础,退款描述,退款金额
orderAccountBiz.refundSubProcess(baseOrder, "", baseOrder.getRealAmount().subtract(orvd.getDeposit()), oad.getDepositAmount().add(oad.getOrderAmount()), AccountTypeEnum.OUT_ORDER_FUND.getCode(), RefundStatusEnum.ALL.getCode(), oad);
......@@ -166,7 +166,7 @@ public class OrderCancelBiz {
CancelStartedVO csv = new CancelStartedVO();
csv.setType(CostDetailExtend.CANCEL_STARTED);
csv.setConsumeAmount(inProgressVO.getConsumeAmount());
csv.setModelAmount(orderItem.getUnitPrice());
csv.setModelAmount(vehicleItemDTO.getUnitPrice());
csv.setUsedAmount(inProgressVO.getUsedAmount());
csv.setUsedDayNum(inProgressVO.getUsedDays());
csv.setUsedfreeDayNum(inProgressVO.getUsedfreeDays());
......@@ -199,7 +199,7 @@ public class OrderCancelBiz {
//退款流程
//违约金封顶 租车身份价 * 2天
orderAccountBiz.rentRefundProcessCancel(baseOrder, BigDecimal.ZERO, timeLag, APP_ORDER+ "_"+ RENT_REFUND, orvd.getDeposit(), vehicleItemDTO.getBuyAmount(), oad, vehicleItemDTO.getTopAmount(0));
orderAccountBiz.rentRefundProcessCancel(baseOrder, BigDecimal.ZERO, timeLag, APP_ORDER+ "_"+ RENT_REFUND, orvd.getDeposit(), vehicleItemDTO.getBuyAmount(), oad, vehicleItemDTO.getTopAmount(0), null, changeViolateAmount);
//设置订单数据
//baseOrder.setDamagesAmount(csv.getDamagesAmount());
......@@ -264,7 +264,7 @@ public class OrderCancelBiz {
}
//退款流程
orderAccountBiz.rentRefundProcessCancel(baseOrder, adultItemAmount.add(childItemAmount), timeLag, APP_ORDER+ "_"+ key, BigDecimal.ZERO, BigDecimal.ZERO, oad, adultItemAmount.add(childItemAmount) );
orderAccountBiz.rentRefundProcessCancel(baseOrder, adultItemAmount.add(childItemAmount), timeLag, APP_ORDER+ "_"+ key, BigDecimal.ZERO, BigDecimal.ZERO, oad, adultItemAmount.add(childItemAmount), changeViolateAmount, null);
//如果有扣款项,则生成额外的费用明细
if(oad.getDeductions().size() > 0) {
......@@ -322,6 +322,8 @@ public class OrderCancelBiz {
if(result < 0) {
throw new BaseException(ResultCode.FAILED_CODE);
}
orvd.setBackFreeDays(freeDays);
orderRentVehicleBiz.updateSelectiveById(orvd);
}
}else if(OrderTypeEnum.TOUR.getCode().equals(baseOrder.getType())) {
......
......@@ -110,7 +110,7 @@ public class RentDepositJobHandler extends IJobHandler {
OrderAccountDetail oad = new OrderAccountDetail();
String refundDesc = "退还押金:";
String refundDesc = "退还违章押金:";
BigDecimal refundAmont;
if(null != orderViolation) {
//设置扣款项
......@@ -120,8 +120,7 @@ public class RentDepositJobHandler extends IJobHandler {
//还车扣除款 剩余的 钱,再减去违章预备金
refundAmont = orvd.getReturnPayResidue().subtract(orderViolation.getPrice());
refundDesc += refundAmont.toString()+ "(已扣除 违章扣款:"+ refundAmont.toString();
refundDesc += ")";
refundDesc += refundAmont.toString();
}else {
refundAmont = orvd.getReturnPayResidue();
refundDesc += refundAmont.toString();
......
......@@ -15,19 +15,17 @@ import com.xxfc.platform.order.biz.OrderAccountBiz;
import com.xxfc.platform.order.biz.OrderItemBiz;
import com.xxfc.platform.order.biz.OrderRefundBiz;
import com.xxfc.platform.order.biz.inner.OrderCalculateBiz;
import com.xxfc.platform.order.biz.inner.OrderCancelBiz;
import com.xxfc.platform.order.contant.enumerate.ItemTypeEnum;
import com.xxfc.platform.order.contant.enumerate.OrderStatusEnum;
import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
import com.xxfc.platform.order.entity.OrderItem;
import com.xxfc.platform.order.entity.OrderRefund;
import com.xxfc.platform.order.entity.OrderRentVehicleDetail;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import com.xxfc.platform.order.pojo.calculate.InProgressVO;
import com.xxfc.platform.order.pojo.calculate.OrderRefundPriceVO;
import com.xxfc.platform.order.pojo.order.OrderPageVO;
import com.xxfc.platform.order.pojo.order.VehicleItemDTO;
import com.xxfc.platform.universal.constant.DictionaryKey;
import lombok.Data;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
......@@ -37,9 +35,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.math.BigDecimal;
import java.math.RoundingMode;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
import static com.xxfc.platform.universal.constant.DictionaryKey.*;
......@@ -160,7 +156,7 @@ public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRe
orpv.setRefundAmount(totalRefundAmount);
if(orderPageVO.getStatus().equals(OrderStatusEnum.ORDER_UNPAY.getCode())
|| orderPageVO.getStatus().equals(OrderStatusEnum.ORDER_CRT.getCode())
|| totalDeductAmount.compareTo(BigDecimal.ZERO) <= 0) {
|| orpv.getRefundAmount().compareTo(BigDecimal.ZERO) <= 0) {
orpv.setRefundDesc("是否确定取消订单");
}else {
orpv.setRefundDesc(StrUtil.format("本次取消操作需要扣除{}元违约金,实际退款金额为{}元,您确定要取消订单吗?", totalDeductAmount, totalRefundAmount));
......@@ -168,16 +164,18 @@ public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRe
return ObjectRestResponse.succ(orpv);
}
@Data
public class OrderRefundPriceVO {
BigDecimal refundAmount;
BigDecimal realAmount;
BigDecimal cutAmount;
String refundDesc;
public void setRefundAmount(BigDecimal refundAmount) {
this.refundAmount = refundAmount;
this.cutAmount = realAmount.subtract(refundAmount);
}
@RequestMapping(value = "/bg-stage/getViolatePrice/{no}", method = RequestMethod.GET)
@ResponseBody
@IgnoreClientToken
public ObjectRestResponse<BigDecimal> getViolatePrice(@PathVariable(value = "no") String no) {
checkAppUser();
OrderPageVO orderPageVO = baseOrderBiz.pageByParm(new Query(new PageParam(){{
setLimit(1);
setPage(1);
}}){{put("no", no); }}.getSuper()).get(0);
OrderRefundPriceVO orderRefundPriceVO = orderCalculateBiz.getPriceCalculate(no, orderPageVO);
return ObjectRestResponse.succ(orderRefundPriceVO);
}
}
\ No newline at end of file
package com.xxfc.platform.universal.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
/**
* 订单支付
......@@ -44,7 +47,11 @@ public class OrderPay implements Serializable {
@Column(name = "pay_way")
@ApiModelProperty(value = "1:微信公众号支付 2.支付宝即时到账,3,银联")
private Integer payWay;
@Column(name = "pay_type")
@ApiModelProperty(value = "1:支付宝APP支付,2:支付宝预授权支付")
private Integer payType;
//渠道:1-租车;2-旅游
@Column(name = "channel")
@ApiModelProperty(value = "渠道:1-租车;2-旅游")
......
......@@ -4,10 +4,6 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
/**
......@@ -69,5 +65,11 @@ public class OrderPayVo{
private String tradeNo;
//支付接口返回的流水号
@Column(name = "serial_number")
@ApiModelProperty(value = "支付接口返回的流水号")
private String serialNumber;
@ApiModelProperty(value = "1:支付宝APP支付,2:支付宝预授权支付")
private Integer payType;
}
......@@ -8,6 +8,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigDecimal;
/**
......@@ -37,5 +38,12 @@ public class OrderRefundVo{
@ApiModelProperty(value = "退款描述")
private String refundDesc;
//冻结转支付描述 只用于预支付相关
@ApiModelProperty(value = "冻结转支付描述")
private String freeze2PayDesc;
//冻结转支付金额 只用于预支付相关
@ApiModelProperty(value = "冻结转支付金额")
private Integer freeze2PayAmount;
}
......@@ -5,7 +5,6 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.util.process.SystemConfig;
import com.github.wxiaoqi.security.common.util.result.JsonResultUtil;
import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.entity.OrderPay;
import com.xxfc.platform.universal.entity.OrderRefund;
import com.xxfc.platform.universal.mapper.OrderRefundMapper;
......@@ -21,10 +20,6 @@ import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
import java.util.Map;
import static com.xxfc.platform.universal.constant.DictionaryKey.PAY_DEMOTION;
import static com.xxfc.platform.universal.constant.DictionaryKey.UNIVERSAL_PAY;
/**
* 订单支付退款表
......@@ -59,17 +54,17 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper, OrderRefund> {
Integer refundAmount = orderRefundVo.getRefundAmount();
//临时处理
Map<String, Dictionary> dictionaryMap = dictionaryBiz.getAll4Map();
Integer demotion = Integer.valueOf(dictionaryMap.get(UNIVERSAL_PAY + "_" + PAY_DEMOTION).getDetail());
payAmount = payAmount / demotion;
if (payAmount <= 0) {
payAmount = 1;
}
refundAmount = refundAmount / demotion;
if (refundAmount <= 0) {
refundAmount = 1;
}
// Map<String, Dictionary> dictionaryMap = dictionaryBiz.getAll4Map();
// Integer demotion = Integer.valueOf(dictionaryMap.get(UNIVERSAL_PAY + "_" + PAY_DEMOTION).getDetail());
// payAmount = payAmount / demotion;
// if (payAmount <= 0) {
// payAmount = 1;
// }
//
// refundAmount = refundAmount / demotion;
// if (refundAmount <= 0) {
// refundAmount = 1;
// }
String refundDesc = StringUtils.isNotBlank(orderRefundVo.getRefundDesc()) ? orderRefundVo.getRefundDesc() : "审核通过,退款";
String out_refund_no = Snowflake.build() + "";
......@@ -89,9 +84,19 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper, OrderRefund> {
OrderPay orderPay = list.get(0);
String out_trade_no = orderPay.getTradeNo();
boolean flag = false;
if (orderPay.getPayWay() == 2) {
log.info("======支付宝退款中===========");
if (orderPay.getPayWay() == 2 && orderPay.getPayType() == 1) {
log.info("======支付宝APP支付退款中===========");
flag = payBiz.alipayOrderRefund(out_trade_no, orderPay.getSerialNumber(), refundAmount, refundDesc, out_trade_no + System.currentTimeMillis());
} else if (orderPay.getPayWay() == 2 && orderPay.getPayType() == 2) {
log.info("======支付宝预授权支付退款中===========");
//需要根据实际传过来的参数类型来进行解冻或者预授权转支付
if (orderRefundVo.getRefundAmount() != 0) { //解冻金额
flag = payBiz.fundAuthOrderUnFreeze(orderPay.getTradeNo() + System.currentTimeMillis(), orderPay.getSerialNumber(), orderRefundVo.getRefundAmount(), orderRefundVo.getRefundDesc());
}
//预授权转支付
if(orderRefundVo.getFreeze2PayAmount() != 0) {
flag = payBiz.tradePay(orderPay.getTradeNo() + System.currentTimeMillis(), orderPay.getSerialNumber(), orderRefundVo.getFreeze2PayAmount(), orderRefundVo.getFreeze2PayDesc(), orderRefundVo.getFreeze2PayDesc());
}
} else if(orderPay.getPayWay() == 1){
log.info("======微信退款中===========");
flag = WxPayRefundUtils.refund(appid, mchId, partnerKey, out_trade_no, out_refund_no, payAmount + "",
......
......@@ -179,6 +179,9 @@ public interface VehicleFeign {
@RequestMapping(value = "/vehicleInfo/bookRecord/update", method = RequestMethod.POST)
public ObjectRestResponse update(@RequestBody BookRecordUpdateLog bookRecordUpdateLog);
@RequestMapping(value ="/branchCompany/app/unauth/getCompanyIds",method = RequestMethod.GET)
RestResponse<List<Integer>> getCompanyIds();
/**
* 车型日历价格
*
......@@ -190,13 +193,11 @@ public interface VehicleFeign {
*/
@GetMapping(value = "/vehicle_model/calendar_price/app/unauth/price",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
ObjectRestResponse<List<VehicleModelCalendarPriceDTO>> findVehicleModelCalendarPriceByDate(@RequestParam(value = "startDate") Long startDate,
@RequestParam(value = "endDate") Long endDate,
@RequestParam(value = "vehicleModelId") Integer vehicleModelId,
@RequestParam(value = "userId") Integer userId);
@RequestParam(value = "endDate") Long endDate,
@RequestParam(value = "vehicleModelId") Integer vehicleModelId,
@RequestParam(value = "userId") Integer userId);
@GetMapping(value = "/bookRecord/get")
public ObjectRestResponse<List<BookRecordUpdateLog>> get(@RequestParam(value = "bookRecordId")Long bookRecordId);
@RequestMapping(value ="/branchCompany/app/unauth/getCompanyIds",method = RequestMethod.GET)
RestResponse<List<Integer>> getCompanyIds();
}
......@@ -1175,7 +1175,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
public PageDataVO<UsableVehicleModelVO> searchUsableModel(UsableVeicleDTO dto) {
Map<String, Object> params = BeanUtil.beanToMap(dto);
if (StrUtil.isNotBlank(dto.getStartDate()) && StrUtil.isNotBlank(dto.getEndDate())) {
initBookSearchParam(dto, params, Boolean.TRUE);
initBookSearchParam(dto, params, Boolean.FALSE);
}
return PageDataVO.pageInfo(dto.getPage(), dto.getLimit(), () -> mapper.searchUsableModel(params));
}
......@@ -1235,10 +1235,10 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
List<String> notBookedDates = Lists.newArrayList();
if (StringUtils.isNotBlank(dto.getBookEndDate()) &&
StringUtils.isNotBlank(dto.getBookEndDate())) {
// notBookedDates = convertDatePeriod2List(dto.getBookStartDate(),
// dto.getBookEndDate());
notBookedDates = convertDatePeriod2List(dto.getStartDateExtend(),
dto.getEndDateExtend());
notBookedDates = convertDatePeriod2List(dto.getBookStartDate(),
dto.getBookEndDate());
// notBookedDates = convertDatePeriod2List(dto.getStartDateExtend(),
// dto.getEndDateExtend());
}
//若传入预定信息查询条件,则查询对应月份预定信息查询条件(不超过3个月)
......
......@@ -31,7 +31,7 @@
from branch_company
<where>
<if test="addrCity != null">
and addr_city = #{addrCity}
and (addr_city = #{addrCity} or addr_province = #{addrCity} or addr_town = #{addrCity})
</if>
<if test="lon != null and lat != null">
and longitude is not null and latitude is not null
......
......@@ -558,14 +558,14 @@
</if>
<!-- yearNo4Where 标识时间参数不用于where条件,用于select部分 -->
<if test=" yearMonthAndParam !=null and yearNo4Where != null and yearNo4Where == true">
,(max(
,(ifnull(max(
vbi.bit_str = #{yearMonthAndParamBitStr}
<!-- 租车列表 不过滤前后预约记录不符的车辆 但是合并标示车型是否有车 即 hasVehicle-->
<if test="withoutRecordWhere != null and withoutRecordWhere = 1 and startCompanyId != null and endCompanyId != null ">
and (abr.to_lift_company is null or abr.to_lift_company = #{startCompanyId})
and (abr.to_return_company is null or abr.to_return_company = #{endCompanyId})
</if>
)
), 1)
) as hasVehicle
</if>
<if test="lon != null and lat != null">
......@@ -576,6 +576,7 @@
and vm.id is not null
and vm.status = 1
and vm.isdel = 0
and vm.app_show = 1
and bc.id is not null
GROUP BY model_id, company_id
<if test="lon != null and lat != null">, distance</if>
......
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