Commit 2f12cffc authored by hanfeng's avatar hanfeng

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

# Conflicts:
#	ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/biz/AppUserSellingWaterBiz.java
#	ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rest/AppUserController.java
parents 4ccbc618 c9b7d499
...@@ -28,6 +28,7 @@ public class RabbitConstant { ...@@ -28,6 +28,7 @@ public class RabbitConstant {
public static final String KEY_ORDER_PAY = "order.pay"; public static final String KEY_ORDER_PAY = "order.pay";
public static final String KEY_ORDER_FINLISH = "order.finlish"; public static final String KEY_ORDER_FINLISH = "order.finlish";
public static final String KEY_ORDER_CANCEL = "order.cancel"; public static final String KEY_ORDER_CANCEL = "order.cancel";
public static final String KEY_ORDER_PART_DEPOSIT = "order.partDeposit";
//钱包 //钱包
public static final String KEY_WALLET_ADD = "wallet.add"; public static final String KEY_WALLET_ADD = "wallet.add";
......
...@@ -336,7 +336,6 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> { ...@@ -336,7 +336,6 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
return mapper.getUserByUsernameAndRealName(username,realName); return mapper.getUserByUsernameAndRealName(username,realName);
} }
@CacheClear(pre = "user{2}") @CacheClear(pre = "user{2}")
......
...@@ -16,6 +16,7 @@ import com.github.wxiaoqi.security.common.vo.PageDataVO; ...@@ -16,6 +16,7 @@ import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.xxfc.platform.vehicle.entity.BranchCompany; import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.feign.VehicleFeign; import com.xxfc.platform.vehicle.feign.VehicleFeign;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -41,6 +42,7 @@ import java.util.stream.Collectors; ...@@ -41,6 +42,7 @@ import java.util.stream.Collectors;
@Transactional @Transactional
@DependsOn("appUserPositionBiz") @DependsOn("appUserPositionBiz")
@Service @Service
@Slf4j
public class AppUserPositionTempBiz extends BaseBiz<AppUserPositionTempMapper, AppUserPositionTemp> implements InitializingBean { public class AppUserPositionTempBiz extends BaseBiz<AppUserPositionTempMapper, AppUserPositionTemp> implements InitializingBean {
@Autowired @Autowired
...@@ -299,4 +301,38 @@ public class AppUserPositionTempBiz extends BaseBiz<AppUserPositionTempMapper, A ...@@ -299,4 +301,38 @@ public class AppUserPositionTempBiz extends BaseBiz<AppUserPositionTempMapper, A
} }
public void setPostionIdByPhone(String phone){
try {
Example example = new Example(AppUserPositionTemp.class);
example.createCriteria().andEqualTo("phone", phone).andEqualTo("isDel", 0);
List<AppUserPositionTemp> list = selectByExample(example);
if (CollectionUtils.isEmpty(list)){
log.info("----用户无身份----phone==="+phone);
return;
}
AppUserPositionTemp positionTemp=list.get(0);
if (positionTemp.getUserId()>0){
log.info("----用户已存在身份----phone==="+phone);
return;
}
//根据手机号查询userId
AppUserLogin userLogin = loginBiz.checkeUserLogin(phone);
if (userLogin==null) {
log.info("----用户不存在----phone==="+phone);
return;
}
Integer userId=userLogin.getId();
positionTemp.setUserId(userId);
int num=updateSelectiveByIdRe(positionTemp);
if (num>0){
Integer postionId=positionTemp.getPositionId();
log.info("----用户---postionId===="+postionId+"----phone==="+phone);
detailBiz.updateUserPositionByUserId(userId, postionId);
}
}catch (Exception e){
e.printStackTrace();
}
}
} }
...@@ -15,11 +15,9 @@ import org.apache.commons.collections.CollectionUtils; ...@@ -15,11 +15,9 @@ import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.github.wxiaoqi.security.admin.mapper.AppUserSellingWaterMapper; import com.github.wxiaoqi.security.admin.mapper.AppUserSellingWaterMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.function.Supplier; import java.util.function.Supplier;
...@@ -198,8 +196,43 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A ...@@ -198,8 +196,43 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
log.info("订单完成计算用户拥金----finishOrderWater----id====" + id + "---commission==" + commission + "----orderType===" + orderType); log.info("订单完成计算用户拥金----finishOrderWater----id====" + id + "---commission==" + commission + "----orderType===" + orderType);
amount = amount.add(commission); amount = amount.add(commission);
} }
log.info("订单完成计算用户拥金----finishOrderWater----orderId====" + orderId + "---amount==" + amount); log.info("订单完成计算用户拥金----finishOrderWater----orderId====" + orderId + "---amount==" + amount);
if(orderType==1){
List<OrderGoodsDTO> goodsDTOList =orderWaterDTO.getGoodsDTOList();
log.info("租车订单完成-----goodsDTOList==="+goodsDTOList);
if (CollectionUtils.isNotEmpty(goodsDTOList)){
for (OrderGoodsDTO goodsDto : goodsDTOList) {
//商品id
Integer goodId = goodsDto.getGoodId();
//商品价格
BigDecimal price = goodsDto.getPrice();
AppUserSellingWater sellingWater = new AppUserSellingWater();
sellingWater.setOrderId(orderId);
sellingWater.setGoodId(goodId);
sellingWater = selectOne(sellingWater);
if (sellingWater == null||sellingWater.getExtract()==null||sellingWater.getExtract()==0) {
log.info("租车订单完成-----sellingWater---不存在或extract---为空");
continue;
}
if (price.compareTo(sellingWater.getPrice())>=0){
log.info("租车订单完成-----完成价格大于支付价格");
continue;
}
price=price.subtract(sellingWater.getPrice());
Integer extract=sellingWater.getExtract();
log.info("租车订单完成-----price====="+price+"---extract===="+extract);
BigDecimal commission = price.multiply(new BigDecimal(extract + "")).divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP);
log.info("租车订单完成--------userId===" + userId + "---commission===" + commission);
sellingWater.setWaiting(1);
sellingWater.setStatus(1);
sellingWater.setCommission(commission);
insertSelective(sellingWater);
log.info("租车订单完成计算用户拥成功----payOrderWater--------userId===" + userId);
amount = amount.subtract(commission);
}
}
}
log.info("订单完成计算用户拥金----finishOrderWater--------orderId===" + orderId + "----amount====" + amount + "--orderType===" + orderType);
int r = amount.compareTo(BigDecimal.ZERO); int r = amount.compareTo(BigDecimal.ZERO);
//更新钱包 //更新钱包
if (r == 1 && userId > 0) { if (r == 1 && userId > 0) {
...@@ -406,6 +439,18 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A ...@@ -406,6 +439,18 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
return sellingWalletPagVo; return sellingWalletPagVo;
} }
public List<Integer> findMemberIdByLeaderIdAndOrdreType(Integer leaderId, int orderType) {
Example example = new Example(AppUserSellingWater.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("userId", leaderId);
criteria.andEqualTo("orderType", orderType);
List<AppUserSellingWater> appUserSellingWaters = mapper.selectByExample(example);
if (CollectionUtils.isEmpty(appUserSellingWaters)){
return Collections.EMPTY_LIST;
}
return appUserSellingWaters.stream().map(AppUserSellingWater::getSourceId).collect(Collectors.toList());
}
public PageDataVO<UserSellingWaterAdminDTO> findSellingWaterWithPage(UserSellingWaterFindDTO userSellingWaterFindDTO) { public PageDataVO<UserSellingWaterAdminDTO> findSellingWaterWithPage(UserSellingWaterFindDTO userSellingWaterFindDTO) {
PageDataVO<UserSellingWaterAdminDTO> pageDataVO = PageDataVO.pageInfo(userSellingWaterFindDTO.getPage(), PageDataVO<UserSellingWaterAdminDTO> pageDataVO = PageDataVO.pageInfo(userSellingWaterFindDTO.getPage(),
userSellingWaterFindDTO.getLimit(), userSellingWaterFindDTO.getLimit(),
......
...@@ -36,6 +36,7 @@ public class RabbitAdminConfig extends RabbitCommonConfig { ...@@ -36,6 +36,7 @@ public class RabbitAdminConfig extends RabbitCommonConfig {
add(new BindDTO(ORDER_WATER_QUEUE, ORDER_TOPIC, KEY_ORDER_PAY)); add(new BindDTO(ORDER_WATER_QUEUE, ORDER_TOPIC, KEY_ORDER_PAY));
add(new BindDTO(ORDER_WATER_QUEUE, ORDER_TOPIC, KEY_ORDER_FINLISH)); add(new BindDTO(ORDER_WATER_QUEUE, ORDER_TOPIC, KEY_ORDER_FINLISH));
add(new BindDTO(ORDER_WATER_QUEUE, ORDER_TOPIC, KEY_ORDER_CANCEL)); add(new BindDTO(ORDER_WATER_QUEUE, ORDER_TOPIC, KEY_ORDER_CANCEL));
add(new BindDTO(ORDER_WATER_QUEUE, ORDER_TOPIC, KEY_ORDER_PART_DEPOSIT));
add(new BindDTO(ORDER_FINLISH_USER_RE_QUEUE, ORDER_TOPIC, KEY_ORDER_FINLISH)); add(new BindDTO(ORDER_FINLISH_USER_RE_QUEUE, ORDER_TOPIC, KEY_ORDER_FINLISH));
//钱包 //钱包
add(new BindDTO(WALLET_ADD_QUEUE, ADMIN_TOPIC, KEY_WALLET_ADD)); add(new BindDTO(WALLET_ADD_QUEUE, ADMIN_TOPIC, KEY_WALLET_ADD));
......
...@@ -63,6 +63,9 @@ public class WaterMQHandler { ...@@ -63,6 +63,9 @@ public class WaterMQHandler {
case ORDER_FINISH: case ORDER_FINISH:
orderWaterDTO.setStatus(2); orderWaterDTO.setStatus(2);
break; break;
case ORDER_PART_DEPOSIT:
orderWaterDTO.setStatus(2);
break;
case ORDER_CANCEL: case ORDER_CANCEL:
orderWaterDTO.setStatus(3); orderWaterDTO.setStatus(3);
break; break;
...@@ -71,13 +74,18 @@ public class WaterMQHandler { ...@@ -71,13 +74,18 @@ public class WaterMQHandler {
} }
switch (OrderTypeEnum.get(orderMQDTO.getType())) { switch (OrderTypeEnum.get(orderMQDTO.getType())) {
case RENT_VEHICLE: case RENT_VEHICLE:
//租车订单finlish不处理,退还第一部分押金后再处理
if(orderMQDTO.getSign().equals(ORDER_FINISH)) {
break;
}
orderMQDTO.getItemByTypeEnum(ItemTypeEnum.VEHICLE_MODEL);
orderWaterDTO.setGoodsDTOList( orderWaterDTO.setGoodsDTOList(
new ArrayList<OrderGoodsDTO>() {{ new ArrayList<OrderGoodsDTO>() {{
add(new OrderGoodsDTO() {{ add(new OrderGoodsDTO() {{
setGoodId(orderMQDTO.getOrderRentVehicleDetail().getModelId()); setGoodId(orderMQDTO.getOrderRentVehicleDetail().getModelId());
setGoodNumber(1); setGoodNumber(1);
setImg(orderMQDTO.getPicture()); setImg(orderMQDTO.getPicture());
setPrice(orderMQDTO.getItemByTypeEnum(ItemTypeEnum.VEHICLE_MODEL).getRealAmount()); setPrice(orderMQDTO.getItemByTypeEnum(ItemTypeEnum.VEHICLE_MODEL).getLastAmount());
setTitle(orderMQDTO.getName()); setTitle(orderMQDTO.getName());
setType(OrderGoodsDTO.TYPE_RENT); setType(OrderGoodsDTO.TYPE_RENT);
}}); }});
......
...@@ -19,12 +19,12 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; ...@@ -19,12 +19,12 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.msg.TableResultResponse; import com.github.wxiaoqi.security.common.msg.TableResultResponse;
import com.github.wxiaoqi.security.common.rest.CommonBaseController; import com.github.wxiaoqi.security.common.rest.CommonBaseController;
import com.github.wxiaoqi.security.common.util.Query; 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 com.xxfc.platform.order.feign.OrderFeign;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -233,7 +233,7 @@ public class AppUserController extends CommonBaseController{ ...@@ -233,7 +233,7 @@ public class AppUserController extends CommonBaseController{
appUserLogin.setOpenid(userVo.getOpenid()); appUserLogin.setOpenid(userVo.getOpenid());
appUserLogin.setId(userid); appUserLogin.setId(userid);
appUserLogin.setUsername(userVo.getUsername()); appUserLogin.setUsername(userVo.getUsername());
appUserLoginBiz.bindOpenid(appUserLogin); appUserLoginBiz.updateAppuserLogin(appUserLogin);
//支付宝绑定 //支付宝绑定
if (StringUtils.isNotEmpty(userVo.getAliCode()) && userVo.getAliCode().trim().length()>0){ if (StringUtils.isNotEmpty(userVo.getAliCode()) && userVo.getAliCode().trim().length()>0){
appUserAlipayBiz.getUserInfo(userVo.getAliCode(),request); appUserAlipayBiz.getUserInfo(userVo.getAliCode(),request);
...@@ -347,8 +347,6 @@ public class AppUserController extends CommonBaseController{ ...@@ -347,8 +347,6 @@ public class AppUserController extends CommonBaseController{
return appUserLoginBiz.test(); return appUserLoginBiz.test();
} }
@PostMapping("/bind") @PostMapping("/bind")
private ObjectRestResponse accountBinding(@RequestBody AccountBindDTO accountBindDTO, HttpServletRequest request){ private ObjectRestResponse accountBinding(@RequestBody AccountBindDTO accountBindDTO, HttpServletRequest request){
try { try {
......
...@@ -111,6 +111,9 @@ public class AppPermissionService { ...@@ -111,6 +111,9 @@ public class AppPermissionService {
@Autowired @Autowired
private AppUserPhoneNotesBiz notesBiz; private AppUserPhoneNotesBiz notesBiz;
@Autowired
private AppUserPositionTempBiz positionTempBiz;
public AppUserInfo validate(String username, String password) { public AppUserInfo validate(String username, String password) {
AppUserInfo info = new AppUserInfo(); AppUserInfo info = new AppUserInfo();
...@@ -331,6 +334,8 @@ public class AppPermissionService { ...@@ -331,6 +334,8 @@ public class AppPermissionService {
//创建钱包 //创建钱包
walletBiz.createWalletByUserId(appUserLogin.getId()); walletBiz.createWalletByUserId(appUserLogin.getId());
log.info("注册:创建钱包: " + userid+"---time===="+System.currentTimeMillis()/1000L); log.info("注册:创建钱包: " + userid+"---time===="+System.currentTimeMillis()/1000L);
//临时身份绑定
positionTempBiz.setPostionIdByPhone(username);
// 登录结果要做做统一处理 // 登录结果要做做统一处理
JSONObject data = autoLogin(userid, username, headimgurl, nickname,code,activityCode,1); JSONObject data = autoLogin(userid, username, headimgurl, nickname,code,activityCode,1);
...@@ -967,6 +972,8 @@ public class AppPermissionService { ...@@ -967,6 +972,8 @@ public class AppPermissionService {
log.error("注册:新增用户详情: " + userid); log.error("注册:新增用户详情: " + userid);
//创建钱包 //创建钱包
walletBiz.createWalletByUserId(appUserLogin.getId()); walletBiz.createWalletByUserId(appUserLogin.getId());
//临时身份绑定
positionTempBiz.setPostionIdByPhone(username);
//临时会员绑定 //临时会员绑定
insertUserMemberByUserIdAndPhone(userid, username); insertUserMemberByUserIdAndPhone(userid, username);
//上线绑定 //上线绑定
......
...@@ -27,6 +27,7 @@ public class Coupon implements Serializable { ...@@ -27,6 +27,7 @@ public class Coupon implements Serializable {
public static final Integer CHANNEL_RENT = 1; public static final Integer CHANNEL_RENT = 1;
public static final Integer CHANNEL_TOUR = 2; public static final Integer CHANNEL_TOUR = 2;
public static final Integer CHANNEL_CAMPSITE = 3; public static final Integer CHANNEL_CAMPSITE = 3;
public static final Integer CHANNEL_MEMBER = 4;
/** /**
* 主键id * 主键id
......
...@@ -59,11 +59,17 @@ public class UserCouponVo { ...@@ -59,11 +59,17 @@ public class UserCouponVo {
@ApiModelProperty(value = "开始时间", hidden = true ) @ApiModelProperty(value = "开始时间", hidden = true )
private Long startTime; private Long startTime;
/** /**
* 到期时间 * 到期时间
*/ */
@ApiModelProperty(value = "到期时间", hidden = true ) @ApiModelProperty(value = "到期时间", hidden = true )
private Long expireTime; private Long expireTime;
@ApiModelProperty(value = "到期时间字符串")
private String expireDate;
/** /**
* 使用时间 * 使用时间
......
...@@ -124,9 +124,12 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> { ...@@ -124,9 +124,12 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
if(type==1){ if(type==1){
startTime=coupon.getStartTime(); startTime=coupon.getStartTime();
expireTime=coupon.getValidEndTime(); expireTime=coupon.getValidEndTime();
}else { }else if (type==2){
startTime=expireTime; startTime=expireTime;
expireTime+=DAY*coupon.getValidDays(); expireTime+=DAY*coupon.getValidDays();
} else {
startTime=expireTime;
expireTime=-1L;
} }
String ticker_no=Snowflake.build()+""; String ticker_no=Snowflake.build()+"";
UserCoupon userCoupon=new UserCoupon(); UserCoupon userCoupon=new UserCoupon();
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
<result property="crtTime" column="crt_time"/> <result property="crtTime" column="crt_time"/>
<result property="startTime" column="start_time"/> <result property="startTime" column="start_time"/>
<result property="expireTime" column="expire_time"/> <result property="expireTime" column="expire_time"/>
<result property="expireDate" column="expireDate"/>
<result property="useTime" column="use_time"/> <result property="useTime" column="use_time"/>
<result property="title" column="title"/> <result property="title" column="title"/>
<result property="subtitle" column="subtitle"/> <result property="subtitle" column="subtitle"/>
...@@ -32,20 +33,20 @@ ...@@ -32,20 +33,20 @@
<select id="getUserCouponsByType" resultMap="userCouponMap"> <select id="getUserCouponsByType" resultMap="userCouponMap">
SELECT SELECT
* *,IF(expire_time=-1,'永久有效',CONCAT('有效期至',FROM_UNIXTIME(expire_time/1000,'%Y-%m-%d'))) as expireDate
FROM FROM
user_coupon u user_coupon u
LEFT JOIN coupon c ON u.coupon_id = c.id LEFT JOIN coupon c ON u.coupon_id = c.id
WHERE WHERE
u.is_del = 0 and u.user_id=#{userId} u.is_del = 0 and u.user_id=#{userId}
<if test="type==0"> <if test="type==0">
and u.is_use=0 and u.expire_time >=#{time} and u.is_use=0 and (u.expire_time >=#{time} or u.expire_time=-1)
</if> </if>
<if test="type==1"> <if test="type==1">
and u.is_use=1 and u.is_use=1
</if> </if>
<if test="type==2"> <if test="type==2">
and u.is_use=0 and u.expire_time &lt;#{time} and u.is_use=0 and u.expire_time &lt;#{time} and u.expire_time!=-1
</if> </if>
<if test="channel!=null and channel!=''"> <if test="channel!=null and channel!=''">
and (c.channel=#{channel} or c.channel=0 ) and (c.channel=#{channel} or c.channel=0 )
......
...@@ -293,4 +293,9 @@ public class BaseOrder implements Serializable { ...@@ -293,4 +293,9 @@ public class BaseOrder implements Serializable {
@ApiModelProperty(value = "促成人联系方式") @ApiModelProperty(value = "促成人联系方式")
@Column(name = "facilitate_phone") @Column(name = "facilitate_phone")
String facilitatePhone; String facilitatePhone;
//支付类型
@ApiModelProperty(value = "支付方式")
@Column(name = "pay_way")
private Integer payWay;
} }
...@@ -137,6 +137,10 @@ public class OrderItem implements Serializable { ...@@ -137,6 +137,10 @@ public class OrderItem implements Serializable {
@ApiModelProperty(value = "描述、详情") @ApiModelProperty(value = "描述、详情")
private String detail; private String detail;
@Column(name = "change_amount")
@ApiModelProperty(value = "下单后导致改变的价格")
private BigDecimal changeAmount;
public Integer getCalculateNum() { public Integer getCalculateNum() {
return buyNum - cutNum; return buyNum - cutNum;
...@@ -176,4 +180,8 @@ public class OrderItem implements Serializable { ...@@ -176,4 +180,8 @@ public class OrderItem implements Serializable {
public BigDecimal getTotalAmount() { public BigDecimal getTotalAmount() {
return realAmount.add(couponAmount); return realAmount.add(couponAmount);
} }
public BigDecimal getLastAmount() {
return realAmount.add(changeAmount);
}
} }
...@@ -15,6 +15,7 @@ public class OrderMQDTO extends BaseOrder implements OrderItemInter { ...@@ -15,6 +15,7 @@ public class OrderMQDTO extends BaseOrder implements OrderItemInter {
public static final int ORDER_CANCEL = 2; public static final int ORDER_CANCEL = 2;
public static final int ORDER_PAY = 4; public static final int ORDER_PAY = 4;
public static final int ORDER_FINISH = 6; public static final int ORDER_FINISH = 6;
public static final int ORDER_PART_DEPOSIT = 101;
OrderRentVehicleDetail orderRentVehicleDetail; OrderRentVehicleDetail orderRentVehicleDetail;
...@@ -42,6 +43,8 @@ public class OrderMQDTO extends BaseOrder implements OrderItemInter { ...@@ -42,6 +43,8 @@ public class OrderMQDTO extends BaseOrder implements OrderItemInter {
* 4--已支付" * 4--已支付"
* *
* 6--已完成 * 6--已完成
*
* 101--部分押金退还
*/ */
Integer sign; Integer sign;
} }
package com.xxfc.platform.order.pojo.order; package com.xxfc.platform.order.pojo.order;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
...@@ -18,6 +20,8 @@ import java.util.List; ...@@ -18,6 +20,8 @@ import java.util.List;
@Data @Data
public class VehicleItemDTO extends OrderItem { public class VehicleItemDTO extends OrderItem {
public static final int topNum = 2; public static final int topNum = 2;
//已抵消天数
private Integer offsetNum = 0;
public BigDecimal calculateVehicleUnitPrice(BigDecimal vehicleAmount, BigDecimal metaVehicleAmount, Boolean isSetRealAmount) { public BigDecimal calculateVehicleUnitPrice(BigDecimal vehicleAmount, BigDecimal metaVehicleAmount, Boolean isSetRealAmount) {
if(isSetRealAmount) { if(isSetRealAmount) {
setRealAmount(vehicleAmount); setRealAmount(vehicleAmount);
...@@ -38,44 +42,50 @@ public class VehicleItemDTO extends OrderItem { ...@@ -38,44 +42,50 @@ public class VehicleItemDTO extends OrderItem {
} }
public BigDecimal getCutAmount() { public BigDecimal getCutAmount() {
List<VehicleModelCalendarPriceDTO> vmcpds = getVehicleDetail(); List<VMCalendarPriceCostDTO> vmcpds = getVehicleDetail();
if(CollUtil.isEmpty(vmcpds)){ if(CollUtil.isEmpty(vmcpds)){
return super.getCutAmount(); return super.getCutAmount();
} }
BigDecimal cutAmount = BigDecimal.ZERO; BigDecimal cutAmount = BigDecimal.ZERO;
for(int i = 0; i < getCutNum(); i++) { // for(int i = 0; i < getCutNum(); i++) {
cutAmount = cutAmount.add(vmcpds.get(i).getPrice()); for(VMCalendarPriceCostDTO vmcpd : vmcpds) {
cutAmount = cutAmount.add(vmcpd.getFreeAmount());
} }
return cutAmount; return cutAmount;
} }
public List<VehicleModelCalendarPriceDTO> getVehicleDetail() { public List<VMCalendarPriceCostDTO> getVehicleDetail() {
if(StrUtil.isBlank(getDetail())) { if(StrUtil.isBlank(getDetail())) {
return CollUtil.newArrayList(); return CollUtil.newArrayList();
} }
return JSONUtil.toList(JSONUtil.parseArray(getDetail()), VehicleModelCalendarPriceDTO.class); return JSONUtil.toList(JSONUtil.parseArray(getDetail()), VMCalendarPriceCostDTO.class);
} }
public BigDecimal getBuyAmount() { public BigDecimal getBuyAmount() {
List<VehicleModelCalendarPriceDTO> vmcpds = getVehicleDetail(); List<VMCalendarPriceCostDTO> vmcpds = getVehicleDetail();
if(CollUtil.isEmpty(vmcpds)){ if(CollUtil.isEmpty(vmcpds)){
return super.getBuyAmount(); return super.getBuyAmount();
} }
BigDecimal buyAmount = BigDecimal.ZERO; BigDecimal buyAmount = BigDecimal.ZERO;
for(int i = 0; i < getBuyNum(); i++) { for(int i = 0; i < getBuyNum(); i++) {
//for(VMCalendarPriceCostDTO vmcpd : vmcpds) {
buyAmount = buyAmount.add(vmcpds.get(i).getPrice()); buyAmount = buyAmount.add(vmcpds.get(i).getPrice());
} }
return buyAmount; return buyAmount;
} }
public BigDecimal getTopAmount(Integer useDays) { public BigDecimal getTopAmount(Integer useDays) {
List<VehicleModelCalendarPriceDTO> vmcpds = getVehicleDetail(); List<VMCalendarPriceCostDTO> vmcpds = getVehicleDetail();
if(CollUtil.isEmpty(vmcpds)){ if(CollUtil.isEmpty(vmcpds)){
return getUnitPrice().multiply(new BigDecimal(topNum+ "")); return getUnitPrice().multiply(new BigDecimal(topNum+ ""));
} }
BigDecimal topAmount = BigDecimal.ZERO; BigDecimal topAmount = BigDecimal.ZERO;
for(int i = useDays; i < getTotalNum(); i++) { for(int i = useDays; i < getTotalNum(); i++) {
topAmount = topAmount.add(vmcpds.get(i).getPrice()); if((i - useDays) >= topNum) {
break;
}else {
topAmount = topAmount.add(vmcpds.get(i).getPrice());
}
} }
//未用天数 小于 topNum //未用天数 小于 topNum
...@@ -91,7 +101,7 @@ public class VehicleItemDTO extends OrderItem { ...@@ -91,7 +101,7 @@ public class VehicleItemDTO extends OrderItem {
} }
public BigDecimal getFreeAmount(Integer freeDays) { public BigDecimal getFreeAmount(Integer freeDays) {
List<VehicleModelCalendarPriceDTO> vmcpds = getVehicleDetail(); List<VMCalendarPriceCostDTO> vmcpds = getVehicleDetail();
if(CollUtil.isEmpty(vmcpds)){ if(CollUtil.isEmpty(vmcpds)){
return getUnitPrice().multiply(new BigDecimal(freeDays+ "")); return getUnitPrice().multiply(new BigDecimal(freeDays+ ""));
} }
...@@ -101,4 +111,43 @@ public class VehicleItemDTO extends OrderItem { ...@@ -101,4 +111,43 @@ public class VehicleItemDTO extends OrderItem {
} }
return freeAmount; return freeAmount;
} }
// public Integer getActualNum() {
//
// }
public void initDetail(Integer ableFreeDays) {
if(StrUtil.isNotBlank(getDetail())) {
List<VehicleModelCalendarPriceDTO> metaList = JSONUtil.toList(JSONUtil.parseArray(getDetail()), VehicleModelCalendarPriceDTO.class);
//计算消费金额
List<VMCalendarPriceCostDTO> list = Convert.toList(VMCalendarPriceCostDTO.class, metaList);
//循环价格列表 获得对应消耗的免费天数
//循环已标记的已使用免费天数
Integer cycleNum = 0;
for(VMCalendarPriceCostDTO dto : list) {
if(ableFreeDays > cycleNum && cycleNum+ dto.getFreeDays() > ableFreeDays) { //本次累加天数 大于 可用免费天数
setCutNum(ableFreeDays);
Integer up = (ableFreeDays - cycleNum);
Integer down = dto.getFreeDays();
//根据百分比计算消费价格
dto.setFreeAndConsumeAmount(dto.getPrice(), dto.getPrice().multiply(
new BigDecimal(up+ "").divide(new BigDecimal(down+ ""), 2, RoundingMode.HALF_UP))
.setScale(2, RoundingMode.HALF_UP));
}else if(ableFreeDays > cycleNum){ //本次累加天数 小于等于 可用免费天数
setCutNum(getCutNum()+ dto.getFreeDays());
//直接设置价格
dto.setFreeAndConsumeAmount(dto.getPrice(), dto.getPrice());
this.offsetNum += 1;
}else { //上次累加天数 大于 可用天数
//直接设置价格
dto.setFreeAndConsumeAmount(dto.getPrice(), BigDecimal.ZERO);
}
cycleNum += dto.getFreeDays();
}
setDetail(JSONUtil.parseArray(list).toString());
}
}
} }
...@@ -15,4 +15,10 @@ public class AddMemberDTO extends AddOrderCommonDTO{ ...@@ -15,4 +15,10 @@ public class AddMemberDTO extends AddOrderCommonDTO{
@ApiModelProperty(value = "会员等级") @ApiModelProperty(value = "会员等级")
private Integer memberLevel; private Integer memberLevel;
/**
* 优惠券*
*/
@ApiModelProperty(value = "优惠卷卷号")
private String tickerNos;
} }
...@@ -20,4 +20,8 @@ public class NotifyUrlDTO { ...@@ -20,4 +20,8 @@ public class NotifyUrlDTO {
//支付类型 //支付类型
@ApiModelProperty(value = "支付类型") @ApiModelProperty(value = "支付类型")
private Integer type; private Integer type;
//支付类型
@ApiModelProperty(value = "支付方式")
private Integer payWay;
} }
\ No newline at end of file
...@@ -563,7 +563,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements ...@@ -563,7 +563,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
* @param tradeNo * @param tradeNo
*/ */
@Transactional @Transactional
public void payNotifyHandle(String orderNo, String tradeNo, Integer type) { public void payNotifyHandle(String orderNo, String tradeNo, Integer type, Integer payWay) {
OrderRentVehicleDetail orvd = new OrderRentVehicleDetail(); OrderRentVehicleDetail orvd = new OrderRentVehicleDetail();
OrderTourDetail otd = new OrderTourDetail(); OrderTourDetail otd = new OrderTourDetail();
OrderMemberDetail omd = new OrderMemberDetail(); OrderMemberDetail omd = new OrderMemberDetail();
...@@ -578,6 +578,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements ...@@ -578,6 +578,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
setHasPay(SYS_TRUE); setHasPay(SYS_TRUE);
setPayTime(System.currentTimeMillis()); setPayTime(System.currentTimeMillis());
setPayOrigin(type); setPayOrigin(type);
setPayWay(payWay);
setVersion(baseOrder.getVersion()); setVersion(baseOrder.getVersion());
}}; }};
...@@ -745,15 +746,15 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements ...@@ -745,15 +746,15 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
switch (sign) { switch (sign) {
case 2: case 2:
sendMsgDTO.setRoutKey(KEY_ORDER_CANCEL); sendMsgDTO.setRoutKey(KEY_ORDER_CANCEL);
// mqSenderFeign.sendMessage(ORDER_TOPIC, KEY_ORDER_CANCEL, JSONUtil.toJsonStr(orderMQDTO));
break; break;
case 4: case 4:
sendMsgDTO.setRoutKey(KEY_ORDER_PAY); sendMsgDTO.setRoutKey(KEY_ORDER_PAY);
// mqSenderFeign.sendMessage(ORDER_TOPIC, KEY_ORDER_PAY, JSONUtil.toJsonStr(orderMQDTO));
break; break;
case 6: case 6:
sendMsgDTO.setRoutKey(KEY_ORDER_FINLISH); sendMsgDTO.setRoutKey(KEY_ORDER_FINLISH);
// mqSenderFeign.sendMessage(ORDER_TOPIC, KEY_ORDER_FINLISH, JSONUtil.toJsonStr(orderMQDTO)); break;
case 101:
sendMsgDTO.setRoutKey(KEY_ORDER_PART_DEPOSIT);
break; break;
default: default:
break; break;
......
...@@ -156,6 +156,9 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> { ...@@ -156,6 +156,9 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
if(null != orderViolateCoverAmount) { if(null != orderViolateCoverAmount) {
depositDeductAmount = orderViolateCoverAmount; depositDeductAmount = orderViolateCoverAmount;
} }
if (null != depositViolateCoverAmount) {
depositDeductAmount = depositViolateCoverAmount;
}
if(topAmount.compareTo(depositDeductAmount) > 0) { if(topAmount.compareTo(depositDeductAmount) > 0) {
totalDeductAmount = totalDeductAmount.add(depositDeductAmount); totalDeductAmount = totalDeductAmount.add(depositDeductAmount);
topAmount = topAmount.subtract(depositDeductAmount); topAmount = topAmount.subtract(depositDeductAmount);
...@@ -485,6 +488,13 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> { ...@@ -485,6 +488,13 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
orderMQDTO.setOrderRentVehicleDetail(orderRentVehicleBiz.selectById(orderMQDTO.getDetailId())); orderMQDTO.setOrderRentVehicleDetail(orderRentVehicleBiz.selectById(orderMQDTO.getDetailId()));
//根据商品消费金额 设置changeAmount
vehicleItemDTO.setChangeAmount(inProgressVO.getConsumeAmount().subtract(vehicleItemDTO.getRealAmount()));
orderItemBiz.updateSelectiveByIdRe(vehicleItemDTO);
//发送押金退还完成队列消息
baseOrderBiz.sendOrderMq(orderMQDTO.getOrderRentVehicleDetail(), null, null, orderMQDTO, OrderMQDTO.ORDER_CANCEL);
//捕捉异常 //捕捉异常
try { try {
orderMsgBiz.handelMsgDeposit(orderMQDTO.getOrderRentVehicleDetail(), orderMQDTO, userFeign.userDetailById(orderMQDTO.getUserId()).getData()); orderMsgBiz.handelMsgDeposit(orderMQDTO.getOrderRentVehicleDetail(), orderMQDTO, userFeign.userDetailById(orderMQDTO.getUserId()).getData());
......
...@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil; ...@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.xxfc.platform.order.contant.enumerate.ItemTypeEnum; import com.xxfc.platform.order.contant.enumerate.ItemTypeEnum;
import com.xxfc.platform.order.pojo.order.VehicleItemDTO;
import com.xxfc.platform.vehicle.feign.VehicleFeign; import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO; import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO;
import com.xxfc.platform.vehicle.pojo.dto.order.VMCalendarPriceCostDTO; import com.xxfc.platform.vehicle.pojo.dto.order.VMCalendarPriceCostDTO;
......
...@@ -87,6 +87,8 @@ public class OrderCalculateBiz { ...@@ -87,6 +87,8 @@ public class OrderCalculateBiz {
public InProgressVO inProgressCalculate(BaseOrder baseOrder, VehicleItemDTO vehicleItemDTO, Integer freeDays, Integer useDays, OrderAccountDetail oad, Boolean isCancel) { public InProgressVO inProgressCalculate(BaseOrder baseOrder, VehicleItemDTO vehicleItemDTO, Integer freeDays, Integer useDays, OrderAccountDetail oad, Boolean isCancel) {
BigDecimal refundAmount = BigDecimal.ZERO; BigDecimal refundAmount = BigDecimal.ZERO;
BigDecimal consumeAmount = BigDecimal.ZERO; BigDecimal consumeAmount = BigDecimal.ZERO;
BigDecimal topViolateAmount = BigDecimal.ZERO;
BigDecimal itemChangeAmount = BigDecimal.ZERO;
//融入日期价格 //融入日期价格
List<VehicleModelCalendarPriceDTO> vmcpds = JSONUtil.toList(JSONUtil.parseArray(vehicleItemDTO.getDetail()), VehicleModelCalendarPriceDTO.class); List<VehicleModelCalendarPriceDTO> vmcpds = JSONUtil.toList(JSONUtil.parseArray(vehicleItemDTO.getDetail()), VehicleModelCalendarPriceDTO.class);
...@@ -203,7 +205,7 @@ public class OrderCalculateBiz { ...@@ -203,7 +205,7 @@ public class OrderCalculateBiz {
residueAmount = residueAmount.add(vmcpds.get(i).getPrice()); residueAmount = residueAmount.add(vmcpds.get(i).getPrice());
} }
String violateDesc = StrUtil.format("{}元", residueAmount.toString()); String violateDesc = StrUtil.format("{}元", residueAmount.toString());
if(residueDays > 2) { if(residueDays >= 2) {
residueDays = 2; residueDays = 2;
residueAmount = BigDecimal.ZERO; residueAmount = BigDecimal.ZERO;
for(int i = useDays; i < (useDays + residueDays + 1); i++) { for(int i = useDays; i < (useDays + residueDays + 1); i++) {
...@@ -216,6 +218,7 @@ public class OrderCalculateBiz { ...@@ -216,6 +218,7 @@ public class OrderCalculateBiz {
OrderAccountDeduction violateDeduction = orderAccountBiz.initDeduction(inProgressVO.getViolateAmount(), violateDesc, DeductionTypeEnum.VIOLATE_ADVANCE, OrderAccountDeduction.ORIGIN_DEPOSIT); OrderAccountDeduction violateDeduction = orderAccountBiz.initDeduction(inProgressVO.getViolateAmount(), violateDesc, DeductionTypeEnum.VIOLATE_ADVANCE, OrderAccountDeduction.ORIGIN_DEPOSIT);
oad.getDeductions().add(violateDeduction); oad.getDeductions().add(violateDeduction);
}else if(residueDays < 0 && !isCancel){ }else if(residueDays < 0 && !isCancel){
//isCancel 表示是否为取消,取消则不计算延期还车(因为没有出车)
//设置消耗费用列表 //设置消耗费用列表
useAmountList.addAll(Convert.toList(VMCalendarPriceCostDTO.class, vmcpds)); useAmountList.addAll(Convert.toList(VMCalendarPriceCostDTO.class, vmcpds));
//如果订单 出发中 或者 已完成 或者定损中 //如果订单 出发中 或者 已完成 或者定损中
...@@ -311,8 +314,6 @@ public class OrderCalculateBiz { ...@@ -311,8 +314,6 @@ public class OrderCalculateBiz {
public OrderRefundPriceVO getPriceCalculate (String no, OrderPageVO orderPageVO) { public OrderRefundPriceVO getPriceCalculate (String no, OrderPageVO orderPageVO) {
//根据no 查订单 //根据no 查订单
OrderTypeEnum orderTypeEnum = OrderTypeEnum.get(orderPageVO.getType()); OrderTypeEnum orderTypeEnum = OrderTypeEnum.get(orderPageVO.getType());
BigDecimal totalRefundAmount = BigDecimal.ZERO; BigDecimal totalRefundAmount = BigDecimal.ZERO;
...@@ -324,22 +325,24 @@ public class OrderCalculateBiz { ...@@ -324,22 +325,24 @@ public class OrderCalculateBiz {
switch (orderTypeEnum) { switch (orderTypeEnum) {
case RENT_VEHICLE: 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(); Long timeLag = orderPageVO.getOrderRentVehicleDetail().getStartTime() - System.currentTimeMillis();
OrderItem vehicleItem = orderItemBiz.selectOne(new OrderItem(){{ VehicleItemDTO vehicleItemDTO = BeanUtil.toBean(orderItemBiz.selectOne(new OrderItem(){{
setType(ItemTypeEnum.VEHICLE_MODEL.getCode()); setType(ItemTypeEnum.VEHICLE_MODEL.getCode());
setOrderId(orderPageVO.getId()); setOrderId(orderPageVO.getId());
}}); }}), VehicleItemDTO.class);
topAmount = vehicleItem.getUnitPrice().multiply(new BigDecimal(2+ ""));
//融入日期价格
List<VehicleModelCalendarPriceDTO> vmcpds = JSONUtil.toList(JSONUtil.parseArray(vehicleItemDTO.getDetail()), VehicleModelCalendarPriceDTO.class);
if(timeLag < 0 ) { if(timeLag < 0 ) {
Integer useDays = getIncludeDays(orderPageVO.getOrderRentVehicleDetail().getStartTime(), DateTime.now().getMillis());
OrderAccountDetail oad = new OrderAccountDetail(); OrderAccountDetail oad = new OrderAccountDetail();
Integer freeDays = (null == vehicleItem.getCutNum())?0 :vehicleItem.getCutNum(); Integer freeDays = (null == vehicleItemDTO.getCutNum())?0 :vehicleItemDTO.getCutNum();
//inProgressVO = inProgressCalculate(orderPageVO, vehicleItem, freeDays, baseOrderBiz.getDaysBetweenDateTime(startTime, nowTime), new OrderAccountDetail(), Boolean.FALSE); inProgressVO = inProgressCalculate(orderPageVO, vehicleItemDTO, freeDays, useDays, new OrderAccountDetail(), Boolean.FALSE);
topAmount = vehicleItemDTO.getTopAmount(useDays);
totalDeductAmount = oad.realTotalDeduct(); totalDeductAmount = oad.realTotalDeduct();
totalRefundAmount = oad.getOrderAmount().add(oad.getDepositAmount()); totalRefundAmount = oad.getOrderAmount().add(oad.getDepositAmount());
refundDesc = inProgressVO.getViolateDesc(); refundDesc = inProgressVO.getViolateDesc();
...@@ -347,11 +350,12 @@ public class OrderCalculateBiz { ...@@ -347,11 +350,12 @@ public class OrderCalculateBiz {
String key = RENT_REFUND; String key = RENT_REFUND;
BigDecimal deductionAmount = orderAccountBiz.calculateDeduction(vehicleItem.getBuyAmount() BigDecimal deductionAmount = orderAccountBiz.calculateDeduction(vehicleItemDTO.getBuyAmount()
, orderPageVO.getOrderRentVehicleDetail().getStartTime() - System.currentTimeMillis() , orderPageVO.getOrderRentVehicleDetail().getStartTime() - System.currentTimeMillis()
, DictionaryKey.APP_ORDER+ "_"+ key , DictionaryKey.APP_ORDER+ "_"+ key
, refundDescBuilder); , refundDescBuilder);
topAmount = vehicleItemDTO.getTopAmount(0);
totalDeductAmount = deductionAmount; totalDeductAmount = deductionAmount;
totalRefundAmount = orderPageVO.getRealAmount().subtract(deductionAmount); totalRefundAmount = orderPageVO.getRealAmount().subtract(deductionAmount);
refundDesc = refundDescBuilder.toString(); refundDesc = refundDescBuilder.toString();
...@@ -377,13 +381,13 @@ public class OrderCalculateBiz { ...@@ -377,13 +381,13 @@ public class OrderCalculateBiz {
BigDecimal adultItemAmount = (null == adultItem)? BigDecimal.ZERO: adultItem.getRealAmount(); BigDecimal adultItemAmount = (null == adultItem)? BigDecimal.ZERO: adultItem.getRealAmount();
BigDecimal childItemAmount = (null == childItem)? BigDecimal.ZERO: childItem.getRealAmount(); BigDecimal childItemAmount = (null == childItem)? BigDecimal.ZERO: childItem.getRealAmount();
topAmount = adultItemAmount.add(childItemAmount);
BigDecimal deductionAmount = orderAccountBiz.calculateDeduction(adultItemAmount.add(childItemAmount) BigDecimal deductionAmount = orderAccountBiz.calculateDeduction(adultItemAmount.add(childItemAmount)
, orderPageVO.getOrderTourDetail().getStartTime() - System.currentTimeMillis() , orderPageVO.getOrderTourDetail().getStartTime() - System.currentTimeMillis()
, DictionaryKey.APP_ORDER+ "_"+ key , DictionaryKey.APP_ORDER+ "_"+ key
, refundDescBuilder); , refundDescBuilder);
topAmount = adultItemAmount.add(childItemAmount);
totalDeductAmount = deductionAmount; totalDeductAmount = deductionAmount;
totalRefundAmount = orderPageVO.getRealAmount().subtract(deductionAmount); totalRefundAmount = orderPageVO.getRealAmount().subtract(deductionAmount);
refundDesc = refundDescBuilder.toString(); refundDesc = refundDescBuilder.toString();
...@@ -399,4 +403,8 @@ public class OrderCalculateBiz { ...@@ -399,4 +403,8 @@ public class OrderCalculateBiz {
orpv.setTopAmount(topAmount); orpv.setTopAmount(topAmount);
return orpv; return orpv;
} }
public static void main(String[] args) {
System.out.println(DateTime.now().getMillis());
}
} }
\ No newline at end of file
...@@ -3,7 +3,6 @@ package com.xxfc.platform.order.biz.inner; ...@@ -3,7 +3,6 @@ package com.xxfc.platform.order.biz.inner;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.github.wxiaoqi.security.admin.feign.UserFeign; import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO; import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
...@@ -32,7 +31,6 @@ import org.springframework.stereotype.Service; ...@@ -32,7 +31,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
...@@ -150,6 +148,9 @@ public class OrderCancelBiz { ...@@ -150,6 +148,9 @@ public class OrderCancelBiz {
Long timeLag = orvd.getStartTime() - System.currentTimeMillis(); Long timeLag = orvd.getStartTime() - System.currentTimeMillis();
if(timeLag < 0 ) { if(timeLag < 0 ) {
Integer useDays = orderCalculateBiz.getIncludeDays(orvd.getStartTime(), System.currentTimeMillis()); Integer useDays = orderCalculateBiz.getIncludeDays(orvd.getStartTime(), System.currentTimeMillis());
if(useDays > orvd.getDayNum()) {
useDays = orvd.getUsedDay();
}
inProgressVO = orderCalculateBiz.calculateOrderComplete(baseOrder, orvd, oad, vehicleItemDTO, useDays, Boolean.TRUE); inProgressVO = orderCalculateBiz.calculateOrderComplete(baseOrder, orvd, oad, vehicleItemDTO, useDays, Boolean.TRUE);
//判断是否修改违约金 //判断是否修改违约金
...@@ -194,9 +195,18 @@ public class OrderCancelBiz { ...@@ -194,9 +195,18 @@ public class OrderCancelBiz {
//orderTemplateBiz.handleCostDetailExtend(csv); //orderTemplateBiz.handleCostDetailExtend(csv);
orvd.handelCostDetailExtend(csv); orvd.handelCostDetailExtend(csv);
orderRentVehicleBiz.updateSelectiveByIdRe(orvd); orderRentVehicleBiz.updateSelectiveByIdRe(orvd);
//根据商品消费金额 设置changeAmount
vehicleItemDTO.setChangeAmount(inProgressVO.getConsumeAmount().subtract(vehicleItemDTO.getRealAmount()));
orderItemBiz.updateSelectiveByIdRe(vehicleItemDTO);
}else { }else {
// //没到出车时间 // //没到出车时间
//判断是否修改违约金
if(null != changeViolateAmount) {
oad.changeCancelViolate(changeViolateAmount);
}
//退款流程 //退款流程
//违约金封顶 租车身份价 * 2天 //违约金封顶 租车身份价 * 2天
orderAccountBiz.rentRefundProcessCancel(baseOrder, BigDecimal.ZERO, timeLag, APP_ORDER+ "_"+ RENT_REFUND, orvd.getDeposit(), vehicleItemDTO.getBuyAmount(), oad, vehicleItemDTO.getTopAmount(0), null, changeViolateAmount); orderAccountBiz.rentRefundProcessCancel(baseOrder, BigDecimal.ZERO, timeLag, APP_ORDER+ "_"+ RENT_REFUND, orvd.getDeposit(), vehicleItemDTO.getBuyAmount(), oad, vehicleItemDTO.getTopAmount(0), null, changeViolateAmount);
......
...@@ -283,7 +283,7 @@ public class BaseOrderController extends CommonBaseController implements UserRes ...@@ -283,7 +283,7 @@ public class BaseOrderController extends CommonBaseController implements UserRes
public ObjectRestResponse notifyUrl(NotifyUrlDTO dto) { public ObjectRestResponse notifyUrl(NotifyUrlDTO dto) {
//判断是否成功,并且订单是未支付状态,则添加支付编号和修改状态 //判断是否成功,并且订单是未支付状态,则添加支付编号和修改状态
if (StrUtil.isNotBlank(dto.getOrderNo())) { if (StrUtil.isNotBlank(dto.getOrderNo())) {
baseOrderBiz.payNotifyHandle(dto.getOrderNo(), dto.getTradeNo(), dto.getType()); baseOrderBiz.payNotifyHandle(dto.getOrderNo(), dto.getTradeNo(), dto.getType(), dto.getPayWay());
} else { } else {
log.error(" exception notifyUrl : " + JSONUtil.toJsonStr(dto)); log.error(" exception notifyUrl : " + JSONUtil.toJsonStr(dto));
} }
......
package com.xxfc.platform.order.rest; package com.xxfc.platform.order.rest;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.github.wxiaoqi.security.admin.feign.UserFeign; import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken; import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken; import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
...@@ -46,7 +47,8 @@ public class OrderMemberController extends BaseController<OrderMemberDetailBiz, ...@@ -46,7 +47,8 @@ public class OrderMemberController extends BaseController<OrderMemberDetailBiz,
@ApiOperation(value = "确认会员订单") @ApiOperation(value = "确认会员订单")
public ObjectRestResponse<BaseOrder> add(@RequestBody AddMemberDTO dto) { public ObjectRestResponse<BaseOrder> add(@RequestBody AddMemberDTO dto) {
MemberBO bo = BeanUtil.toBean(dto, MemberBO.class); MemberBO bo = BeanUtil.toBean(dto, MemberBO.class);
bo.setTickerNo(StrUtil.isNotBlank(dto.getTickerNos())?
StrUtil.splitTrim(dto.getTickerNos(), ","):null);
//查询会员等级实体 //查询会员等级实体
// bo.setBaseUserMemberLevel(userFeign.memberEntityList(BeanUtil.beanToMap(new BaseUserMemberLevel(){{ // bo.setBaseUserMemberLevel(userFeign.memberEntityList(BeanUtil.beanToMap(new BaseUserMemberLevel(){{
// setId(dto.getMemberLevelId()); // setId(dto.getMemberLevelId());
......
...@@ -73,93 +73,13 @@ public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRe ...@@ -73,93 +73,13 @@ public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRe
setLimit(1); setLimit(1);
setPage(1); setPage(1);
}}){{put("no", no); }}.getSuper()).get(0); }}){{put("no", no); }}.getSuper()).get(0);
OrderRefundPriceVO orpv = orderCalculateBiz.getPriceCalculate(no, orderPageVO);
OrderTypeEnum orderTypeEnum = OrderTypeEnum.get(orderPageVO.getType());
BigDecimal totalRefundAmount = BigDecimal.ZERO;
BigDecimal totalDeductAmount = BigDecimal.ZERO;
StringBuilder refundDescBuilder = new StringBuilder("");
String refundDesc = "";
InProgressVO inProgressVO = new InProgressVO();
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();
VehicleItemDTO vehicleItemDTO = BeanUtil.toBean(orderItemBiz.selectOne(new OrderItem(){{
setType(ItemTypeEnum.VEHICLE_MODEL.getCode());
setOrderId(orderPageVO.getId());
}}), VehicleItemDTO.class);
if(timeLag < 0 ) {
OrderAccountDetail oad = new OrderAccountDetail();
Integer freeDays = (null == vehicleItemDTO.getCutNum())?0 :vehicleItemDTO.getCutNum();
inProgressVO = orderCalculateBiz.inProgressCalculate(orderPageVO, vehicleItemDTO, freeDays, baseOrderBiz.getDaysBetweenDateTime(startTime, nowTime), new OrderAccountDetail(), Boolean.FALSE);
//.inProgressCalculate(orderPageVO, baseOrderBiz.getDaysBetweenDateTime(startTime, nowTime));
totalDeductAmount = oad.realTotalDeduct();
totalRefundAmount = oad.getOrderAmount().add(oad.getDepositAmount());
refundDesc = inProgressVO.getViolateDesc();
}else {
String key = RENT_REFUND;
BigDecimal deductionAmount = orderAccountBiz.calculateDeduction(vehicleItemDTO.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();
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);
if(orderPageVO.getStatus().equals(OrderStatusEnum.ORDER_UNPAY.getCode()) if(orderPageVO.getStatus().equals(OrderStatusEnum.ORDER_UNPAY.getCode())
|| orderPageVO.getStatus().equals(OrderStatusEnum.ORDER_CRT.getCode()) || orderPageVO.getStatus().equals(OrderStatusEnum.ORDER_CRT.getCode())
|| orpv.getRefundAmount().compareTo(BigDecimal.ZERO) <= 0) { || orpv.getRefundAmount().compareTo(BigDecimal.ZERO) <= 0) {
orpv.setRefundDesc("是否确定取消订单"); orpv.setRefundDesc("是否确定取消订单");
}else { }else {
orpv.setRefundDesc(StrUtil.format("本次取消操作需要扣除{}元违约金,实际退款金额为{}元,您确定要取消订单吗?", totalDeductAmount, totalRefundAmount)); orpv.setRefundDesc(StrUtil.format("本次取消操作需要扣除{}元违约金,实际退款金额为{}元,您确定要取消订单吗?", orpv.getRealAmount(), orpv.getRefundAmount()));
} }
return ObjectRestResponse.succ(orpv); return ObjectRestResponse.succ(orpv);
} }
...@@ -169,7 +89,7 @@ public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRe ...@@ -169,7 +89,7 @@ public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRe
@ResponseBody @ResponseBody
@IgnoreClientToken @IgnoreClientToken
public ObjectRestResponse<BigDecimal> getViolatePrice(@PathVariable(value = "no") String no) { public ObjectRestResponse<BigDecimal> getViolatePrice(@PathVariable(value = "no") String no) {
checkAppUser(); checkAdminUser();
OrderPageVO orderPageVO = baseOrderBiz.pageByParm(new Query(new PageParam(){{ OrderPageVO orderPageVO = baseOrderBiz.pageByParm(new Query(new PageParam(){{
setLimit(1); setLimit(1);
setPage(1); setPage(1);
......
...@@ -162,6 +162,7 @@ public class OrderRentVehicleController extends CommonBaseController { ...@@ -162,6 +162,7 @@ public class OrderRentVehicleController extends CommonBaseController {
}}); }});
bo.setAppUserDTO(userFeign.userDetailByToken(BaseContextHandler.getToken()).getData()); bo.setAppUserDTO(userFeign.userDetailByToken(BaseContextHandler.getToken()).getData());
bo.setTickerNo(StrUtil.isNotBlank(vo.getTickerNos())? Arrays.asList(vo.getTickerNos().split(",")):null); bo.setTickerNo(StrUtil.isNotBlank(vo.getTickerNos())? Arrays.asList(vo.getTickerNos().split(",")):null);
bo.setDayNum(orderCalculateBiz.getIncludeDays(vo.getStartTime(), vo.getEndTime()));
orderRentVehicleService.initDetailSecond(bo); orderRentVehicleService.initDetailSecond(bo);
return ObjectRestResponse.succ(orderRentVehicleService.calculatePrice(bo)); return ObjectRestResponse.succ(orderRentVehicleService.calculatePrice(bo));
} }
......
...@@ -150,8 +150,8 @@ public abstract class AbstractOrderHandle<Biz extends BaseBiz, Detail extends Or ...@@ -150,8 +150,8 @@ public abstract class AbstractOrderHandle<Biz extends BaseBiz, Detail extends Or
if(BigDecimal.ZERO.compareTo(realAmount) > 0) { if(BigDecimal.ZERO.compareTo(realAmount) > 0) {
throw new BaseException(ResultCode.FAILED_CODE); throw new BaseException(ResultCode.FAILED_CODE);
}else if(BigDecimal.ZERO.compareTo(realAmount) == 0) { }else if(BigDecimal.ZERO.compareTo(realAmount) == 0) {
//直接支付 //直接支付 0表示不需要支付
baseOrderBiz.payNotifyHandle(detail.getOrder().getNo(), null, detail.getOrderOrigin()); baseOrderBiz.payNotifyHandle(detail.getOrder().getNo(), null, detail.getOrderOrigin(), 0);
} }
} }
/** /**
......
...@@ -9,6 +9,7 @@ import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig; ...@@ -9,6 +9,7 @@ import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.activity.entity.Coupon;
import com.xxfc.platform.activity.feign.ActivityFeign; import com.xxfc.platform.activity.feign.ActivityFeign;
import com.xxfc.platform.order.biz.BaseOrderBiz; import com.xxfc.platform.order.biz.BaseOrderBiz;
import com.xxfc.platform.order.biz.OrderCostDetailBiz; import com.xxfc.platform.order.biz.OrderCostDetailBiz;
...@@ -99,6 +100,7 @@ public class OrderMemberService extends AbstractOrderHandle<OrderMemberDetailBiz ...@@ -99,6 +100,7 @@ public class OrderMemberService extends AbstractOrderHandle<OrderMemberDetailBiz
@PostConstruct @PostConstruct
public void init() { public void init() {
this.channel = Coupon.CHANNEL_MEMBER;
this.orderTypeEnum = OrderTypeEnum.MEMBER; this.orderTypeEnum = OrderTypeEnum.MEMBER;
} }
......
...@@ -39,6 +39,7 @@ import com.xxfc.platform.vehicle.entity.VehicleModel; ...@@ -39,6 +39,7 @@ 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 com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO; import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO;
import com.xxfc.platform.vehicle.pojo.dto.order.VMCalendarPriceCostDTO;
import com.xxfc.platform.vehicle.pojo.vo.AccompanyingItemVo; import com.xxfc.platform.vehicle.pojo.vo.AccompanyingItemVo;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -229,7 +230,8 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -229,7 +230,8 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
String couponDesc = ""; String couponDesc = "";
Integer vehicleDayNum = 0; Integer vehicleDayNum = 0;
Integer freeDayNum = 0; Integer freeDayNum = 0;
Integer cutDayNum = 0; //抵消的天数
Integer offsetNum = 0;
//当前用户 //当前用户
AppUserDTO dto = detail.getAppUserDTO(); AppUserDTO dto = detail.getAppUserDTO();
...@@ -238,7 +240,8 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -238,7 +240,8 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
VehicleModel vehicleModel = vehicleFeign.get(detail.getModelId()).getData(); VehicleModel vehicleModel = vehicleFeign.get(detail.getModelId()).getData();
detail.initDate(); detail.initDate();
List<VehicleModelCalendarPriceDTO> vmcpds = vehicleFeign.findVehicleModelCalendarPriceByDate(detail.getStartTime(), detail.getEndTime(), detail.getModelId(), dto.getUserid()).getData(); List<VehicleModelCalendarPriceDTO> metaVmcpds = vehicleFeign.findVehicleModelCalendarPriceByDate(detail.getStartTime(), detail.getEndTime(), detail.getModelId(), dto.getUserid()).getData();
List<VMCalendarPriceCostDTO> vmcpds = Convert.toList(VMCalendarPriceCostDTO.class, metaVmcpds);
//设置Item //设置Item
...@@ -260,24 +263,29 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -260,24 +263,29 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
}}); }});
} }
//循环价格列表 获得对应消耗的免费天数 // //循环价格列表 获得对应消耗的免费天数
for(VehicleModelCalendarPriceDTO vmcpd : vmcpds) { // for(VehicleModelCalendarPriceDTO vmcpd : vmcpds) {
//如果新的相加消耗天数 大于 拥有天数 // //如果新的相加消耗天数 大于 拥有天数
if(freeDayNum+ vmcpd.getFreeDays() > dto.getRentFreeDays()) { // if(freeDayNum+ vmcpd.getFreeDays() > dto.getRentFreeDays()) {
//freeDayNum = dto.getRentFreeDays(); // //freeDayNum = dto.getRentFreeDays();
break; // break;
}else { // }else {
freeDayNum += detail.getDayNum(); // freeDayNum += detail.getDayNum();
cutDayNum += 1; // cutDayNum += 1;
} // }
} // }
vehicleOrderItem.setCutNum(cutDayNum); // vehicleOrderItem.setCutNum(cutDayNum);
vehicleDayNum = detail.getDayNum() - cutDayNum; vehicleOrderItem.initDetail(dto.getRentFreeDays());
freeDayNum = vehicleOrderItem.getCutNum();
offsetNum = vehicleOrderItem.getOffsetNum();
vehicleDayNum = detail.getDayNum() - offsetNum;
detail.getOrder().setHasMemberRight(SYS_TRUE); detail.getOrder().setHasMemberRight(SYS_TRUE);
}else { }else {
vehicleOrderItem.initDetail(0);
vehicleDayNum = detail.getDayNum(); vehicleDayNum = detail.getDayNum();
} }
vmcpds = vehicleOrderItem.getVehicleDetail();
detail.setFreeDays(freeDayNum); detail.setFreeDays(freeDayNum);
//计算价格 //计算价格
...@@ -309,14 +317,22 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -309,14 +317,22 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
// default: // default:
// break; // break;
// } // }
//设置是否使用会员权益
for(VMCalendarPriceCostDTO vmcpcd : vehicleOrderItem.getVehicleDetail()) {
if(!vmcpcd.getNo_discount_price().equals(vmcpcd.getPrice())) {
detail.getOrder().setHasMemberRight(SYS_TRUE);
break;
}
}
detail.setRebate(dto.getDiscount()); detail.setRebate(dto.getDiscount());
// vehicleOrderItem.setUnitPrice(handleDiscountDTO.getModelAmount()); // vehicleOrderItem.setUnitPrice(handleDiscountDTO.getModelAmount());
} }
//计算价格 //计算价格
if(vehicleDayNum > 0) { if(vehicleDayNum > 0) {
for(int i = cutDayNum; i < vmcpds.size(); i++) { for(int i = offsetNum; i < vmcpds.size(); i++) {
vehicleAmount = vehicleAmount.add(vmcpds.get(i).getPrice()); vehicleAmount = vehicleAmount.add(vmcpds.get(i).getConsumeAmount());
metaVehicleAmount = metaVehicleAmount.add(vmcpds.get(i).getNo_discount_price()); metaVehicleAmount = metaVehicleAmount.add(vmcpds.get(i).getNo_discount_price());
} }
}else { }else {
...@@ -392,7 +408,7 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -392,7 +408,7 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
rvp.setVehicleDayNum(vehicleDayNum); rvp.setVehicleDayNum(vehicleDayNum);
rvp.setFreeDayNum(freeDayNum); rvp.setFreeDayNum(freeDayNum);
rvp.setCutDayNum(cutDayNum); rvp.setCutDayNum(offsetNum);
rvp.setFreeAmount(vehicleOrderItem.getCutAmount()); rvp.setFreeAmount(vehicleOrderItem.getCutAmount());
rvp.setBuyVehicleAmount(vehicleOrderItem.getBuyAmount()); rvp.setBuyVehicleAmount(vehicleOrderItem.getBuyAmount());
rvp.setRealVehicleAmount(vehicleOrderItem.getRealAmount()); rvp.setRealVehicleAmount(vehicleOrderItem.getRealAmount());
......
...@@ -27,22 +27,16 @@ import java.util.Map; ...@@ -27,22 +27,16 @@ import java.util.Map;
@Slf4j @Slf4j
public class XCFQPictureParsingImpl implements UserPictureParsing { public class XCFQPictureParsingImpl implements UserPictureParsing {
private String appcode = "acea1c8811f748b3a65815f11db357c4"; // private String appcode = "acea1c8811f748b3a65815f11db357c4";
private String appcode2 = "ee7710ce92054cae9f6c040f6864e6a7"; private String appcode2 = "ee7710ce92054cae9f6c040f6864e6a7";
/** /**
* 认证相关的数据 * 认证相关的数据
*/ */
private String host = "https://ocridcard.market.alicloudapi.com"; private String host = "https://ocridcards.market.alicloudapi.com";
private String path = "/idimages";
private String path = "/idcard";
private String methd = "POST";
private String imageRet = "code"; private String method = "POST";
private String resultCode = "1";
private String dataNam = "result"; private String dataNam = "result";
...@@ -81,18 +75,32 @@ public class XCFQPictureParsingImpl implements UserPictureParsing { ...@@ -81,18 +75,32 @@ public class XCFQPictureParsingImpl implements UserPictureParsing {
} }
private Map<String,String> judgeAccordingToAnalyticalData(String imageUrl, String type) { private Map<String,String> judgeAccordingToAnalyticalData(String imageUrl, String type) {
String json = imageParse(imageUrl, type); String json = imageParse(imageUrl);
log.info("json:" + json); log.info("json:" + json);
if (StringUtils.isBlank(json)) { if (StringUtils.isBlank(json)) {
return null; return null;
} }
Map reuslt = (Map) JSONObject.parse(json); Map reuslt = (Map) JSONObject.parse(json);
//判断是否调用图片解析的接口是否异常,若果两个次认证都没结果 //判断是否调用图片解析的接口是否异常,若果两个次认证都没结果
if (MapUtil.isEmpty(reuslt) if ("front".equals(type)) {
|| !(reuslt.get(imageRet).equals(resultCode)) if (MapUtil.isEmpty(reuslt)
) { || !(reuslt.get("code").equals("1"))
return null; ) {
return null;
}
}
if ("back".equals(type)) {
if (MapUtil.isEmpty(reuslt)
|| !(reuslt.get("code").equals("2"))
) {
return null;
}
} }
Map<String,String> map = (Map) reuslt.get(dataNam); Map<String,String> map = (Map) reuslt.get(dataNam);
log.info("map:" + map); log.info("map:" + map);
if (MapUtils.isNotEmpty(map)) { if (MapUtils.isNotEmpty(map)) {
...@@ -103,14 +111,12 @@ public class XCFQPictureParsingImpl implements UserPictureParsing { ...@@ -103,14 +111,12 @@ public class XCFQPictureParsingImpl implements UserPictureParsing {
//身份证照片解析 //身份证照片解析
private String imageParse(String imageUrl, String type) { private String imageParse(String imageUrl) {
Map<String, String> headers = new HashMap<String, String>(); Map<String, String> headers = new HashMap<String, String>();
headers.put("Authorization", "APPCODE " + appcode2); headers.put("Authorization", "APPCODE " + appcode2);
Map<String, String> querys = new HashMap<String, String>(); Map<String, String> querys = new HashMap<String, String>();
Map<String, String> bodys = new HashMap<String, String>(); Map<String, String> bodys = new HashMap<String, String>();
bodys.put("image", imageUrl); bodys.put("image", imageUrl);
//默认正面front,背面请传back
bodys.put("idCardSide", type);
try { try {
return callExternalRequest(headers,querys,bodys,1); return callExternalRequest(headers,querys,bodys,1);
} catch (Exception e) { } catch (Exception e) {
...@@ -125,7 +131,7 @@ public class XCFQPictureParsingImpl implements UserPictureParsing { ...@@ -125,7 +131,7 @@ public class XCFQPictureParsingImpl implements UserPictureParsing {
Map<String, String> bodys, Map<String, String> bodys,
int type) throws Exception { int type) throws Exception {
HttpResponse response = CertifHttpUtils.doPost(host, path, methd, headers, querys, bodys); HttpResponse response = CertifHttpUtils.doPost(host, path, method, headers, querys, bodys);
log.info("response:"+response); log.info("response:"+response);
StatusLine statusLine = response.getStatusLine(); StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode(); int statusCode = statusLine.getStatusCode();
...@@ -140,13 +146,7 @@ public class XCFQPictureParsingImpl implements UserPictureParsing { ...@@ -140,13 +146,7 @@ public class XCFQPictureParsingImpl implements UserPictureParsing {
} }
if (403==statusCode){ if (403==statusCode){
if (type==2){
log.error("验证次数已用完"); log.error("验证次数已用完");
return null;
}
Map<String, String> headers2 = new HashMap<String, String>();
headers.put("Authorization", "APPCODE " + appcode);
return callExternalRequest(headers2,querys,bodys,2);
} }
return null; return null;
......
...@@ -27,9 +27,8 @@ import java.util.Map; ...@@ -27,9 +27,8 @@ import java.util.Map;
@Primary @Primary
public class XCFQAuthentication implements UserAuthentication { public class XCFQAuthentication implements UserAuthentication {
private String appcode="acea1c8811f748b3a65815f11db357c4"; // private String appcode="acea1c8811f748b3a65815f11db357c4";
private String appcode2="ee7710ce92054cae9f6c040f6864e6a7"; private String appcode2 = "ee7710ce92054cae9f6c040f6864e6a7";
/** /**
* 认证相关的数据 * 认证相关的数据
...@@ -38,7 +37,7 @@ public class XCFQAuthentication implements UserAuthentication { ...@@ -38,7 +37,7 @@ public class XCFQAuthentication implements UserAuthentication {
private String path = "/idcard"; private String path = "/idcard";
private String methd = "GET"; private String method = "GET";
//响应:认证错误码字段名 //响应:认证错误码字段名
private String certifRet = "status"; private String certifRet = "status";
...@@ -58,7 +57,7 @@ public class XCFQAuthentication implements UserAuthentication { ...@@ -58,7 +57,7 @@ public class XCFQAuthentication implements UserAuthentication {
Map<String, String> headers = new HashMap<String, String>(); Map<String, String> headers = new HashMap<String, String>();
headers.put("Authorization", "APPCODE " + appcode2); headers.put("Authorization", "APPCODE " + appcode2);
try { try {
callExternalRequest(message,headers,1); return callExternalRequest(message, headers, 1);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -66,19 +65,19 @@ public class XCFQAuthentication implements UserAuthentication { ...@@ -66,19 +65,19 @@ public class XCFQAuthentication implements UserAuthentication {
} }
private boolean callExternalRequest(UserMessage message, Map<String, String> headers,int type) throws Exception { private boolean callExternalRequest(UserMessage message, Map<String, String> headers, int type) throws Exception {
//map携带身份证和姓名进行认证 //map携带身份证和姓名进行认证
Map<String, String> querys = new HashMap<>(); Map<String, String> querys = new HashMap<>();
querys.put(idCardName, message.getIdNumber()); querys.put(idCardName, message.getIdNumber());
querys.put(cName, message.getName()); querys.put(cName, message.getName());
log.info("----querys=========" + querys); log.info("----querys=========" + querys);
HttpResponse response = HttpUtils.doGet(hsot, path, methd, headers, querys); HttpResponse response = HttpUtils.doGet(hsot, path, method, headers, querys);
StatusLine statusLine = response.getStatusLine(); StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode(); int statusCode = statusLine.getStatusCode();
/** /**
* 状态码: 200 正常;400 URL无效;401 appCode错误; 403 次数用完; 500 API网管错误 * 状态码: 200 正常;400 URL无效;401 appCode错误; 403 次数用完; 500 API网管错误
*/ */
log.info("外部接口响应状态码:"+statusCode); log.info("外部接口响应状态码:" + statusCode);
//获取response的body //获取response的body
if (statusCode == 200) { if (statusCode == 200) {
...@@ -86,22 +85,17 @@ public class XCFQAuthentication implements UserAuthentication { ...@@ -86,22 +85,17 @@ public class XCFQAuthentication implements UserAuthentication {
log.info("----认证结果result=========" + result); log.info("----认证结果result=========" + result);
//认证返回的参数是否为空 //认证返回的参数是否为空
if (!StringUtils.isBlank(result)) { if (!StringUtils.isBlank(result)) {
Map<String, Object> map = (Map<String, Object>) JSONObject.parse(result); Map<String,String> map = (Map<String, String>) JSONObject.parse(result);
log.info("----响应数据=========" + map); log.info("----响应数据=========" + map);
if (MapUtil.isNotEmpty(map) || certifResultCode.equals(map.get(certifRet))) { if (MapUtil.isNotEmpty(map) && certifResultCode.equals(map.get("status"))) {
log.info("认证成功");
return true; return true;
} }
} }
} }
if (403==statusCode){ if (403 == statusCode) {
if (type==2){ log.error("验证次数已用完");
log.error("验证次数已用完");
return false;
}
Map<String, String> headers2 = new HashMap<String, String>();
headers.put("Authorization", "APPCODE " + appcode);
return callExternalRequest(message,headers2,2);
} }
return false; return false;
......
...@@ -182,4 +182,8 @@ public class VehicleModel implements Serializable { ...@@ -182,4 +182,8 @@ public class VehicleModel implements Serializable {
@Column(name = "img_desc") @Column(name = "img_desc")
@ApiModelProperty("seo*html标签优化") @ApiModelProperty("seo*html标签优化")
private String imgDesc; private String imgDesc;
@Column(name = "app_show")
@ApiModelProperty("是否在App展示")
private Integer appShow;
} }
...@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; ...@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO; import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
@Data @Data
...@@ -11,4 +12,19 @@ public class VMCalendarPriceCostDTO extends VehicleModelCalendarPriceDTO { ...@@ -11,4 +12,19 @@ public class VMCalendarPriceCostDTO extends VehicleModelCalendarPriceDTO {
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd") @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd")
private Date date; private Date date;
/**
* 消费金额
*/
private BigDecimal consumeAmount = BigDecimal.ZERO;
/**
* 免费金额
*/
private BigDecimal freeAmount = BigDecimal.ZERO;
public void setFreeAndConsumeAmount(BigDecimal realAmount, BigDecimal freeAmount) {
setFreeAmount(freeAmount);
setConsumeAmount(realAmount.subtract(freeAmount));
}
} }
...@@ -62,10 +62,12 @@ public class VehicleActiveService { ...@@ -62,10 +62,12 @@ public class VehicleActiveService {
log.info("出车参数: departureVo = {}", departureVo.toString()); log.info("出车参数: departureVo = {}", departureVo.toString());
Vehicle vehicle = vehicleBiz.selectById(departureVo.getVehicleId()); Vehicle vehicle = vehicleBiz.selectById(departureVo.getVehicleId());
if (vehicle == null) { if (vehicle == null) {
log.info("出车异常,车辆不存在!");
throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getDesc(), throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getDesc(),
ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode()); ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode());
} }
if (StringUtils.isBlank(departureVo.getCheckMan()) || StringUtils.isBlank(departureVo.getCheckManTel())) { if (StringUtils.isBlank(departureVo.getCheckMan()) || StringUtils.isBlank(departureVo.getCheckManTel())) {
log.error("出车 核销人姓名不能为空!");
throw new BaseException(ResCode.CHECKUSER_AND_PHONE_NOT_NULL.getDesc(), throw new BaseException(ResCode.CHECKUSER_AND_PHONE_NOT_NULL.getDesc(),
ResCode.CHECKUSER_AND_PHONE_NOT_NULL.getCode()); ResCode.CHECKUSER_AND_PHONE_NOT_NULL.getCode());
} }
...@@ -74,7 +76,11 @@ public class VehicleActiveService { ...@@ -74,7 +76,11 @@ public class VehicleActiveService {
ResCode.VEHICLE_STATUS_IS_NOT_NORMAL.getCode()); ResCode.VEHICLE_STATUS_IS_NOT_NORMAL.getCode());
} }
//添加出车时间过滤 再出车开始时间前一天至结束时间内可以出车,并且预定记录为已审核状态 //添加出车时间过滤 再出车开始时间前一天至结束时间内可以出车,并且预定记录为已审核状态
checkDateInvalid(departureVo); try {
checkDateInvalid(departureVo);
} catch (BaseException b) {
throw new BaseException(b.getMessage(), b.getStatus());
}
Integer MileageLift = vehicle.getMileageLastUpdate(); Integer MileageLift = vehicle.getMileageLastUpdate();
Integer MileageLift1 = departureVo.getMileage(); Integer MileageLift1 = departureVo.getMileage();
if (MileageLift1 == null) { if (MileageLift1 == null) {
...@@ -85,8 +91,12 @@ public class VehicleActiveService { ...@@ -85,8 +91,12 @@ public class VehicleActiveService {
// 写入车辆公里数,预计目的地 // 写入车辆公里数,预计目的地
vehicle.setMileageLastUpdate(MileageLift1); vehicle.setMileageLastUpdate(MileageLift1);
// 修改车辆状态,确认是空闲状态 // 修改车辆状态,确认是空闲状态
int result = vehicleMapper.updateStatusByIdAndStatus(departureVo.getVehicleId(), VehicleStatus.DEPARTURE.getCode(), if (vehicle.getStatus().equals(VehicleStatus.NORMAL.getCode())) {
VehicleStatus.NORMAL.getCode()); vehicle.setStatus(VehicleStatus.DEPARTURE.getCode());
}
vehicleMapper.updateByPrimaryKeySelective(vehicle);
//修改预约记录状态 //修改预约记录状态
VehicleBookRecord vehicleBookRecord = null; VehicleBookRecord vehicleBookRecord = null;
...@@ -211,7 +221,6 @@ public class VehicleActiveService { ...@@ -211,7 +221,6 @@ public class VehicleActiveService {
} }
// 写入车辆公里数,还车分公司id // 写入车辆公里数,还车分公司id
vehicle.setMileageLastUpdate(MileageRest1); vehicle.setMileageLastUpdate(MileageRest1);
vehicleMapper.updateByPrimaryKeySelective(vehicle);
// 出车记录 // 出车记录
VehicleDepartureLogVo departureLogVo = vehicleDepartureLogMapper.selectByBookRecordId(arrivalVo.getBookRecordId()); VehicleDepartureLogVo departureLogVo = vehicleDepartureLogMapper.selectByBookRecordId(arrivalVo.getBookRecordId());
...@@ -230,13 +239,13 @@ public class VehicleActiveService { ...@@ -230,13 +239,13 @@ public class VehicleActiveService {
} }
} }
if (flag) { //如果此条记录后面还有未收车记录,就不修改车辆状态 if (flag) { //如果此条记录后面还有未收车记录,就不修改车辆状态
int result = vehicleMapper.updateStatus(arrivalVo.getVehicleId(), VehicleStatus.NORMAL.getCode()); vehicle.setStatus(VehicleStatus.NORMAL.getCode());
// if (result == 0) { // if (result == 0) {
// throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getDesc(), // throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getDesc(),
// ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getCode()); // ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getCode());
// } // }
} }
vehicleMapper.updateByPrimaryKeySelective(vehicle);
DateTime arrivalDate = new DateTime(vehicleBookRecord.getBookEndDate()); DateTime arrivalDate = new DateTime(vehicleBookRecord.getBookEndDate());
DateTime actualArrivalDate = new DateTime(new Date()); DateTime actualArrivalDate = new DateTime(new Date());
//提前还车处理 //提前还车处理
...@@ -256,7 +265,7 @@ public class VehicleActiveService { ...@@ -256,7 +265,7 @@ public class VehicleActiveService {
throw new BaseException(ResCode.VEHICLE_UNBOOK_FAIL.getDesc(), ResCode.VEHICLE_UNBOOK_FAIL.getCode()); throw new BaseException(ResCode.VEHICLE_UNBOOK_FAIL.getDesc(), ResCode.VEHICLE_UNBOOK_FAIL.getCode());
} }
} catch (Exception e) { } catch (Exception e) {
log.info("提前还车失败,bookVehicleVo = {}", bookVehicleVo.toString()); log.error("提前还车失败,bookVehicleVo = {}", bookVehicleVo.toString());
e.printStackTrace(); e.printStackTrace();
} }
} else if (actualArrivalDate.compareTo(arrivalDate) > 0) {//实际还车时间大于预计还车时间 } else if (actualArrivalDate.compareTo(arrivalDate) > 0) {//实际还车时间大于预计还车时间
...@@ -336,6 +345,7 @@ public class VehicleActiveService { ...@@ -336,6 +345,7 @@ public class VehicleActiveService {
} }
} }
if (!(startDate.minusDays(1).compareTo(DateTime.now()) <= 0 && DateTime.now().compareTo(endDate) <= 0 && vehicleBookRecord.getStatus() == VehicleBookRecordStatus.APPROVE.getCode() && (list == null || list.size() <= 0))) { if (!(startDate.minusDays(1).compareTo(DateTime.now()) <= 0 && DateTime.now().compareTo(endDate) <= 0 && vehicleBookRecord.getStatus() == VehicleBookRecordStatus.APPROVE.getCode() && (list == null || list.size() <= 0))) {
log.error("出车过滤,有正常未还车记录,请按照预定的日期出车");
throw new BaseException(ResCode.VEHICLE_DEPARTURE_DATE_IS_NOT_ABLED.getDesc(), throw new BaseException(ResCode.VEHICLE_DEPARTURE_DATE_IS_NOT_ABLED.getDesc(),
ResCode.VEHICLE_DEPARTURE_DATE_IS_NOT_ABLED.getCode()); ResCode.VEHICLE_DEPARTURE_DATE_IS_NOT_ABLED.getCode());
} }
......
...@@ -83,6 +83,9 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic ...@@ -83,6 +83,9 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
@Autowired @Autowired
VehicleActiveService vehicleActiveService; VehicleActiveService vehicleActiveService;
@Autowired
VehicleBiz vehicleBiz;
@Override @Override
public UserFeign getUserFeign() { public UserFeign getUserFeign() {
return userFeign; return userFeign;
...@@ -252,6 +255,15 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic ...@@ -252,6 +255,15 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
if(a <= 0) { if(a <= 0) {
return ObjectRestResponse.createDefaultFail(); return ObjectRestResponse.createDefaultFail();
} }
//出行中才修改车辆停靠分公司
VehicleDepartureLogVo vehicleDepartureLogVo = vehicleDepartureService.getByRecordId(vehicleBookRecord.getId());
if (vehicleDepartureLogVo != null && vehicleDepartureLogVo.getState() == 0) {
Vehicle vehicle = vehicleBiz.selectById(vehicleBookRecord.getVehicleId());
if (vehicle != null) {
vehicle.setParkBranchCompanyId(vehicleBookRecord.getRetCompany());
vehicleBiz.updateSelectiveByIdRe(vehicle);
}
}
return bookRecordUpdateLogBiz.save(bookRecordUpdateLog); return bookRecordUpdateLogBiz.save(bookRecordUpdateLog);
} else { } else {
return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getCode(), ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getDesc()); return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getCode(), ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getDesc());
......
...@@ -2,6 +2,7 @@ package com.xxfc.platform.vehicle.biz; ...@@ -2,6 +2,7 @@ package com.xxfc.platform.vehicle.biz;
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;
import com.google.common.collect.Lists;
import com.xxfc.platform.vehicle.entity.Festival; import com.xxfc.platform.vehicle.entity.Festival;
import com.xxfc.platform.vehicle.entity.VehicleModelHolidayPrice; import com.xxfc.platform.vehicle.entity.VehicleModelHolidayPrice;
import com.xxfc.platform.vehicle.mapper.VehicleModelHolidayPriceMapper; import com.xxfc.platform.vehicle.mapper.VehicleModelHolidayPriceMapper;
...@@ -161,6 +162,17 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric ...@@ -161,6 +162,17 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric
} }
List<Integer> festivalIds = modelHolidayPrices.stream().map(VehicleModelHolidayPrice::getFestivalId).collect(Collectors.toList()); List<Integer> festivalIds = modelHolidayPrices.stream().map(VehicleModelHolidayPrice::getFestivalId).collect(Collectors.toList());
Map<Integer,Festival> festivalMap = festivalBiz.findFestivalsByIds(festivalIds); Map<Integer,Festival> festivalMap = festivalBiz.findFestivalsByIds(festivalIds);
Map<Date, List<VehicleModelHolidayPrice>> dateListMap = modelHolidayPrices.stream().collect(Collectors.groupingBy(VehicleModelHolidayPrice::getFestivalDay, Collectors.toList()));
modelHolidayPrices = dateListMap.values().stream().map(x->{
if (x.size()>1){
Optional<VehicleModelHolidayPrice> holidayPrice = x.stream().sorted(Comparator.comparing(VehicleModelHolidayPrice::getMultiple).reversed()).findFirst();
return Lists.newArrayList(holidayPrice.get());
}else {
return x;
}
}).flatMap(List::stream).collect(Collectors.toList());
VehicleModelHolidayPriceDTO vehicleModelHolidayPriceDTO; VehicleModelHolidayPriceDTO vehicleModelHolidayPriceDTO;
for (VehicleModelHolidayPrice modelHolidayPrice : modelHolidayPrices) { for (VehicleModelHolidayPrice modelHolidayPrice : modelHolidayPrices) {
vehicleModelHolidayPriceDTO = new VehicleModelHolidayPriceDTO(); vehicleModelHolidayPriceDTO = new VehicleModelHolidayPriceDTO();
......
...@@ -78,6 +78,9 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use ...@@ -78,6 +78,9 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use
@Autowired @Autowired
BookRecordUpdateLogBiz bookRecordUpdateLogBiz; BookRecordUpdateLogBiz bookRecordUpdateLogBiz;
@Autowired
VehicleDepartureService vehicleDepartureService;
public UserFeign getUserFeign() { public UserFeign getUserFeign() {
return userFeign; return userFeign;
...@@ -335,6 +338,14 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use ...@@ -335,6 +338,14 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use
bookRecordUpdateLog.setOperaterId(userDTO.getId()); bookRecordUpdateLog.setOperaterId(userDTO.getId());
bookRecordUpdateLog.setOperaterName(userDTO.getName()); bookRecordUpdateLog.setOperaterName(userDTO.getName());
bookRecordUpdateLog.setCreateTime(new Date()); bookRecordUpdateLog.setCreateTime(new Date());
VehicleDepartureLogVo vehicleDepartureLogVo = vehicleDepartureService.getByRecordId(oldValue.getId());
if (vehicleDepartureLogVo != null && vehicleDepartureLogVo.getState() == 0) {
Vehicle vehicle = vehicleBiz.selectById(oldValue.getVehicleId());
if (vehicle != null) {
vehicle.setParkBranchCompanyId(oldValue.getRetCompany());
vehicleBiz.updateSelectiveByIdRe(vehicle);
}
}
vehicleBookRecordBiz.updateSelectiveByIdRe(vehicleBookRecord); vehicleBookRecordBiz.updateSelectiveByIdRe(vehicleBookRecord);
return bookRecordUpdateLogBiz.save(bookRecordUpdateLog); return bookRecordUpdateLogBiz.save(bookRecordUpdateLog);
} else { } else {
......
...@@ -16,8 +16,9 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -16,8 +16,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.time.LocalDate; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -47,8 +48,8 @@ public class VehicleModelCalendarPriceController { ...@@ -47,8 +48,8 @@ public class VehicleModelCalendarPriceController {
if (StringUtils.isEmpty(start) || StringUtils.isEmpty(end)) { if (StringUtils.isEmpty(start) || StringUtils.isEmpty(end)) {
throw new BaseException("缺少开始时间或结束时间"); throw new BaseException("缺少开始时间或结束时间");
} }
Date startDate = Date.from(LocalDate.parse(start).atStartOfDay(ZoneId.systemDefault()).toInstant()); Date startDate = Date.from(LocalDateTime.parse(start, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")).toInstant(ZoneOffset.ofHours(8)));
Date endDate = Date.from(LocalDate.parse(end).atStartOfDay(ZoneId.systemDefault()).toInstant()); Date endDate = Date.from(LocalDateTime.parse(end,DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")).toInstant(ZoneOffset.ofHours(8)));
List<VehicleModelCalendarPriceDTO> vehicleModelCalendarPriceVos = vehicleModelCalendarPriceBiz.listVehicleModelCalendarPriceByDateAndVehicleModelIdAndUserId(startDate, endDate, vehicleModelId, appUserDTO.getUserid()); List<VehicleModelCalendarPriceDTO> vehicleModelCalendarPriceVos = vehicleModelCalendarPriceBiz.listVehicleModelCalendarPriceByDateAndVehicleModelIdAndUserId(startDate, endDate, vehicleModelId, appUserDTO.getUserid());
return ObjectRestResponse.succ(vehicleModelCalendarPriceVos); return ObjectRestResponse.succ(vehicleModelCalendarPriceVos);
} }
...@@ -60,9 +61,7 @@ public class VehicleModelCalendarPriceController { ...@@ -60,9 +61,7 @@ public class VehicleModelCalendarPriceController {
@RequestParam(value = "userId") Integer userId) { @RequestParam(value = "userId") Integer userId) {
Date startDateDay = DateUtil.beginOfDay(DateUtil.date(startDate)); Date startDateDay = DateUtil.beginOfDay(DateUtil.date(startDate));
//Date.from(startDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
Date endDateDay = DateUtil.beginOfDay(DateUtil.date(endDate)); Date endDateDay = DateUtil.beginOfDay(DateUtil.date(endDate));
//Date.from(endDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
return ObjectRestResponse.succ(vehicleModelCalendarPriceBiz.findVehicleModelCalendarPriceByDateAndVehilceIdAndUserId(startDateDay, endDateDay, vehicleModelId, userId)); return ObjectRestResponse.succ(vehicleModelCalendarPriceBiz.findVehicleModelCalendarPriceByDateAndVehilceIdAndUserId(startDateDay, endDateDay, vehicleModelId, userId));
} }
...@@ -72,8 +71,8 @@ public class VehicleModelCalendarPriceController { ...@@ -72,8 +71,8 @@ public class VehicleModelCalendarPriceController {
@RequestParam(value = "vehicleModelId") Integer vehicleModelId, @RequestParam(value = "vehicleModelId") Integer vehicleModelId,
AppUserDTO appUserDTO) { AppUserDTO appUserDTO) {
Date startDateDay = DateUtil.beginOfDay(DateUtil.date(startDate)); Date startDateDay = new Date(startDate);
Date endDateDay = DateUtil.beginOfDay(DateUtil.date(endDate)); Date endDateDay = new Date(endDate);
return ObjectRestResponse.succ(vehicleModelCalendarPriceBiz.findVehicleModelCalendarPriceByDateAndVehilceIdAndUserId(startDateDay, endDateDay, vehicleModelId, appUserDTO.getUserid())); return ObjectRestResponse.succ(vehicleModelCalendarPriceBiz.findVehicleModelCalendarPriceByDateAndVehilceIdAndUserId(startDateDay, endDateDay, vehicleModelId, appUserDTO.getUserid()));
} }
......
...@@ -18,6 +18,7 @@ import com.xxfc.platform.vehicle.biz.VehicleCataBiz; ...@@ -18,6 +18,7 @@ import com.xxfc.platform.vehicle.biz.VehicleCataBiz;
import com.xxfc.platform.vehicle.biz.VehicleModelBiz; import com.xxfc.platform.vehicle.biz.VehicleModelBiz;
import com.xxfc.platform.vehicle.biz.VehiclePlatCataBiz; import com.xxfc.platform.vehicle.biz.VehiclePlatCataBiz;
import com.xxfc.platform.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.entity.VehicleCata; import com.xxfc.platform.vehicle.entity.VehicleCata;
import com.xxfc.platform.vehicle.entity.VehicleModel; import com.xxfc.platform.vehicle.entity.VehicleModel;
import com.xxfc.platform.vehicle.pojo.VModelDetailVO; import com.xxfc.platform.vehicle.pojo.VModelDetailVO;
...@@ -292,7 +293,20 @@ public class VehicleModelController extends BaseController<VehicleModelBiz, Vehi ...@@ -292,7 +293,20 @@ public class VehicleModelController extends BaseController<VehicleModelBiz, Vehi
} }
} }
@ApiOperation("是否在App展示")
@PostMapping(value = "/bg/updateAppShow")
public ObjectRestResponse<VehicleModel> updateAppShow(@RequestBody VehicleModel vehicleModel) {
if (vehicleModel == null || vehicleModel.getId() == null) {
return ObjectRestResponse.paramIsEmpty();
}
VehicleModel oldValue = vehicleModelBiz.selectById(vehicleModel.getId());
if (oldValue == null) {
return ObjectRestResponse.createFailedResult(ResCode.FIND_DATA_NOT_EXIST.getCode(), ResCode.FIND_DATA_NOT_EXIST.getDesc());
}
oldValue.setAppShow(vehicleModel.getAppShow());
vehicleModelBiz.updateByPrimaryKeySelective(oldValue);
return ObjectRestResponse.succ();
}
@ApiOperation("删除") @ApiOperation("删除")
@DeleteMapping(value = "/app/{id}") @DeleteMapping(value = "/app/{id}")
......
...@@ -487,7 +487,7 @@ ...@@ -487,7 +487,7 @@
and (v3.number_plate like concat('%', #{keywords}, '%') or v3.code like concat('%', #{keywords}, '%')) and (v3.number_plate like concat('%', #{keywords}, '%') or v3.code like concat('%', #{keywords}, '%'))
</if> </if>
<if test="zoneId != null"> <if test="zoneId != null">
and bc3.zone_id = #{zoneId} and bc1.zone_id = #{zoneId}
</if> </if>
<if test="companyIds != null and companyIds.size > 0"> <if test="companyIds != null and companyIds.size > 0">
and (v1.lift_company in and (v1.lift_company in
......
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