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