Commit a9af589c authored by hanfeng's avatar hanfeng

修改租车订单

parent f8255d8b
......@@ -4,6 +4,7 @@ import com.github.wxiaoqi.security.admin.dto.UserInfoDTO;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.activity.dto.ActivityListDTO;
import com.xxfc.platform.activity.dto.ActivityPopularizeRelationDTO;
import com.xxfc.platform.activity.entity.Coupon;
import com.xxfc.platform.activity.entity.IntegralUserTotal;
import com.xxfc.platform.activity.vo.UserCouponVo;
import io.swagger.annotations.ApiModelProperty;
......@@ -12,7 +13,9 @@ import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
......@@ -73,4 +76,9 @@ public interface ActivityFeign {
@ApiOperation("查询活动的时间")
@GetMapping("/activityList/time/{activityId}")
ActivityListDTO findActivityStartTimeAndEndTimeById(@PathVariable(value = "activityId") Integer activityId);
@ApiOperation("获取所用优惠卷")
@GetMapping("/coupon/coupons")
Map<Integer, Coupon> coupons();
}
......@@ -2,6 +2,8 @@ package com.xxfc.platform.activity.biz;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.xxfc.platform.activity.constant.CouponUsed;
import com.xxfc.platform.activity.dto.CouponDTO;
import com.xxfc.platform.activity.dto.CouponFindDTO;
......@@ -17,10 +19,9 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.*;
/**
* 优惠券表
......@@ -122,4 +123,9 @@ public class CouponBiz extends BaseBiz<CouponMapper, Coupon> {
public List<CouponTitleVo> getCouponTitleList() {
return mapper.selectTitles();
}
public Map<Integer, Coupon> getCoupons() {
Map<Integer, Coupon> coupons = mapper.getCoupons();
return coupons ;
}
}
\ No newline at end of file
......@@ -4,7 +4,9 @@ import com.xxfc.platform.activity.entity.Coupon;
import com.xxfc.platform.activity.vo.CouponTitleVo;
import tk.mybatis.mapper.common.Mapper;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
* 优惠券表
......@@ -16,4 +18,8 @@ import java.util.List;
public interface CouponMapper extends Mapper<Coupon> {
List<CouponTitleVo> selectTitles();
Map<Integer, Coupon> getCoupons();
}
......@@ -3,13 +3,22 @@ package com.xxfc.platform.activity.rest;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.xxfc.platform.activity.biz.CouponBiz;
import com.xxfc.platform.activity.entity.Coupon;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("coupon")
public class CouponController extends BaseController<CouponBiz, Coupon> {
@ApiOperation("获取所用优惠卷")
@RequestMapping("/coupons")
public Map<Integer, Coupon> coupons() {
return baseBiz.getCoupons();
}
}
\ No newline at end of file
......@@ -40,4 +40,10 @@
<select id="selectTitles" resultType="com.xxfc.platform.activity.vo.CouponTitleVo">
select `id`,`title` from `coupon` where `is_del`=0
</select>
<select id="getCoupons" resultType="com.xxfc.platform.activity.entity.Coupon" >
select id ,title,used_amount from coupon
</select>
</mapper>
\ No newline at end of file
......@@ -293,4 +293,19 @@ public class BaseOrder implements Serializable {
@ApiModelProperty(value = "促成人联系方式")
@Column(name = "facilitate_phone")
String facilitatePhone;
/**
* 1:微信公众号支付 2.支付宝即时到账,3,银联
*/
@ApiModelProperty(value = "1:微信公众号支付 2.支付宝即时到账,3,银联")
@Column(name = "pay_way")
private Integer payWay;
/**
* 备注
*/
@ApiModelProperty(value = "备注")
@Column(name = "remark")
private Integer remark;
}
package com.xxfc.platform.order.pojo.order;
import com.xxfc.platform.activity.entity.Coupon;
import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.pojo.OrderAccompanyDTO;
import com.xxfc.platform.vehicle.entity.VehicleUserLicense;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@Data
......@@ -52,5 +55,13 @@ public class OrderListVo extends BaseOrder {
@ApiModelProperty(value = "用户会员名称")
private String memberName;
@ApiModelProperty(value = "随车物品")
private String carArticlesJson;
@ApiModelProperty(value = "使用优惠卷")
ArrayList<Coupon> couponList ;
@ApiModelProperty(value = "退还优惠卷")
ArrayList<Coupon> backCouponList;
}
......@@ -3,7 +3,7 @@ package com.xxfc.platform.order.rest;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.druid.sql.visitor.functions.If;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.entity.AppUserLogin;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
......@@ -18,6 +18,9 @@ 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.github.wxiaoqi.security.common.vo.PageDataVO;
import com.google.common.collect.Lists;
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.OrderItemBiz;
import com.xxfc.platform.order.biz.OrderRentVehicleBiz;
......@@ -42,11 +45,13 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.mockito.internal.util.collections.Sets;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import java.time.Instant;
......@@ -83,12 +88,16 @@ public class BackStageOrderController extends CommonBaseController implements Us
@Autowired
UserFeign userFeign;
@Autowired
ActivityFeign activityFeign;
@Autowired
TourFeign tourFeign;
@Resource
VehicleFeign vehicleFeign;
@Override
public UserFeign getUserFeign() {
return userFeign;
......@@ -105,12 +114,12 @@ public class BackStageOrderController extends CommonBaseController implements Us
dto.setEndTime(new Date().getTime());
}
}
if (StringUtils.isNotBlank(dto.getPhone())||StringUtils.isNotBlank(dto.getRealName())) {
List<AppUserLogin> appUserLoins = userFeign.getOne(dto.getPhone(),dto.getRealName());
if (StringUtils.isNotBlank(dto.getPhone()) || StringUtils.isNotBlank(dto.getRealName())) {
List<AppUserLogin> appUserLoins = userFeign.getOne(dto.getPhone(), dto.getRealName());
if (CollectionUtil.isNotEmpty(appUserLoins)) {
List<Integer> collect = appUserLoins.parallelStream().map(AppUserLogin::getId).collect(Collectors.toList());
dto.setUserIds(collect);
}else {
} else {
return ObjectRestResponse.succ(new PageDataVO<>());
}
}
......@@ -120,34 +129,35 @@ public class BackStageOrderController extends CommonBaseController implements Us
if (userDTO == null) {
return ObjectRestResponse.succ(new PageDataVO<>());
}
if(dto.getType() != null && dto.getType() != 3) {
if (dto.getType() != null && dto.getType() != 3) {
List<BranchCompany> branchCompanies = vehicleFeign.companyAll(userDTO.getDataAll(), userDTO.getDataCompany(), userDTO.getDataZone());
List<Integer> companyIds = branchCompanies.stream().map(BranchCompany::getId).collect(Collectors.toList());
dto.setCompanyIds(companyIds);
}
if (dto.getZoneId()!=null){
if (userDTO.getDataAll()!=1&&!dto.getZoneId().equals(userDTO.getZoneId())) {
if (dto.getZoneId() != null) {
if (userDTO.getDataAll() != 1 && !dto.getZoneId().equals(userDTO.getZoneId())) {
return ObjectRestResponse.succ(new PageDataVO<>());
}else {
} else {
ArrayList<Integer> zoneIds = new ArrayList<>();
zoneIds.add(dto.getZoneId());
dto.setZoneIds(zoneIds);
}
}
if (dto.getStartCompanyId()!=null){
if (userDTO.getDataAll()!=1&&!dto.getStartCompanyId().equals(userDTO.getId())) {
if (dto.getStartCompanyId() != null) {
if (userDTO.getDataAll() != 1 && !dto.getStartCompanyId().equals(userDTO.getId())) {
return ObjectRestResponse.succ(new PageDataVO<>());
}else {
} else {
ArrayList<Integer> companyIds = new ArrayList<>();
companyIds.add(dto.getStartCompanyId());
dto.setCompanyIds(companyIds);
}
}
if (StringUtils.isNotEmpty(dto.getPlateNumber())||StringUtils.isNotEmpty(dto.getVehicleCode())){
List<String> vehicleIds = vehicleFeign.findbyPlateNumberAndVehicleCod(dto.getPlateNumber(),dto.getVehicleCode());
if (StringUtils.isNotEmpty(dto.getPlateNumber()) || StringUtils.isNotEmpty(dto.getVehicleCode())) {
List<String> vehicleIds = vehicleFeign.findbyPlateNumberAndVehicleCod(dto.getPlateNumber(), dto.getVehicleCode());
dto.setVehicleIds(vehicleIds);
}
Query query = new Query(dto);
......@@ -158,23 +168,50 @@ public class BackStageOrderController extends CommonBaseController implements Us
ObjectRestResponse<List<AppUserVo>> objectRestResponse = userFeign.getByUserIds(userIds);
log.info("获取用户信息:objectRestResponse = {}", objectRestResponse.getData());
Map<Integer, AppUserVo> appvoMap = new HashMap<Integer, AppUserVo>();
if(objectRestResponse.getData() != null) {
for(AppUserVo appUserVo : objectRestResponse.getData()) {
if(appUserVo != null) {
if (objectRestResponse.getData() != null) {
for (AppUserVo appUserVo : objectRestResponse.getData()) {
if (appUserVo != null) {
appvoMap.put(appUserVo.getUserid(), appUserVo);
}
}
}
Map<Integer, Coupon> coupons = activityFeign.coupons();
for (OrderListVo orderPageVO : list) {
AppUserVo appUserVo = appvoMap.get(orderPageVO.getUserId());
if(appUserVo != null) {
if (appUserVo != null) {
orderPageVO.setTelephone(appUserVo.getUsername());
orderPageVO.setUsername(appUserVo.getNickname());
orderPageVO.setRealName(appUserVo.getRealname());
orderPageVO.setJobTitle(appUserVo.getJobTitle());
orderPageVO.setMemberName(appUserVo.getMemberName());
}
ArrayList<Coupon> couponList = Lists.newArrayList();
ArrayList<Coupon> backCouponList = Lists.newArrayList();
if (StringUtils.isNotBlank(orderPageVO.getCouponTickerNos())) {
String[] couponIds = orderPageVO.getCouponTickerNos().split(",");
for (String couponId : couponIds) {
couponList.add(coupons.get(couponId));
}
}
if (StringUtils.isNotBlank(orderPageVO.getBackCoupon())) {
String[] backCouponIds = orderPageVO.getBackCoupon().split(",");
for (String backCouponId : backCouponIds) {
backCouponList.add(coupons.get(backCouponId));
}
}
orderPageVO.setCouponList(couponList);
orderPageVO.setBackCouponList(backCouponList);
// String carArticlesJson = orderPageVO.getCarArticlesJson();
// if (StringUtils.isNotBlank(carArticlesJson)){
// List<OrderAccompanyDTO> orderAccompanyDTOS = JSONObject.parseArray(carArticlesJson, OrderAccompanyDTO.class);
// orderPageVO.setOrderAccompanyDTOS(orderAccompanyDTOS);
// if (CollectionUtils.isNotEmpty(orderAccompanyDTOS)) {
// List<String> collect = orderAccompanyDTOS.parallelStream().map(OrderAccompanyDTO::getName).collect(Collectors.toList());
// orderPageVO.setCarArticles(collect);
// }
// }
if (orderPageVO.getOrderRentVehicleDetail() != null && orderPageVO.getOrderRentVehicleDetail().getVehicleId() != null) {
RestResponse<Vehicle> restResponse = vehicleFeign.findById(orderPageVO.getOrderRentVehicleDetail().getVehicleId());
log.info("获取车辆信息返回消息:{}", restResponse.getData());
......@@ -217,7 +254,7 @@ public class BackStageOrderController extends CommonBaseController implements Us
if (startResponse.getData() != null) {
orderPageVO.setStartCompanyName(startResponse.getData().getName());
}
if(StringUtils.isNotBlank(orderPageVO.getOrderTourDetail().getTourUserIds())) {
if (StringUtils.isNotBlank(orderPageVO.getOrderTourDetail().getTourUserIds())) {
List<TourUser> tourUsers = tourFeign.getTourUsers(orderPageVO.getOrderTourDetail().getTourUserIds()).getData();
orderPageVO.getOrderTourDetail().setUserVoList(tourUsers == null || tourUsers.size() <= 0 ? new ArrayList<>() : tourUsers);
}
......@@ -241,12 +278,12 @@ public class BackStageOrderController extends CommonBaseController implements Us
}
}
List<Integer> userIds = new ArrayList<>();
if(StringUtils.isNotBlank(dto.getKeywords())) {
if (StringUtils.isNotBlank(dto.getKeywords())) {
List<Integer> list = userFeign.getUserIdByUsername(dto.getKeywords());
if(list != null) {
if (list != null) {
userIds.addAll(list);
}
if(userIds.size() <= 0) {
if (userIds.size() <= 0) {
return ObjectRestResponse.succ(new PageDataVO<>());
}
}
......@@ -257,9 +294,9 @@ public class BackStageOrderController extends CommonBaseController implements Us
}
List<BranchCompany> branchCompanies = vehicleFeign.companyAll(userDTO.getDataAll(), userDTO.getDataCompany(), userDTO.getDataZone());
List<Integer> companyIds = branchCompanies.stream().map(BranchCompany::getId).collect(Collectors.toList());
if(dto.getStartCompanyId() != null) {
if(companyIds.size() > 0) {
if(companyIds.contains(dto.getStartCompanyId())) {
if (dto.getStartCompanyId() != null) {
if (companyIds.size() > 0) {
if (companyIds.contains(dto.getStartCompanyId())) {
companyIds.clear();
companyIds.add(dto.getStartCompanyId());
} else {
......@@ -281,9 +318,9 @@ public class BackStageOrderController extends CommonBaseController implements Us
orderPageVO.setCode(restResponse.getData().getCode());
}
}
if(orderPageVO.getUserId() != null) {
if (orderPageVO.getUserId() != null) {
AppUserDTO appUserDTO = userFeign.userDetailById(orderPageVO.getUserId()).getData();
if(appUserDTO != null) {
if (appUserDTO != null) {
orderPageVO.setUsername(appUserDTO.getUsername());
orderPageVO.setRealName(appUserDTO.getRealname());
}
......@@ -355,20 +392,20 @@ public class BackStageOrderController extends CommonBaseController implements Us
query.put("userId", null);
PageDataVO<OrderPageVO> page = PageDataVO.pageInfo(query, () -> baseOrderBiz.pageByParm(query.getSuper()));
OrderPageVO orderPageVO = page.getData().get(0);
if(null == orderPageVO) {
if (null == orderPageVO) {
throw new BaseException(ResultCode.PARAM_ILLEGAL_CODE, Sets.newSet("订单不存在"));
}
//预约新的车辆
RentVehicleBO bo = BeanUtil.toBean(orderPageVO.getOrderRentVehicleDetail(), RentVehicleBO.class);
bo.setOrder(orderPageVO);
bo.setBookVehicleVO(new BookVehicleVO(){{
bo.setBookVehicleVO(new BookVehicleVO() {{
setBookStartDate(YMR_SLASH_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(bo.getStartTime()), ZoneOffset.ofHours(8))));
setBookEndDate(YMR_SLASH_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(bo.getEndTime()), ZoneOffset.ofHours(8))));
setBookStartDateTime(DATE_TIME_LINE_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(bo.getStartTime()), ZoneOffset.ofHours(8))));
setBookEndDateTime(DATE_TIME_LINE_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(bo.getEndTime()), ZoneOffset.ofHours(8))));
}});
List<OrderAccompanyDTO> oads = JSONUtil.toList(JSONUtil.parseArray(orderItemBiz.selectOne(new OrderItem(){{
List<OrderAccompanyDTO> oads = JSONUtil.toList(JSONUtil.parseArray(orderItemBiz.selectOne(new OrderItem() {{
setOrderId(orderPageVO.getId());
setType(ItemTypeEnum.ACCOMPANY.getCode());
}}).getDetail()), OrderAccompanyDTO.class);
......@@ -378,7 +415,7 @@ public class BackStageOrderController extends CommonBaseController implements Us
//如果成功则取消旧车的预约
RestResponse<Integer> rentUnbookResponse = vehicleFeign.rentUnbookVehicle(oldBookRecordId);
//设置新的vehicleId 和 record
orderRentVehicleBiz.updateSelectiveByIdRe(new OrderRentVehicleDetail(){{
orderRentVehicleBiz.updateSelectiveByIdRe(new OrderRentVehicleDetail() {{
setId(bo.getId());
setVehicleId(bo.getVehicleId());
setBookRecordId(bo.getBookRecordId());
......
......@@ -114,12 +114,14 @@
</select>
<select id="listOrder" parameterType="Map" resultMap="orderListMap">
select b.*
select b.*,i.detail as carArticlesJson
from base_order b
LEFT JOIN order_rent_vehicle_detail r on r.order_id = b.id
LEFT JOIN order_tour_detail t on t.order_id = b.id
LEFT JOIN order_member_detail m on m.order_id = b.id
LEFT JOIN order_item i on b.id = i.order_id
<where>
i.type=104
<if test="crtUser != null">
and b.crt_user = #{crtUser}
</if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment