Commit 9bd49717 authored by hezhen's avatar hezhen

Merge branch 'hz_dev' into base-modify

parents 42adbcae a4b9c0f5
...@@ -15,6 +15,8 @@ import lombok.RequiredArgsConstructor; ...@@ -15,6 +15,8 @@ import lombok.RequiredArgsConstructor;
import org.apache.commons.collections.CollectionUtils; 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.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
...@@ -68,13 +70,12 @@ public class CustomerServiceBiz { ...@@ -68,13 +70,12 @@ public class CustomerServiceBiz {
CustomerService customerService = new CustomerService(); CustomerService customerService = new CustomerService();
BeanUtils.copyProperties(customerServiceDTO,customerService); BeanUtils.copyProperties(customerServiceDTO,customerService);
customerService.setCreateTime(Instant.now().toEpochMilli()); customerService.setCreateTime(Instant.now().toEpochMilli());
String password = new BCryptPasswordEncoder(UserConstant.PW_ENCORDER_SALT).encode(INIT_PASSWORD);
customerService.setName(String.format("%s%s",NICK_PRE_NAME,customerServiceDTO.getTelphone())); customerService.setName(String.format("%s%s",NICK_PRE_NAME,customerServiceDTO.getTelphone()));
customerService.setIsDel(false); customerService.setIsDel(false);
Map<String,Object> imMap = new HashMap<>(2); Map<String,Object> imMap = new HashMap<>(2);
imMap.put("telephone",customerServiceDTO.getTelphone()); imMap.put("telephone",customerServiceDTO.getTelphone());
imMap.put("password",password); imMap.put("password",INIT_PASSWORD);
imMap.put("nickname",customerService.getName()); imMap.put("nickname",customerService.getName());
BaseResponse imResponse = userBiz.register(imMap); BaseResponse imResponse = userBiz.register(imMap);
String imResult = imResponse.getMessage(); String imResult = imResponse.getMessage();
...@@ -88,10 +89,19 @@ public class CustomerServiceBiz { ...@@ -88,10 +89,19 @@ public class CustomerServiceBiz {
customerServiceRepository.save(customerService); customerServiceRepository.save(customerService);
} }
/**
* 1: mongoTemplate.find(Query.query(Criteria.where("isDel").is(false)), CustomerService.class);
*
* 2. customerServiceRepository.findByIsDelEquals(false);
* @return
*/
public List<CustomerServiceVO> findAll() { public List<CustomerServiceVO> findAll() {
List<CustomerServiceVO> customerServiceVOS = new ArrayList<>(); List<CustomerServiceVO> customerServiceVOS = new ArrayList<>();
// List<CustomerService> customerServices = mongoTemplate.find(Query.query(Criteria.where("isDel").is(false)), CustomerService.class);
List<CustomerService> customerServices = customerServiceRepository.findByIsDelEquals(false); CustomerService customer_service = new CustomerService();
Example<CustomerService> customerServiceExample = Example.of(customer_service, ExampleMatcher.matchingAll());
List<CustomerService> customerServices = customerServiceRepository.findAll(customerServiceExample);
CustomerServiceVO customerServiceVO; CustomerServiceVO customerServiceVO;
if (CollectionUtils.isNotEmpty(customerServices)){ if (CollectionUtils.isNotEmpty(customerServices)){
List<Integer> imUserIds = customerServices.stream().map(CustomerService::getImUserId).collect(Collectors.toList()); List<Integer> imUserIds = customerServices.stream().map(CustomerService::getImUserId).collect(Collectors.toList());
...@@ -117,7 +127,7 @@ public class CustomerServiceBiz { ...@@ -117,7 +127,7 @@ public class CustomerServiceBiz {
public void updateCustomerServiceIsDelToTrue(String id,Integer imUserId){ public void updateCustomerServiceIsDelToTrue(String id,Integer imUserId){
Query query = query(Criteria.where("_id").is(id)); Query query = query(Criteria.where("_id").is(id));
Update update = update("is_del", true).set("update_time",Instant.now().toEpochMilli()); Update update = update("is_del", true).set("update_time",Instant.now().toEpochMilli());
UpdateResult customer_service = mongoTemplate.updateFirst(query, update, Map.class, "customer_service"); mongoTemplate.updateFirst(query, update, Map.class, "customer_service");
userBiz.deleteById(imUserId); userBiz.deleteById(imUserId);
} }
} }
...@@ -8,8 +8,10 @@ import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO; ...@@ -8,8 +8,10 @@ import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.admin.vo.ImiVo; import com.github.wxiaoqi.security.admin.vo.ImiVo;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
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.xxfc.platform.im.dto.CommentVo; import com.xxfc.platform.im.dto.CommentVo;
import com.xxfc.platform.im.dto.PraiseVo; import com.xxfc.platform.im.dto.PraiseVo;
import com.xxfc.platform.im.dto.QuestionParamDto;
import com.xxfc.platform.im.model.Comment; import com.xxfc.platform.im.model.Comment;
import com.xxfc.platform.im.model.Msg; import com.xxfc.platform.im.model.Msg;
import com.xxfc.platform.im.model.Praise; import com.xxfc.platform.im.model.Praise;
...@@ -38,6 +40,9 @@ public class MsgBiz { ...@@ -38,6 +40,9 @@ public class MsgBiz {
@Autowired @Autowired
UserBiz userBiz; UserBiz userBiz;
@Autowired
ImQuestionBiz imQuestionBiz;
/** /**
* 获取消息列表 * 获取消息列表
* *
...@@ -123,7 +128,7 @@ public class MsgBiz { ...@@ -123,7 +128,7 @@ public class MsgBiz {
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
public ObjectRestResponse getMsgListByUserId(Integer page, Integer limit) { public ObjectRestResponse getMsgListByUserId(Integer page, Integer limit, Integer type) {
//获取所有朋友圈 //获取所有朋友圈
page = page == null ? 1 : page; page = page == null ? 1 : page;
limit = limit == null ? 10 : limit; limit = limit == null ? 10 : limit;
...@@ -136,8 +141,14 @@ public class MsgBiz { ...@@ -136,8 +141,14 @@ public class MsgBiz {
} }
Pageable pageable = PageRequest.of(--page, limit); Pageable pageable = PageRequest.of(--page, limit);
List<Integer> ids = new ArrayList<>(); List<Integer> ids = new ArrayList<>();
ids.add(2); if(type != null) {
ids.add(4); ids.add(type);
}
if(type != null && type == 5) {
QuestionParamDto questionParamDto = new QuestionParamDto();
questionParamDto.setUserId(Long.parseLong(userId + ""));
return imQuestionBiz.getList(questionParamDto);
}
Query query = new Query(Criteria.where("body.type").in(ids)); Query query = new Query(Criteria.where("body.type").in(ids));
query.addCriteria(Criteria.where("userId").is(userId)); query.addCriteria(Criteria.where("userId").is(userId));
int totalSize = mongoTemplate.find(query, Msg.class, "s_msg").size(); int totalSize = mongoTemplate.find(query, Msg.class, "s_msg").size();
...@@ -147,7 +158,7 @@ public class MsgBiz { ...@@ -147,7 +158,7 @@ public class MsgBiz {
List<MsgVo> msgVoList = replaceMsgResult(msgList); List<MsgVo> msgVoList = replaceMsgResult(msgList);
PageInfo<MsgVo> goodPageInfo = new PageInfo<>(msgVoList); PageInfo<MsgVo> goodPageInfo = new PageInfo<>(msgVoList);
goodPageInfo.setPageSize(totalSize%limit == 0 ?totalSize/limit : totalSize/limit + 1); goodPageInfo.setPageSize(totalSize%limit == 0 ?totalSize/limit : totalSize/limit + 1);
return ObjectRestResponse.succ(goodPageInfo); return ObjectRestResponse.succ(PageDataVO.pageInfo(goodPageInfo));
} }
...@@ -246,7 +257,7 @@ public class MsgBiz { ...@@ -246,7 +257,7 @@ public class MsgBiz {
return praiseVoArrayList; return praiseVoArrayList;
} }
public List<CommentVo> replaceCommentResult(List<Comment> list) { public List<CommentVo> replaceCommentResult(List<Comment> list) {
List<CommentVo> commentVoList = new ArrayList<>(); List<CommentVo> commentVoList = new ArrayList<>();
for(Comment comment : list) { for(Comment comment : list) {
CommentVo commentVo = new CommentVo(); CommentVo commentVo = new CommentVo();
......
...@@ -257,7 +257,6 @@ public class UserBiz { ...@@ -257,7 +257,6 @@ public class UserBiz {
*/ */
public void updatePasswordByPhone(String telphone,String password){ public void updatePasswordByPhone(String telphone,String password){
Query query = Query.query(Criteria.where("phone").is(telphone)); Query query = Query.query(Criteria.where("phone").is(telphone));
password = new BCryptPasswordEncoder(UserConstant.PW_ENCORDER_SALT).encode(password);
Update update = Update.update("password", password); Update update = Update.update("password", password);
mongoTemplate.updateFirst(query,update,Map.class,"user"); mongoTemplate.updateFirst(query,update,Map.class,"user");
} }
......
package com.xxfc.platform.im.repos; package com.xxfc.platform.im.repos;
import com.xxfc.platform.im.model.CustomerService; import com.xxfc.platform.im.model.CustomerService;
import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository; import org.springframework.data.mongodb.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
/** /**
* @author libin * @author libin
...@@ -17,10 +19,13 @@ public interface CustomerServiceRepository extends MongoRepository<CustomerServi ...@@ -17,10 +19,13 @@ public interface CustomerServiceRepository extends MongoRepository<CustomerServi
/** /**
* 查询客服 * 查询客服
* @param isDel 删除状态 * * @param isDel 删除状态
* @return * @return
*/ */
List<CustomerService> findByIsDelEquals(Boolean isDel); List<CustomerService> findByIsDelEquals(Boolean isDel);
List<CustomerService> findByIsDel(Boolean isDel);
// @Query(value = "{'is_del':?0}",fields ="{'telphone':1}",sort = "{'create_time':-1}")
@Query(value = "{'is_del':?#{[0]}}",fields ="{'name':1}",sort = "{'create_time':-1}")
List<CustomerService> findByIsDelState(Boolean isDel);
} }
...@@ -32,7 +32,7 @@ public class MsgController { ...@@ -32,7 +32,7 @@ public class MsgController {
} }
@GetMapping(value = "/getByUserId") @GetMapping(value = "/getByUserId")
public ObjectRestResponse getByUserId(Integer page, Integer limit) { public ObjectRestResponse getByUserId(Integer page, Integer limit, Integer type) {
return msgBiz.getMsgListByUserId(page, limit); return msgBiz.getMsgListByUserId(page, limit, type);
} }
} }
...@@ -8,7 +8,7 @@ import java.util.List; ...@@ -8,7 +8,7 @@ import java.util.List;
@Data @Data
public class DedDetailDTO { public class DedDetailDTO {
/** /**
* : 扣除项 * : 扣除项名称
*/ */
String deductions; String deductions;
...@@ -34,4 +34,6 @@ public class DedDetailDTO { ...@@ -34,4 +34,6 @@ public class DedDetailDTO {
//type对应的中文 //type对应的中文
String statusName; String statusName;
} }
...@@ -145,7 +145,7 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper,OrderRefund> { ...@@ -145,7 +145,7 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper,OrderRefund> {
* @param timeLag 与开始时间的时间差 * @param timeLag 与开始时间的时间差
* @param dicParentKey * @param dicParentKey
*/ */
public void rentRefundProcess(BaseOrder baseOrder, Long timeLag, String dicParentKey) { public BigDecimal rentRefundProcess(BaseOrder baseOrder, Long timeLag, String dicParentKey) {
//计算退款金额 //计算退款金额
//商品价格 - 优惠券减免的价格 //商品价格 - 优惠券减免的价格
BigDecimal originalRefundAmount = BigDecimal.ZERO.add(baseOrder.getGoodsAmount().subtract(baseOrder.getCouponAmount())); BigDecimal originalRefundAmount = BigDecimal.ZERO.add(baseOrder.getGoodsAmount().subtract(baseOrder.getCouponAmount()));
...@@ -158,6 +158,7 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper,OrderRefund> { ...@@ -158,6 +158,7 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper,OrderRefund> {
//退款子流程: 订单基础,退款描述,退款金额 //退款子流程: 订单基础,退款描述,退款金额
refundSubProcess(baseOrder, refundDescBuilder.toString(), originalRefundAmount, refundAmount, RefundTypeEnum.ORDER_FUND.getCode(), RefundStatusEnum.ALL.getCode()); refundSubProcess(baseOrder, refundDescBuilder.toString(), originalRefundAmount, refundAmount, RefundTypeEnum.ORDER_FUND.getCode(), RefundStatusEnum.ALL.getCode());
return refundAmount;
} }
/** /**
...@@ -168,7 +169,7 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper,OrderRefund> { ...@@ -168,7 +169,7 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper,OrderRefund> {
* @param dicParentKey * @param dicParentKey
* @param originalDeductAmount * @param originalDeductAmount
*/ */
public void rentRefundDepositProcess(BaseOrder baseOrder, BigDecimal depositAmount, Long timeLag, String dicParentKey, BigDecimal originalDeductAmount) { public BigDecimal rentRefundDepositProcess(BaseOrder baseOrder, BigDecimal depositAmount, Long timeLag, String dicParentKey, BigDecimal originalDeductAmount) {
// 1、押金 + 租金(规则扣除) // 1、押金 + 租金(规则扣除)
BigDecimal originalRefundAmount = BigDecimal.ZERO.add(depositAmount); BigDecimal originalRefundAmount = BigDecimal.ZERO.add(depositAmount);
BigDecimal refundAmount = BigDecimal.ZERO.add(depositAmount); BigDecimal refundAmount = BigDecimal.ZERO.add(depositAmount);
...@@ -178,12 +179,13 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper,OrderRefund> { ...@@ -178,12 +179,13 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper,OrderRefund> {
BigDecimal residueAmount = calculateRefund(originalDeductAmount, timeLag, dicParentKey, refundDescBuilder); BigDecimal residueAmount = calculateRefund(originalDeductAmount, timeLag, dicParentKey, refundDescBuilder);
residueAmount = residueAmount.setScale(2, RoundingMode.HALF_UP); residueAmount = residueAmount.setScale(2, RoundingMode.HALF_UP);
//退款金额 :押金 - (原扣除款 - 剩余款) //退款金额 :押金 - (原扣除款 - 剩余款) 即: 押金 - (免费天数对应的钱 - 剩余款)
refundAmount = originalRefundAmount.subtract(originalDeductAmount.subtract(residueAmount)); refundAmount = originalRefundAmount.subtract(originalDeductAmount.subtract(residueAmount));
} }
//触发押金退款 //触发押金退款
refundSubProcess(baseOrder, refundDescBuilder.toString(), originalRefundAmount, refundAmount, RefundTypeEnum.DEPOSIT.getCode(), RefundStatusEnum.ALL.getCode()); refundSubProcess(baseOrder, refundDescBuilder.toString(), originalRefundAmount, refundAmount, RefundTypeEnum.DEPOSIT.getCode(), RefundStatusEnum.ALL.getCode());
return refundAmount;
} }
public BigDecimal calculateRefund(BigDecimal goodsAmount, Long timeLag, String dicParentKey, StringBuilder refundDescBuilder) { public BigDecimal calculateRefund(BigDecimal goodsAmount, Long timeLag, String dicParentKey, StringBuilder refundDescBuilder) {
......
...@@ -18,6 +18,7 @@ import com.xxfc.platform.order.contant.enumerate.DepositRefundStatus; ...@@ -18,6 +18,7 @@ import com.xxfc.platform.order.contant.enumerate.DepositRefundStatus;
import com.xxfc.platform.order.contant.enumerate.OrderStatusEnum; import com.xxfc.platform.order.contant.enumerate.OrderStatusEnum;
import com.xxfc.platform.order.entity.*; import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.mapper.OrderVehicaleCrosstownMapper; import com.xxfc.platform.order.mapper.OrderVehicaleCrosstownMapper;
import com.xxfc.platform.order.pojo.DedDetailDTO;
import com.xxfc.platform.order.pojo.mq.OrderMQDTO; import com.xxfc.platform.order.pojo.mq.OrderMQDTO;
import com.xxfc.platform.order.pojo.order.OrderPageVO; import com.xxfc.platform.order.pojo.order.OrderPageVO;
import com.xxfc.platform.order.pojo.order.OrderVehicleCrosstownDto; import com.xxfc.platform.order.pojo.order.OrderVehicleCrosstownDto;
...@@ -34,11 +35,13 @@ import com.xxfc.platform.vehicle.pojo.VehicleDepartureVo; ...@@ -34,11 +35,13 @@ import com.xxfc.platform.vehicle.pojo.VehicleDepartureVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.map.HashedMap; import org.apache.commons.collections4.map.HashedMap;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
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 org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
...@@ -79,11 +82,11 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp ...@@ -79,11 +82,11 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
List<OrderVehicleCrosstownDto> list = mapper.selectByOrderId(orderVehicleCrosstownDto); List<OrderVehicleCrosstownDto> list = mapper.selectByOrderId(orderVehicleCrosstownDto);
for (OrderVehicleCrosstownDto value : list) { for (OrderVehicleCrosstownDto value : list) {
if(value != null && value.getOrperaterId() != null && value.getType() != 1) { if (value != null && value.getOrperaterId() != null && value.getType() != 1) {
UserDTO userDTO = userFeign.userinfoByUid(value.getOrperaterId()).getData(); UserDTO userDTO = userFeign.userinfoByUid(value.getOrperaterId()).getData();
if(userDTO != null) { if (userDTO != null) {
CompanyDetail branchCompany = vehicleFeign.getCompanyDetail(userDTO.getCompanyId()).getData(); CompanyDetail branchCompany = vehicleFeign.getCompanyDetail(userDTO.getCompanyId()).getData();
if(branchCompany != null) { if (branchCompany != null) {
value.setCustomerPhone(branchCompany.getVehiceServicePhone()); value.setCustomerPhone(branchCompany.getVehiceServicePhone());
} }
} }
...@@ -163,20 +166,20 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp ...@@ -163,20 +166,20 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
} }
OrderRentVehicleDetail orderRentVehicleDetail = orderRentVehicleBiz.selectById(baseOrder.getDetailId()); OrderRentVehicleDetail orderRentVehicleDetail = orderRentVehicleBiz.selectById(baseOrder.getDetailId());
if(orderVehicleCrosstownDto.getType() == CrosstownTypeEnum.DEPARTURE.getCode()) { if (orderVehicleCrosstownDto.getType() == CrosstownTypeEnum.DEPARTURE.getCode()) {
boolean flag = getTodayTime(orderRentVehicleDetail.getEndTime()); boolean flag = getTodayTime(orderRentVehicleDetail.getEndTime());
if (!flag) { if (!flag) {
return ObjectRestResponse.createFailedResult(3502, "今日不是交车日期"); return ObjectRestResponse.createFailedResult(3502, "今日不是交车日期");
} }
if(userDTO.getCompanyId() != orderRentVehicleDetail.getStartCompanyId()) { if (userDTO.getCompanyId() != orderRentVehicleDetail.getStartCompanyId()) {
return ObjectRestResponse.createFailedResult(3501, "无交车权限"); return ObjectRestResponse.createFailedResult(3501, "无交车权限");
} }
} else { } else {
if(userDTO.getCompanyId() != orderRentVehicleDetail.getEndCompanyId()) { if (userDTO.getCompanyId() != orderRentVehicleDetail.getEndCompanyId()) {
return ObjectRestResponse.createFailedResult(3503, "无收车权限"); return ObjectRestResponse.createFailedResult(3503, "无收车权限");
} }
} }
if(baseOrder.getStatus() != -1) { if (baseOrder.getStatus() != -1) {
Vehicle vehicle = null; Vehicle vehicle = null;
RestResponse<Vehicle> restResponse = vehicleFeign.findById(orderRentVehicleDetail.getVehicleId()); RestResponse<Vehicle> restResponse = vehicleFeign.findById(orderRentVehicleDetail.getVehicleId());
log.info("获取车辆信息返回消息:{}", restResponse.getMessage()); log.info("获取车辆信息返回消息:{}", restResponse.getMessage());
...@@ -186,12 +189,12 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp ...@@ -186,12 +189,12 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
if (vehicle == null) { if (vehicle == null) {
return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode(), ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getDesc()); return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode(), ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getDesc());
} }
if( vehicle.getMileageLastUpdate() != null) { if (vehicle.getMileageLastUpdate() != null) {
//判断车辆公里数 //判断车辆公里数
if (orderVehicleCrosstownDto.getMileage() == null || orderVehicleCrosstownDto.getMileage() <= vehicle.getMileageLastUpdate()) { if (orderVehicleCrosstownDto.getMileage() == null || orderVehicleCrosstownDto.getMileage() <= vehicle.getMileageLastUpdate()) {
return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getCode(), ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getDesc()); return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getCode(), ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getDesc());
}
} }
}
} }
AppUserDTO appUserDTO = userFeign.userDetailById(baseOrder.getUserId()).getData(); AppUserDTO appUserDTO = userFeign.userDetailById(baseOrder.getUserId()).getData();
...@@ -204,13 +207,13 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp ...@@ -204,13 +207,13 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
vehicleDepartureVo.setDepartureBranchCompanyId(orderRentVehicleDetail.getStartCompanyId()); vehicleDepartureVo.setDepartureBranchCompanyId(orderRentVehicleDetail.getStartCompanyId());
vehicleDepartureVo.setExpectArrivalBranchCompanyId(orderRentVehicleDetail.getEndCompanyId()); vehicleDepartureVo.setExpectArrivalBranchCompanyId(orderRentVehicleDetail.getEndCompanyId());
vehicleDepartureVo.setMileage(orderVehicleCrosstownDto.getMileage()); vehicleDepartureVo.setMileage(orderVehicleCrosstownDto.getMileage());
if(appUserDTO != null) { if (appUserDTO != null) {
vehicleDepartureVo.setUser(appUserDTO.getNickname()); vehicleDepartureVo.setUser(appUserDTO.getNickname());
vehicleDepartureVo.setUserTel(appUserDTO.getUsername()); vehicleDepartureVo.setUserTel(appUserDTO.getUsername());
} else { } else {
vehicleDepartureVo.setUser("APP用戶"); vehicleDepartureVo.setUser("APP用戶");
vehicleDepartureVo.setUserTel("13656235623"); vehicleDepartureVo.setUserTel("13656235623");
} }
vehicleDepartureVo.setUse("用户租车"); vehicleDepartureVo.setUse("用户租车");
vehicleDepartureVo.setBookRecordId(orderRentVehicleDetail.getBookRecordId()); vehicleDepartureVo.setBookRecordId(orderRentVehicleDetail.getBookRecordId());
vehicleDepartureVo.setCheckMan(orderVehicleCrosstownDto.getLicenseName()); vehicleDepartureVo.setCheckMan(orderVehicleCrosstownDto.getLicenseName());
...@@ -229,7 +232,7 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp ...@@ -229,7 +232,7 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
vehicleArrivalVo.setMileage(orderVehicleCrosstownDto.getMileage()); vehicleArrivalVo.setMileage(orderVehicleCrosstownDto.getMileage());
vehicleArrivalVo.setRecycleMan(userDTO.getName()); vehicleArrivalVo.setRecycleMan(userDTO.getName());
vehicleArrivalVo.setBookRecordId(orderRentVehicleDetail.getBookRecordId()); vehicleArrivalVo.setBookRecordId(orderRentVehicleDetail.getBookRecordId());
if(appUserDTO != null) { if (appUserDTO != null) {
vehicleArrivalVo.setRecycleManTel(appUserDTO.getUsername()); vehicleArrivalVo.setRecycleManTel(appUserDTO.getUsername());
} else { } else {
vehicleArrivalVo.setRecycleManTel("13565235623"); vehicleArrivalVo.setRecycleManTel("13565235623");
...@@ -246,17 +249,17 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp ...@@ -246,17 +249,17 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
JSONArray jsonArray = JSONArray.parseArray(orderVehicleCrosstownDto.getDedDetail()); JSONArray jsonArray = JSONArray.parseArray(orderVehicleCrosstownDto.getDedDetail());
for (int i = 0; i < jsonArray.size(); i++) { for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = JSONObject.parseObject(jsonArray.get(i).toString()); JSONObject jsonObject = JSONObject.parseObject(jsonArray.get(i).toString());
if(jsonObject!= null) { if (jsonObject != null) {
cost += Double.parseDouble(jsonObject.getString("cost")); cost += Double.parseDouble(jsonObject.getString("cost"));
} }
} }
} }
BigDecimal amount = new BigDecimal(cost.toString()).divide(new BigDecimal("1"), 2, BigDecimal.ROUND_UP); BigDecimal amount = new BigDecimal(cost.toString()).divide(new BigDecimal("1"), 2, BigDecimal.ROUND_UP);
orderVehicleCrosstownDto.setDeductionCost(amount); orderVehicleCrosstownDto.setDeductionCost(amount);
//扣除费用 //扣除费用
orderVehicleCrosstownDto.setRestDeposit(orderRentVehicleDetail.getDeposit().subtract(amount)); orderVehicleCrosstownDto.setRestDeposit(orderRentVehicleDetail.getDeposit().subtract(orderVehicleCrosstownDto.getDeductionCost()));
if(orderVehicleCrosstownDto.getRestDeposit().compareTo(getAmount()) == -1) { //剩余金额小于保证金 if (orderVehicleCrosstownDto.getRestDeposit().compareTo(getAmount()) == -1) { //剩余金额小于保证金
return ObjectRestResponse.createFailedResult(500,"押金不足,不能交车,请联系客服!"); return ObjectRestResponse.createFailedResult(500, "押金不足,不能交车,请联系客服!");
} }
//出车成功后修改订单状态 //出车成功后修改订单状态
List<OrderVehicleCrosstownDto> oldValue = orderVehicleCrosstownBiz.selectByOrderId(orderVehicleCrosstownDto); List<OrderVehicleCrosstownDto> oldValue = orderVehicleCrosstownBiz.selectByOrderId(orderVehicleCrosstownDto);
...@@ -289,7 +292,7 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp ...@@ -289,7 +292,7 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
BigDecimal totalAmount = new BigDecimal(0); BigDecimal totalAmount = new BigDecimal(0);
ObjectRestResponse<OrderPageVO> objectRestResponse = baseOrderBiz.getOrderDetail(baseOrder.getNo()); ObjectRestResponse<OrderPageVO> objectRestResponse = baseOrderBiz.getOrderDetail(baseOrder.getNo());
if (objectRestResponse.getData() != null && objectRestResponse.getData().getOrderRentVehicleDetail() != null) { if (objectRestResponse.getData() != null && objectRestResponse.getData().getOrderRentVehicleDetail() != null) {
//总押金-保留金 //总押金
totalAmount = objectRestResponse.getData().getOrderRentVehicleDetail().getDeposit(); totalAmount = objectRestResponse.getData().getOrderRentVehicleDetail().getDeposit();
} }
...@@ -305,7 +308,7 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp ...@@ -305,7 +308,7 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
depositRefundRecord.setTotalAmount(totalAmount.subtract(getAmount())); depositRefundRecord.setTotalAmount(totalAmount.subtract(getAmount()));
depositRefundRecord.setCrosstownId(orderVehicleCrosstown.getId()); depositRefundRecord.setCrosstownId(orderVehicleCrosstown.getId());
orderDepositRefundRecordBiz.saveNormalRecord(depositRefundRecord); orderDepositRefundRecordBiz.saveNormalRecord(depositRefundRecord);
//修改订单状态为已完成 //修改订单状态为已完成
baseOrder.setStatus(OrderStatusEnum.ORDER_FINISH.getCode()); baseOrder.setStatus(OrderStatusEnum.ORDER_FINISH.getCode());
baseOrder = baseOrderBiz.updateSelectiveByIdReT(baseOrder); baseOrder = baseOrderBiz.updateSelectiveByIdReT(baseOrder);
//修改订单详情是否押金全部退还 //修改订单详情是否押金全部退还
...@@ -313,19 +316,48 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp ...@@ -313,19 +316,48 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
orderRentVehicleBiz.updateSelectiveByIdRe(orderRentVehicleDetail); orderRentVehicleBiz.updateSelectiveByIdRe(orderRentVehicleDetail);
baseOrderBiz.sendOrderMq(orderRentVehicleDetail, null, null, baseOrder, OrderMQDTO.ORDER_FINISH); baseOrderBiz.sendOrderMq(orderRentVehicleDetail, null, null, baseOrder, OrderMQDTO.ORDER_FINISH);
} else if (orderVehicleCrosstown.getType() == CrosstownTypeEnum.FIXED_LOSS.getCode()) { //定损还车,添加定损记录 } else if (orderVehicleCrosstown.getType() == CrosstownTypeEnum.FIXED_LOSS.getCode()) { //定损还车,添加定损记录
//添加定损记录 //提前还车,结束时间大于当前时间
DepositRefundRecord depositRefundRecord = new DepositRefundRecord(); DateTime nowTime = DateTime.now();
depositRefundRecord.setAmount(orderVehicleCrosstown.getDeductionCost()); DateTime endTime = new DateTime(orderRentVehicleDetail.getEndTime());
depositRefundRecord.setRestAmount(totalAmount.subtract(getAmount()).subtract(orderVehicleCrosstown.getDeductionCost())); DateTime startTime = new DateTime(orderRentVehicleDetail.getStartTime());
depositRefundRecord.setTotalAmount(totalAmount.subtract(getAmount())); //实际预定的天数
depositRefundRecord.setCrosstownId(orderVehicleCrosstown.getId()); int actualDay = getDaysBetweenDateTime(startTime, endTime);
orderDepositRefundRecordBiz.saveFixLossRecord(depositRefundRecord); if (orderRentVehicleDetail.getEndTime() > nowTime.getMillis()) {
//修改訂單狀態為定損 //提前的天数
baseOrder.setStatus(OrderStatusEnum.ORDER_FIXED_LOSS.getCode()); int noUsedDay = getDaysBetweenDateTime(nowTime, endTime);
baseOrderBiz.updateSelectiveByIdReT(baseOrder); //退还未使用的天数,或者金额,扣除违约金,实际未使用天数的金额,最多3000元
orderRentVehicleDetail.setFixedLossStatus(1);
orderRentVehicleBiz.updateSelectiveByIdRe(orderRentVehicleDetail); //延期还车,结束时间小于当前时间
} else if (orderRentVehicleDetail.getEndTime() < nowTime.getMillis()) {
//延期的天数, 延期违约金是延期天数*200%
int usedDay = getDaysBetweenDateTime(endTime, nowTime);
DedDetailDTO dedDetailDTO = new DedDetailDTO();
dedDetailDTO.setDeductions("违约金:");
dedDetailDTO.setCost(baseOrder.getGoodsAmount().multiply(new BigDecimal(usedDay)).multiply(new BigDecimal(2)));
dedDetailDTO.setId(1);
dedDetailDTO.setStatusIndex(1);
dedDetailDTO.setStatusName("延期违约金");
dedDetailDTO.setType(3);
orderVehicleCrosstown.setDedDetail(JSONObject.toJSONString(dedDetailDTO));
BigDecimal restDeposit = orderVehicleCrosstown.getRestDeposit().subtract(dedDetailDTO.getCost());
orderVehicleCrosstown.setRestDeposit(restDeposit);
orderVehicleCrosstown.setDeductionCost(orderVehicleCrosstown.getDeductionCost().add(dedDetailDTO.getCost()));
orderVehicleCrosstownBiz.updateSelectiveByIdRe(orderVehicleCrosstown);
}
} }
//添加定损记录
DepositRefundRecord depositRefundRecord = new DepositRefundRecord();
depositRefundRecord.setAmount(orderVehicleCrosstown.getDeductionCost());
depositRefundRecord.setRestAmount(totalAmount.subtract(getAmount()).subtract(orderVehicleCrosstown.getDeductionCost()));
depositRefundRecord.setTotalAmount(totalAmount.subtract(getAmount()));
depositRefundRecord.setCrosstownId(orderVehicleCrosstown.getId());
orderDepositRefundRecordBiz.saveFixLossRecord(depositRefundRecord);
//修改訂單狀態為定損
baseOrder.setStatus(OrderStatusEnum.ORDER_FIXED_LOSS.getCode());
baseOrderBiz.updateSelectiveByIdReT(baseOrder);
orderRentVehicleDetail.setFixedLossStatus(1);
orderRentVehicleBiz.updateSelectiveByIdRe(orderRentVehicleDetail);
} else if (baseOrder.getStatus() == OrderStatusEnum.ORDER_FIXED_LOSS.getCode()) {//定损后还车 } else if (baseOrder.getStatus() == OrderStatusEnum.ORDER_FIXED_LOSS.getCode()) {//定损后还车
DepositRefundRecord depositRefundRecord = orderDepositRefundRecordBiz.findByCrossIdAndStatus(orderVehicleCrosstown.getId(), DepositRefundStatus.FIXLOSSREFUND.getCode()); DepositRefundRecord depositRefundRecord = orderDepositRefundRecordBiz.findByCrossIdAndStatus(orderVehicleCrosstown.getId(), DepositRefundStatus.FIXLOSSREFUND.getCode());
if (depositRefundRecord != null) { if (depositRefundRecord != null) {
...@@ -341,7 +373,7 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp ...@@ -341,7 +373,7 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
newValue.setId(null); newValue.setId(null);
orderDepositRefundRecordBiz.save(newValue); orderDepositRefundRecordBiz.save(newValue);
DepositRefundRecord nextValue = orderDepositRefundRecordBiz.findByCrossIdAndStatus(orderVehicleCrosstown.getId(), DepositRefundStatus.FIXLOSSREFUNDARRIVAL.getCode()); DepositRefundRecord nextValue = orderDepositRefundRecordBiz.findByCrossIdAndStatus(orderVehicleCrosstown.getId(), DepositRefundStatus.FIXLOSSREFUNDARRIVAL.getCode());
if(nextValue != null) { if (nextValue != null) {
nextValue.setRestAmount(newValue.getRestAmount()); nextValue.setRestAmount(newValue.getRestAmount());
orderDepositRefundRecordBiz.update(nextValue); orderDepositRefundRecordBiz.update(nextValue);
} }
...@@ -354,6 +386,8 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp ...@@ -354,6 +386,8 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
} }
} }
//添加订单驾驶人信息
public void getOrderLicense(OrderVehicleCrosstownDto orderVehicleCrosstownDto) { public void getOrderLicense(OrderVehicleCrosstownDto orderVehicleCrosstownDto) {
if (StringUtils.isNotBlank(orderVehicleCrosstownDto.getLicenseIdCard())) { if (StringUtils.isNotBlank(orderVehicleCrosstownDto.getLicenseIdCard())) {
OrderUserLicense orderUserLicense = new OrderUserLicense(); OrderUserLicense orderUserLicense = new OrderUserLicense();
...@@ -377,9 +411,18 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp ...@@ -377,9 +411,18 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
public boolean getTodayTime(Long time) { public boolean getTodayTime(Long time) {
long current = System.currentTimeMillis(); long current = System.currentTimeMillis();
if (current <= (time / (1000 * 3600 * 24) * (1000 * 3600 * 24) - TimeZone.getDefault().getRawOffset() ) + 24 * 60 * 60 * 1000 -1) { if (current <= (time / (1000 * 3600 * 24) * (1000 * 3600 * 24) - TimeZone.getDefault().getRawOffset()) + 24 * 60 * 60 * 1000 - 1) {
return true; return true;
} }
return false; return false;
} }
//获取两个日期之间的天数
public int getDaysBetweenDateTime(DateTime startDay, DateTime endDay) {
int a = 0;
for (DateTime curDate = startDay.plusDays(1); curDate.compareTo(endDay) < 0; curDate = curDate.plusDays(1)) {
a++;
}
return a;
}
} }
...@@ -134,11 +134,12 @@ public class OrderCancelBiz { ...@@ -134,11 +134,12 @@ public class OrderCancelBiz {
// } // }
//退款流程 //退款流程
//退押金
orderRefundBiz.rentRefundDepositProcess(hasUpdateOrder, orvd.getDeposit(), timeLag, APP_ORDER+ "_"+ RENT_REFUND, freeDayAmount);
//退订单款 //退订单款
orderRefundBiz.rentRefundProcess(hasUpdateOrder, timeLag, APP_ORDER+ "_"+ RENT_REFUND); orderRefundBiz.rentRefundProcess(hasUpdateOrder, timeLag, APP_ORDER+ "_"+ RENT_REFUND);
//退押金
orderRefundBiz.rentRefundDepositProcess(hasUpdateOrder, orvd.getDeposit(), timeLag, APP_ORDER+ "_"+ RENT_REFUND, freeDayAmount);
//已付款的取消订单发送消息 //已付款的取消订单发送消息
try { try {
AppUserDTO appUserDTO = userFeign.userDetailById(baseOrder.getUserId()).getData(); AppUserDTO appUserDTO = userFeign.userDetailById(baseOrder.getUserId()).getData();
......
...@@ -131,6 +131,10 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> { ...@@ -131,6 +131,10 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
if (article.getType() == null) { if (article.getType() == null) {
article.setType(0); article.setType(0);
} }
if (article.getStatus()==1){
article.setAddTime(new Date());
}
article.setCreTime(new Date()); article.setCreTime(new Date());
mapper.insertSelective(article); mapper.insertSelective(article);
......
...@@ -64,6 +64,7 @@ public class VehicleModelController extends CommonBaseController { ...@@ -64,6 +64,7 @@ public class VehicleModelController extends CommonBaseController {
@GetMapping(value = "/findVehicleModelPage") @GetMapping(value = "/findVehicleModelPage")
@IgnoreUserToken @IgnoreUserToken
public ObjectRestResponse<PageDataVO<VehicleModelVo>> findVehicleModelPageUnauthfind(VehicleModelQueryCondition vmqc) { public ObjectRestResponse<PageDataVO<VehicleModelVo>> findVehicleModelPageUnauthfind(VehicleModelQueryCondition vmqc) {
vmqc.setNotInIds("67");
ObjectRestResponse<PageDataVO<VehicleModelVo>> objectRestResponse = vehicleFeign.findVehicleModelPageUnauthfind(vmqc); ObjectRestResponse<PageDataVO<VehicleModelVo>> objectRestResponse = vehicleFeign.findVehicleModelPageUnauthfind(vmqc);
PageDataVO<VehicleModelVo> pageDataVOs = objectRestResponse.getData(); PageDataVO<VehicleModelVo> pageDataVOs = objectRestResponse.getData();
pageDataVOs.getData().forEach( v -> { pageDataVOs.getData().forEach( v -> {
......
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
<dependency> <dependency>
<groupId>cn.jpush.api</groupId> <groupId>cn.jpush.api</groupId>
<artifactId>jpush-client</artifactId> <artifactId>jpush-client</artifactId>
<version>3.3.7</version> <version>3.3.9</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.jpush.api</groupId> <groupId>cn.jpush.api</groupId>
......
package com.xxfc.platform.universal.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
/**
* 消息推送表
*
* @author zjw
* @email nishijjo@qq.com
* @date 2019-05-28 16:17:42
*/
@Data
@Table(name = "message_push")
public class MessagePush implements Serializable {
private static final long serialVersionUID = 1L;
//
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("")
private Integer id;
@ApiModelProperty(value = "1-手动推送;2-系统自动推送")
private Integer type;
@Column(name = "send_type")
@ApiModelProperty(value = "系统发送类型:1-支付完成")
private Integer sendType;
@ApiModelProperty(value = "通知标题")
private String title;
@ApiModelProperty(value = "通知内容")
private String alert;
@ApiModelProperty(value = "通知栏样式类型:1-大文本;2-文本条目;3-大图片")
private Integer style;
@Column(name = "big_text")
@ApiModelProperty(value = "大文本通知栏样式")
private String bigText;
@ApiModelProperty(value = "文本条目通知栏样式")
private String inbox;
@Column(name = "big_pic_path")
@ApiModelProperty(value = "大图片通知栏样式")
private String bigPicPath;
@ApiModelProperty(value = "指定跳转页面")
private String intent;
@Column(name = "crt_time")
@ApiModelProperty(value = "创建时间", hidden = true )
private Long crtTime;
@Column(name = "upd_time")
@ApiModelProperty(value = "更新时间", hidden = true )
private Long updTime;
@Column(name = "is_del")
@ApiModelProperty(value = "是否删除")
private Integer isDel;
}
package com.xxfc.platform.universal.utils;
import cn.jiguang.common.ClientConfig;
import cn.jiguang.common.ServiceHelper;
import cn.jiguang.common.connection.NativeHttpClient;
import cn.jiguang.common.connection.NettyHttpClient;
import cn.jiguang.common.resp.APIConnectionException;
import cn.jiguang.common.resp.APIRequestException;
import cn.jiguang.common.resp.ResponseWrapper;
import cn.jpush.api.JPushClient;
import cn.jpush.api.push.CIDResult;
import cn.jpush.api.push.GroupPushClient;
import cn.jpush.api.push.PushResult;
import cn.jpush.api.push.model.*;
import cn.jpush.api.push.model.audience.Audience;
import cn.jpush.api.push.model.audience.AudienceTarget;
import cn.jpush.api.push.model.notification.*;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import io.netty.handler.codec.http.HttpMethod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
public class PushExample {
protected static final Logger LOG = LoggerFactory.getLogger(PushExample.class);
// demo App defined in resources/jpush-api.conf
protected static final String APP_KEY = "7b4b94cca0d185d611e53cca";
protected static final String MASTER_SECRET = "860803cf613ed54aa3b941a8";
protected static final String GROUP_PUSH_KEY = "2c88a01e073a0fe4fc7b167c";
protected static final String GROUP_MASTER_SECRET = "b11314807507e2bcfdeebe2e";
public static final String TITLE = "Test from API example";
public static final String ALERT = "Test from API Example - alert";
public static final String MSG_CONTENT = "Test from API Example - msgContent";
public static final String REGISTRATION_ID = "0900e8d85ef";
public static final String TAG = "tag_api";
public static long sendCount = 0;
private static long sendTotalTime = 0;
// 使用 NettyHttpClient 异步接口发送请求
public static void testSendPushWithCallback() {
ClientConfig clientConfig = ClientConfig.getInstance();
String host = (String) clientConfig.get(ClientConfig.PUSH_HOST_NAME);
final NettyHttpClient client = new NettyHttpClient(ServiceHelper.getBasicAuthorization(APP_KEY, MASTER_SECRET),
null, clientConfig);
try {
URI uri = new URI(host + clientConfig.get(ClientConfig.PUSH_PATH));
PushPayload payload = buildPushObject_all_alias_alert();
client.sendRequest(HttpMethod.POST, payload.toString(), uri, new NettyHttpClient.BaseCallback() {
@Override
public void onSucceed(ResponseWrapper responseWrapper) {
LOG.info("Got result: " + responseWrapper.responseContent);
}
});
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
public static void testSendPush() {
ClientConfig clientConfig = ClientConfig.getInstance();
final JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY, null, clientConfig);
// String authCode = ServiceHelper.getBasicAuthorization(APP_KEY, MASTER_SECRET);
// Here you can use NativeHttpClient or NettyHttpClient or ApacheHttpClient.
// Call setHttpClient to set httpClient,
// If you don't invoke this method, default httpClient will use NativeHttpClient.
// ApacheHttpClient httpClient = new ApacheHttpClient(authCode, null, clientConfig);
// NettyHttpClient httpClient =new NettyHttpClient(authCode, null, clientConfig);
// jpushClient.getPushClient().setHttpClient(httpClient);
final PushPayload payload = buildPushObject_android_and_ios();
// // For push, all you need do is to build PushPayload object.
// PushPayload payload = buildPushObject_all_alias_alert();
try {
PushResult result = jpushClient.sendPush(payload);
LOG.info("Got result - " + result);
System.out.println(result);
// 如果使用 NettyHttpClient,需要手动调用 close 方法退出进程
// If uses NettyHttpClient, call close when finished sending request, otherwise process will not exit.
// jpushClient.close();
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
LOG.error("Sendno: " + payload.getSendno());
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
LOG.info("Msg ID: " + e.getMsgId());
LOG.error("Sendno: " + payload.getSendno());
}
}
//use String to build PushPayload instance
public static void testSendPush_fromJSON() {
ClientConfig clientConfig = ClientConfig.getInstance();
JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY, null, clientConfig);
Gson gson = new GsonBuilder()
.registerTypeAdapter(PlatformNotification.class, new InterfaceAdapter<PlatformNotification>())
.create();
// Since the type of DeviceType is enum, thus the value should be uppercase, same with the AudienceType.
String payloadString = "{\"platform\":{\"all\":false,\"deviceTypes\":[\"IOS\"]},\"audience\":{\"all\":true,\"targets\":[{\"audienceType\":\"TAG_AND\",\"values\":[\"tag1\",\"tag_all\"]}]},\"notification\":{\"notifications\":[{\"soundDisabled\":false,\"badgeDisabled\":false,\"sound\":\"happy\",\"badge\":\"5\",\"contentAvailable\":false,\"alert\":\"Test from API Example - alert\",\"extras\":{\"from\":\"JPush\"},\"type\":\"cn.jpush.api.push.model.notification.IosNotification\"}]},\"message\":{\"msgContent\":\"Test from API Example - msgContent\"},\"options\":{\"sendno\":1429488213,\"overrideMsgId\":0,\"timeToLive\":-1,\"apnsProduction\":true,\"bigPushDuration\":0}}";
PushPayload payload = gson.fromJson(payloadString, PushPayload.class);
try {
PushResult result = jpushClient.sendPush(payloadString);
LOG.info("Got result - " + result);
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
// LOG.error("Sendno: " + payload.getSendno());
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
LOG.info("Msg ID: " + e.getMsgId());
//LOG.error("Sendno: " + payload.getSendno());
}
}
/**
* 测试多线程发送 2000 条推送耗时
*/
public static void testSendPushes() {
ClientConfig clientConfig = ClientConfig.getInstance();
final JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY, null, clientConfig);
String authCode = ServiceHelper.getBasicAuthorization(APP_KEY, MASTER_SECRET);
// Here you can use NativeHttpClient or NettyHttpClient or ApacheHttpClient.
NativeHttpClient httpClient = new NativeHttpClient(authCode, null, clientConfig);
// Call setHttpClient to set httpClient,
// If you don't invoke this method, default httpClient will use NativeHttpClient.
// ApacheHttpClient httpClient = new ApacheHttpClient(authCode, null, clientConfig);
jpushClient.getPushClient().setHttpClient(httpClient);
final PushPayload payload = buildPushObject_ios_tagAnd_alertWithExtrasAndMessage();
for (int i = 0; i < 10; i++) {
Thread thread = new Thread() {
public void run() {
for (int j = 0; j < 200; j++) {
long start = System.currentTimeMillis();
try {
PushResult result = jpushClient.sendPush(payload);
LOG.info("Got result - " + result);
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
LOG.error("Sendno: " + payload.getSendno());
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
LOG.info("Msg ID: " + e.getMsgId());
LOG.error("Sendno: " + payload.getSendno());
}
System.out.println("耗时" + (System.currentTimeMillis() - start) + "毫秒 sendCount:" + (++sendCount));
}
}
};
thread.start();
}
}
public void testSendGroupPush() {
GroupPushClient groupPushClient = new GroupPushClient(GROUP_MASTER_SECRET, GROUP_PUSH_KEY);
final PushPayload payload = buildPushObject_android_and_ios();
try {
Map<String, PushResult> result = groupPushClient.sendGroupPush(payload);
for (Map.Entry<String, PushResult> entry : result.entrySet()) {
PushResult pushResult = entry.getValue();
PushResult.Error error = pushResult.error;
if (error != null) {
LOG.info("AppKey: " + entry.getKey() + " error code : " + error.getCode() + " error message: " + error.getMessage());
} else {
LOG.info("AppKey: " + entry.getKey() + " sendno: " + pushResult.sendno + " msg_id:" + pushResult.msg_id);
}
}
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
LOG.error("Sendno: " + payload.getSendno());
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
LOG.info("Msg ID: " + e.getMsgId());
LOG.error("Sendno: " + payload.getSendno());
}
}
public static PushPayload buildPushObject_all_all_alert() {
return PushPayload.alertAll(ALERT);
}
public static PushPayload buildPushObject_all_alias_alert() {
return PushPayload.newBuilder()
.setPlatform(Platform.all())
.setAudience(Audience.alias("alias1"))
.setNotification(Notification.alert(ALERT))
.build();
}
public static PushPayload buildPushObject_android_tag_alertWithTitle() {
return PushPayload.newBuilder()
.setPlatform(Platform.android())
.setAudience(Audience.tag("tag1"))
.setNotification(Notification.android(ALERT, TITLE, null))
.build();
}
public static PushPayload buildPushObject_android_and_ios() {
Map<String, String> extras = new HashMap<String, String>();
extras.put("test", "https://community.jiguang.cn/push");
return PushPayload.newBuilder()
.setPlatform(Platform.android_ios())
.setAudience(Audience.all())
.setNotification(Notification.newBuilder()
.setAlert("alert content")
.addPlatformNotification(AndroidNotification.newBuilder()
.setTitle("Android Title")
.addExtras(extras).build())
.addPlatformNotification(IosNotification.newBuilder()
.incrBadge(1)
.addExtra("extra_key", "extra_value").build())
.build())
.build();
}
public static void buildPushObject_with_extra() {
JsonObject jsonExtra = new JsonObject();
jsonExtra.addProperty("extra1", 1);
jsonExtra.addProperty("extra2", false);
Map<String, String> extras = new HashMap<String, String>();
extras.put("extra_1", "val1");
extras.put("extra_2", "val2");
PushPayload payload = PushPayload.newBuilder()
.setPlatform(Platform.android_ios())
.setAudience(Audience.tag("tag1"))
.setNotification(Notification.newBuilder()
.setAlert("alert content")
.addPlatformNotification(AndroidNotification.newBuilder()
.setTitle("Android Title")
.addExtras(extras)
.addExtra("booleanExtra", false)
.addExtra("numberExtra", 1)
.addExtra("jsonExtra", jsonExtra)
.build())
.addPlatformNotification(IosNotification.newBuilder()
.incrBadge(1)
.addExtra("extra_key", "extra_value").build())
.build())
.build();
System.out.println(payload.toJSON());
}
public static PushPayload buildPushObject_ios_tagAnd_alertWithExtrasAndMessage() {
JsonObject sound = new JsonObject();
sound.add("critical", new JsonPrimitive(1));
sound.add("name", new JsonPrimitive("default"));
sound.add("volume", new JsonPrimitive(0.2));
return PushPayload.newBuilder()
.setPlatform(Platform.ios())
.setAudience(Audience.tag_and("tag1", "tag_all"))
.setNotification(Notification.newBuilder()
.addPlatformNotification(IosNotification.newBuilder()
.setAlert(ALERT)
.setBadge(5)
.setMutableContent(false)
// .setSound("happy")
.setSound(sound)
.addExtra("from", "JPush")
.build())
.build())
.setMessage(Message.content(MSG_CONTENT))
.setOptions(Options.newBuilder()
.setApnsProduction(true)
.build())
.build();
}
public static PushPayload buildPushObject_android_newly_support() {
JsonObject inbox = new JsonObject();
inbox.add("line1", new JsonPrimitive("line1 string"));
inbox.add("line2", new JsonPrimitive("line2 string"));
inbox.add("contentTitle", new JsonPrimitive("title string"));
inbox.add("summaryText", new JsonPrimitive("+3 more"));
JsonObject intent = new JsonObject();
intent.add("url", new JsonPrimitive("intent:#Intent;component=com.jiguang.push/com.example.jpushdemo.SettingActivity;end"));
Notification notification = Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder()
.setAlert(ALERT)
.setBigPicPath("path to big picture")
.setBigText("long text")
.setBuilderId(1)
.setCategory("CATEGORY_SOCIAL")
.setInbox(inbox)
.setStyle(1)
.setTitle("Alert test")
.setPriority(1)
.setLargeIcon("http://www.jiguang.cn/largeIcon.jpg")
.setIntent(intent)
.build())
.build();
return PushPayload.newBuilder()
.setPlatform(Platform.all())
.setAudience(Audience.all())
.setNotification(notification)
.setOptions(Options.newBuilder()
.setApnsProduction(true)
.setSendno(ServiceHelper.generateSendno())
.build())
.build();
}
public static PushPayload buildPushObject_ios_audienceMore_messageWithExtras() {
return PushPayload.newBuilder()
.setPlatform(Platform.android_ios())
.setAudience(Audience.newBuilder()
.addAudienceTarget(AudienceTarget.tag("tag1", "tag2"))
.addAudienceTarget(AudienceTarget.alias("alias1", "alias2"))
.build())
.setMessage(Message.newBuilder()
.setMsgContent(MSG_CONTENT)
.addExtra("from", "JPush")
.build())
.build();
}
public static PushPayload buildPushObject_all_tag_not() {
return PushPayload.newBuilder()
.setPlatform(Platform.all())
.setAudience(Audience.tag_not("abc", "123"))
.setNotification(Notification.alert(ALERT))
.build();
}
public static PushPayload buildPushObject_android_cid() {
Collection<String> list = new LinkedList<String>();
list.add("1507bfd3f79558957de");
list.add("1507bfd3f79554957de");
list.add("1507bfd3f79555957de");
list.add("1507bfd3f79556957de");
list.add("1507ffd3f79545957de");
list.add("1507ffd3f79457957de");
list.add("1507ffd3f79456757de");
return PushPayload.newBuilder()
.setPlatform(Platform.android())
// .setAudience(Audience.registrationId("1507bfd3f79558957de"))
.setAudience(Audience.registrationId(list))
.setNotification(Notification.alert(ALERT))
.setCid("cid")
.build();
}
public static void testSendPushWithCustomConfig() {
ClientConfig config = ClientConfig.getInstance();
// Setup the custom hostname
config.setPushHostName("https://api.jpush.cn");
JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY, null, config);
// For push, all you need do is to build PushPayload object.
PushPayload payload = buildPushObject_all_all_alert();
try {
PushResult result = jpushClient.sendPush(payload);
LOG.info("Got result - " + result);
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
LOG.info("Msg ID: " + e.getMsgId());
}
}
public static void testSendIosAlert() {
JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
IosAlert alert = IosAlert.newBuilder()
.setTitleAndBody("test alert", "subtitle", "test ios alert json")
.setActionLocKey("PLAY")
.build();
try {
PushResult result = jpushClient.sendIosNotificationWithAlias(alert, new HashMap<String, String>(), "alias1");
LOG.info("Got result - " + result);
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
}
}
public static void testSendWithSMS() {
JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
try {
// SMS sms = SMS.content(1, 10);
SMS sms = SMS.newBuilder()
.setDelayTime(1000)
.setTempID(2000)
.addPara("Test", 1)
.build();
PushResult result = jpushClient.sendAndroidMessageWithAlias("Test SMS", "test sms", sms, "alias1");
LOG.info("Got result - " + result);
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
}
}
public static void testGetCidList() {
JPushClient jPushClient = new JPushClient(MASTER_SECRET, APP_KEY);
try {
CIDResult result = jPushClient.getCidList(3, "push");
LOG.info("Got result - " + result);
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
}
}
public static void testSendPushWithCid() {
JPushClient jPushClient = new JPushClient(MASTER_SECRET, APP_KEY);
PushPayload pushPayload = buildPushObject_android_cid();
try {
PushResult result = jPushClient.sendPush(pushPayload);
LOG.info("Got result - " + result);
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
}
}
}
...@@ -2,22 +2,35 @@ package com.xxfc.platform.universal.biz; ...@@ -2,22 +2,35 @@ package com.xxfc.platform.universal.biz;
import cn.jiguang.common.ClientConfig; import cn.jiguang.common.ClientConfig;
import cn.jiguang.common.ServiceHelper;
import cn.jiguang.common.resp.APIConnectionException; import cn.jiguang.common.resp.APIConnectionException;
import cn.jiguang.common.resp.APIRequestException; import cn.jiguang.common.resp.APIRequestException;
import cn.jpush.api.JPushClient; import cn.jpush.api.JPushClient;
import cn.jpush.api.push.PushResult; import cn.jpush.api.push.PushResult;
import cn.jpush.api.push.model.Options;
import cn.jpush.api.push.model.Platform;
import cn.jpush.api.push.model.PushPayload; import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.push.model.audience.Audience;
import cn.jpush.api.push.model.notification.AndroidNotification;
import cn.jpush.api.push.model.notification.Notification;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.universal.service.SmsService; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.universal.utils.CCPRestSmsUtils; import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.xxfc.platform.universal.entity.MessagePush;
import com.xxfc.platform.universal.mapper.MessagePushMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
@Service @Service
@Slf4j @Slf4j
public class JPushBiz { public class JPushBiz extends BaseBiz<MessagePushMapper, MessagePush> {
@Value("${universal.MASTER_SECRET}") @Value("${universal.MASTER_SECRET}")
...@@ -25,6 +38,8 @@ public class JPushBiz { ...@@ -25,6 +38,8 @@ public class JPushBiz {
@Value("${universal.APP_KEY}") @Value("${universal.APP_KEY}")
private String APP_KEY; private String APP_KEY;
public static final String ALERT = "Test from API Example - alert";
//推送给所有平台设备 //推送给所有平台设备
public ObjectRestResponse jpushToAllPlat(String title){ public ObjectRestResponse jpushToAllPlat(String title){
ClientConfig clientConfig = ClientConfig.getInstance(); ClientConfig clientConfig = ClientConfig.getInstance();
...@@ -48,5 +63,179 @@ public class JPushBiz { ...@@ -48,5 +63,179 @@ public class JPushBiz {
} }
} }
//推送给所有平台设备
public ObjectRestResponse jpushToAllPlat1(){
ClientConfig clientConfig = ClientConfig.getInstance();
final JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY, null, clientConfig);
PushPayload payload = buildPushObject_android_newly_support();
try {
PushResult result = jpushClient.sendPush(payload);
log.debug("\n推送结果:"+result);
return ObjectRestResponse.succ();
} catch (APIConnectionException e) {
// Connection error, should retry later
log.debug("\nConnection error, should retry later"+e);
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,e.getMessage());
} catch (APIRequestException e) {
// Should review the error, and fix the request
log.debug("\nShould review the error, and fix the request"+ e);
log.debug("\nHTTP Status: " + e.getStatus());
log.debug("\nError Code: " + e.getErrorCode());
log.debug("\nError Message: " + e.getErrorMessage());
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,e.getMessage());
}
}
public static PushPayload buildPushObject_android_newly_support() {
JsonObject inbox = new JsonObject();
inbox.add("line1", new JsonPrimitive("line1 string"));
inbox.add("line2", new JsonPrimitive("line2 string"));
inbox.add("contentTitle", new JsonPrimitive("title string"));
inbox.add("summaryText", new JsonPrimitive("+3 more"));
JsonObject intent = new JsonObject();
intent.add("url", new JsonPrimitive("intent:#Intent;component=com.jiguang.push/com.example.jpushdemo.SettingActivity;end"));
Notification notification = Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder()
.setAlert("测试通知内容")
.setBigPicPath("https://xxtest.upyuns.com/image/app/oyI48qqcy3m38iCFffFc3UeZLcm1s3.png")
.setBigText("long text")
.setBuilderId(1)
.setCategory("CATEGORY_SOCIAL")
.setInbox(inbox)
.setStyle(3)
.setTitle("测试通知标题")
.setPriority(1)
.setLargeIcon("https://xxtest.upyuns.com/image/admin/stock.jpg")
.setIntent(intent)
.build())
.build();
return PushPayload.newBuilder()
.setPlatform(Platform.all())
.setAudience(Audience.all())
.setNotification(notification)
.setOptions(Options.newBuilder()
.setApnsProduction(true)
.setSendno(ServiceHelper.generateSendno())
.build())
.build();
}
//推送
public ObjectRestResponse jpushToAlias(Integer id,String userIds){
ClientConfig clientConfig = ClientConfig.getInstance();
final JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY, null, clientConfig);
PushPayload payload = buildPushObject_android_id(id,userIds);
if (payload==null){
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"参数无效");
}
try {
PushResult result = jpushClient.sendPush(payload);
log.debug("\n推送结果:"+result);
return ObjectRestResponse.succ();
} catch (APIConnectionException e) {
// Connection error, should retry later
log.debug("\nConnection error, should retry later"+e);
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,e.getMessage());
} catch (APIRequestException e) {
// Should review the error, and fix the request
log.debug("\nShould review the error, and fix the request"+ e);
log.debug("\nHTTP Status: " + e.getStatus());
log.debug("\nError Code: " + e.getErrorCode());
log.debug("\nError Message: " + e.getErrorMessage());
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,e.getMessage());
}
}
public PushPayload buildPushObject_android_id(Integer id,String userIds) {
Example example =new Example(MessagePush.class);
example.createCriteria().andEqualTo("id",id).andEqualTo("isDel",0);
MessagePush messagePush=mapper.selectOneByExample(example);
if (messagePush==null||messagePush.getType()==null){
log.info("无有效数据--id=="+id);
return null;
}
Audience audience=Audience.all();
if (messagePush.getType()==2){
if (StringUtils.isBlank(userIds)){
log.info("无有效数据--type=="+messagePush.getType()+"------userId=="+userIds);
return null;
}
audience=Audience.alias(userIds);
}
JsonObject intent = new JsonObject();
if (StringUtils.isNotBlank(messagePush.getIntent())){
intent= getJsonObject(messagePush.getIntent());
}
Notification notification = Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder()
.setAlert(messagePush.getAlert())
.setBigPicPath(messagePush.getBigPicPath())
.setBigText(messagePush.getBigText())
.setBuilderId(1)
.setCategory("CATEGORY_SOCIAL")
.setInbox(messagePush.getInbox())
.setStyle(messagePush.getStyle())
.setTitle(messagePush.getTitle())
.setPriority(1)
.setIntent(intent)
.build())
.build();
return PushPayload.newBuilder()
.setPlatform(Platform.all())
.setAudience(audience)
.setNotification(notification)
.setOptions(Options.newBuilder()
.setApnsProduction(true)
.setSendno(ServiceHelper.generateSendno())
.build())
.build();
}
//字符串转JsonObject
public JsonObject getJsonObject(String json){
Gson g = new Gson();
return g.fromJson(json, JsonObject.class);
}
//编辑推送内容
public ObjectRestResponse updMessagePush(MessagePush messagePush){
Integer id= messagePush.getId();
if (id==null){
insertSelective(messagePush);
}else {
updateSelectiveById(messagePush);
}
return ObjectRestResponse.succ();
}
//删除推送内容
public ObjectRestResponse delMessagePush(MessagePush messagePush){
messagePush.setIsDel(1);
updateSelectiveById(messagePush);
return ObjectRestResponse.succ();
}
//获取列表
public ObjectRestResponse getList(Integer page,Integer limit,String title,Integer type){
Example example =new Example(MessagePush.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("isDel",0);
if (StringUtils.isNotBlank(title)){
criteria.andLike("title","%"+title+"%");
}
if (type!=null&&type!=0){
criteria.andEqualTo("type",type);
}
return ObjectRestResponse.succ(PageDataVO.pageInfo(page, limit, ()->mapper.selectByExample(example)));
}
} }
...@@ -5,6 +5,7 @@ package com.xxfc.platform.universal.controller; ...@@ -5,6 +5,7 @@ package com.xxfc.platform.universal.controller;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken; import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.universal.biz.JPushBiz; import com.xxfc.platform.universal.biz.JPushBiz;
import com.xxfc.platform.universal.entity.MessagePush;
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.*;
...@@ -27,5 +28,42 @@ public class JPushController { ...@@ -27,5 +28,42 @@ public class JPushController {
return jPushBiz.jpushToAllPlat(title); return jPushBiz.jpushToAllPlat(title);
} }
@RequestMapping(value = "/app/unauth/alls", method = RequestMethod.GET) //匹配的是href中的download请求
public ObjectRestResponse alls() throws Exception {
return jPushBiz.jpushToAllPlat1();
}
@RequestMapping(value = "/stype", method = RequestMethod.GET)
public ObjectRestResponse stype(@RequestParam(value = "id",defaultValue = "0") Integer id,
@RequestParam(value = "userIds",defaultValue = "") String userIds) throws Exception {
return jPushBiz.jpushToAlias(id,userIds);
}
@RequestMapping(value = "/addMessagePush", method = RequestMethod.POST)
public ObjectRestResponse addMessagePush(@RequestBody MessagePush messagePush){
return jPushBiz.updMessagePush(messagePush);
}
@RequestMapping(value = "/udpMessagePush", method = RequestMethod.POST)
public ObjectRestResponse udpMessagePush(@RequestBody MessagePush messagePush){
return jPushBiz.updMessagePush(messagePush);
}
@RequestMapping(value = "/del", method = RequestMethod.POST)
public ObjectRestResponse delMessagePush(@RequestBody MessagePush messagePush){
return jPushBiz.delMessagePush(messagePush);
}
@RequestMapping(value = "/list", method = RequestMethod.GET)
public ObjectRestResponse getList(@RequestParam(value = "page",defaultValue = "1") Integer page,
@RequestParam(value = "limit",defaultValue = "10") Integer limit,
@RequestParam(value = "title",defaultValue = "") String title,
@RequestParam(value = "type",defaultValue = "0") Integer type){
return jPushBiz.getList(page,limit,title,type);
}
} }
package com.xxfc.platform.universal.mapper;
import com.xxfc.platform.universal.entity.MessagePush;
import tk.mybatis.mapper.common.Mapper;
/**
* 消息推送表
*
* @author zjw
* @email nishijjo@qq.com
* @date 2019-05-28 16:17:42
*/
public interface MessagePushMapper extends Mapper<MessagePush> {
}
...@@ -30,6 +30,8 @@ public class VehicleModelQueryCondition { ...@@ -30,6 +30,8 @@ public class VehicleModelQueryCondition {
private Integer status; private Integer status;
@ApiModelProperty("分类逗号分割") @ApiModelProperty("分类逗号分割")
String catasStr; String catasStr;
@ApiModelProperty("排除的车型id")
String notInIds;
@ApiModelProperty(value = "分类列表", hidden = true) @ApiModelProperty(value = "分类列表", hidden = true)
Map<Integer, List<VehiclePlatCata>> catas; Map<Integer, List<VehiclePlatCata>> catas;
} }
...@@ -3,6 +3,7 @@ package com.xxfc.platform.vehicle.biz; ...@@ -3,6 +3,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.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.RandomUtil;
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.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
...@@ -10,6 +11,7 @@ import com.xxfc.platform.vehicle.entity.*; ...@@ -10,6 +11,7 @@ import com.xxfc.platform.vehicle.entity.*;
import com.xxfc.platform.vehicle.mapper.BranchCompanyStockInfoMapper; import com.xxfc.platform.vehicle.mapper.BranchCompanyStockInfoMapper;
import com.xxfc.platform.vehicle.mapper.CompanyBaseMapper; import com.xxfc.platform.vehicle.mapper.CompanyBaseMapper;
import com.xxfc.platform.vehicle.mapper.SysRegionMapper; import com.xxfc.platform.vehicle.mapper.SysRegionMapper;
import com.xxfc.platform.vehicle.pojo.AddOrUpdateVehicleVo;
import com.xxfc.platform.vehicle.pojo.dto.CompanyBaseDetailDTO; import com.xxfc.platform.vehicle.pojo.dto.CompanyBaseDetailDTO;
import com.xxfc.platform.vehicle.pojo.vo.CompanyBaseVo; import com.xxfc.platform.vehicle.pojo.vo.CompanyBaseVo;
import com.xxfc.platform.vehicle.pojo.vo.CompanyVo; import com.xxfc.platform.vehicle.pojo.vo.CompanyVo;
...@@ -26,6 +28,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -26,6 +28,7 @@ import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Scanner;
@Service @Service
@Slf4j @Slf4j
...@@ -47,6 +50,9 @@ public class CompanyBaseBiz extends BaseBiz<CompanyBaseMapper, CompanyBase> { ...@@ -47,6 +50,9 @@ public class CompanyBaseBiz extends BaseBiz<CompanyBaseMapper, CompanyBase> {
@Autowired @Autowired
AreaBiz areaBiz; AreaBiz areaBiz;
@Autowired
VehicleBiz vehicleBiz;
@Value("${branchCompanyPic.url}") @Value("${branchCompanyPic.url}")
private String companyUrl; private String companyUrl;
...@@ -85,6 +91,47 @@ public class CompanyBaseBiz extends BaseBiz<CompanyBaseMapper, CompanyBase> { ...@@ -85,6 +91,47 @@ public class CompanyBaseBiz extends BaseBiz<CompanyBaseMapper, CompanyBase> {
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
//临时数据同步4(添加车辆)
public ObjectRestResponse synchro4() throws Exception{
List<BranchCompany> list= branchCompanyBiz.selectListAll();
if (list.size()>0){
int num=1;
for (BranchCompany branchCompany:list){
List<AddOrUpdateVehicleVo> addOrUpdateVehicleVoList=new ArrayList<>();
for (int i=1;i<6;i++){
String numberPlate="测试"+getNumberPlate(num);
AddOrUpdateVehicleVo vehicleVo=new AddOrUpdateVehicleVo();
vehicleVo.setCode(Integer.parseInt(RandomUtil.getRandomStr(4)));
vehicleVo.setNumberPlate(numberPlate);
vehicleVo.setStatus(1);
vehicleVo.setBrand(5);
vehicleVo.setUseType(1);
vehicleVo.setModelId(67);
vehicleVo.setSubordinateBranch(branchCompany.getId());
vehicleVo.setMaintenanceMileage(3000);
vehicleVo.setParkBranchCompanyId(branchCompany.getId());
vehicleVo.setTravelStatus(3);
addOrUpdateVehicleVoList.add(vehicleVo);
num++;
log.info("----成功---num=="+num+"---numberPlate==="+numberPlate);
}
vehicleBiz.add(addOrUpdateVehicleVoList);
}
}
return ObjectRestResponse.succ();
}
public String getNumberPlate(int number){
String str=number+"";
char[] ary1 = str.toCharArray();
char[] ary2 = {'0','0','0','0'};
System.arraycopy(ary1, 0, ary2, ary2.length-ary1.length, ary1.length);
String result = new String(ary2);
return result;
}
//临时数据同步2 //临时数据同步2
public ObjectRestResponse synchro2(){ public ObjectRestResponse synchro2(){
List<BranchCompany> list= branchCompanyBiz.selectListAll(); List<BranchCompany> list= branchCompanyBiz.selectListAll();
......
...@@ -58,95 +58,99 @@ public class VehicleActiveService { ...@@ -58,95 +58,99 @@ public class VehicleActiveService {
* *
* @param departureVo * @param departureVo
*/ */
@Transactional
public void departure(VehicleDepartureVo departureVo) { public void departure(VehicleDepartureVo departureVo) {
Vehicle vehicle = vehicleMapper.selectByPrimaryKey(departureVo.getVehicleId()); try {
if (vehicle == null) { Vehicle vehicle = vehicleMapper.selectByPrimaryKey(departureVo.getVehicleId());
throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getDesc(), if (vehicle == null) {
ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode()); throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getDesc(),
} ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode());
if (StringUtils.isBlank(departureVo.getCheckMan()) || StringUtils.isBlank(departureVo.getCheckManTel())) { }
throw new BaseException(ResCode.CHECKUSER_AND_PHONE_NOT_NULL.getDesc(), if (StringUtils.isBlank(departureVo.getCheckMan()) || StringUtils.isBlank(departureVo.getCheckManTel())) {
ResCode.CHECKUSER_AND_PHONE_NOT_NULL.getCode()); throw new BaseException(ResCode.CHECKUSER_AND_PHONE_NOT_NULL.getDesc(),
} ResCode.CHECKUSER_AND_PHONE_NOT_NULL.getCode());
if (!vehicle.getStatus().equals(VehicleStatus.NORMAL.getCode())) { }
throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getDesc() + ", 车辆状态是:" + getVehicleStatus(vehicle.getStatus(), vehicle.getId()),
ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getCode());
}
//添加出车时间过滤 再出车开始时间前一天至结束时间内可以出车,并且预定记录为已审核状态
checkDateInvalide(departureVo);
Integer MileageLift = vehicle.getMileageLastUpdate();
Integer MileageLift1 = departureVo.getMileage();
if (MileageLift1 == null) {
throw new BaseException(ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getDesc(),
ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getCode());
}
if (MileageLift == null || MileageLift1 >= MileageLift) {
// 写入车辆公里数,预计目的地
vehicle.setMileageLastUpdate(MileageLift1);
vehicle.setExpectDestinationBranchCompanyId(departureVo.getExpectArrivalBranchCompanyId());
vehicleMapper.updateByPrimaryKeySelective(vehicle);
// 修改车辆状态,确认是空闲状态
int result = vehicleMapper.updateStatusByIdAndStatus(departureVo.getVehicleId(), VehicleStatus.DEPARTURE.getCode(),
VehicleStatus.NORMAL.getCode());
if (!vehicle.getStatus().equals(VehicleStatus.NORMAL.getCode())) { if (!vehicle.getStatus().equals(VehicleStatus.NORMAL.getCode())) {
throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getDesc() + ", 车辆状态是:" + getVehicleStatus(vehicle.getStatus(), vehicle.getId()), throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getDesc() + ", 车辆状态是:" + getVehicleStatus(vehicle.getStatus(), vehicle.getId()),
ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getCode()); ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getCode());
} }
//修改预约记录状态 //添加出车时间过滤 再出车开始时间前一天至结束时间内可以出车,并且预定记录为已审核状态
VehicleBookRecord vehicleBookRecord = null; checkDateInvalide(departureVo);
if (departureVo.getBookRecordId() != null) { Integer MileageLift = vehicle.getMileageLastUpdate();
vehicleBookRecord = vehicleBookRecordBiz.selectById(departureVo.getBookRecordId()); Integer MileageLift1 = departureVo.getMileage();
updateBookRecordStatus(vehicleBookRecord, 1); if (MileageLift1 == null) {
throw new BaseException(ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getDesc(),
ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getCode());
} }
VehicleDepartureLogVo vehicleDepartureLogVo = vehicleDepartureLogMapper.selectByBookRecordId(departureVo.getBookRecordId()); if (MileageLift == null || MileageLift1 >= MileageLift) {
if (vehicleDepartureLogVo != null) { // 写入车辆公里数,预计目的地
BeanUtil.copyProperties(departureVo, vehicleDepartureLogVo, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true)); vehicle.setMileageLastUpdate(MileageLift1);
VehicleDepartureLog departureLog = vehicleDepartureLogVo.getVehicleDeparture(vehicleDepartureLogVo); vehicle.setExpectDestinationBranchCompanyId(departureVo.getExpectArrivalBranchCompanyId());
departureLog.setDepartureTime(new Date()); vehicleMapper.updateByPrimaryKeySelective(vehicle);
departureLog.setUpdateTime(new Date());
departureLog.setState(VehicleDepartureState.DEPARTURE.getCode()); // 修改车辆状态,确认是空闲状态
departureLog.setDepartureRemark(departureVo.getRemark()); int result = vehicleMapper.updateStatusByIdAndStatus(departureVo.getVehicleId(), VehicleStatus.DEPARTURE.getCode(),
if (vehicleBookRecord != null) { VehicleStatus.NORMAL.getCode());
departureLog.setDepartureBranchCompanyId(vehicleBookRecord.getLiftCompany());
departureLog.setUse(BookType.getByCode(vehicleBookRecord.getBookType())); if (!vehicle.getStatus().equals(VehicleStatus.NORMAL.getCode())) {
departureLog.setUser(vehicleBookRecord.getVehicleUsername()); throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getDesc() + ", 车辆状态是:" + getVehicleStatus(vehicle.getStatus(), vehicle.getId()),
departureLog.setUserTel(vehicleBookRecord.getVehicleUserPhone()); ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getCode());
} }
vehicleDepartureLogMapper.updateByPrimaryKeySelective(departureLog); //修改预约记录状态
} else { VehicleBookRecord vehicleBookRecord = null;
// 出车记录 if (departureVo.getBookRecordId() != null) {
VehicleDepartureLog departureLog = new VehicleDepartureLog(); vehicleBookRecord = vehicleBookRecordBiz.selectById(departureVo.getBookRecordId());
BeanUtils.copyProperties(departureVo, departureLog); updateBookRecordStatus(vehicleBookRecord, 1);
departureLog.setDepartureTime(new Date()); }
departureLog.setCreateTime(new Date()); VehicleDepartureLogVo vehicleDepartureLogVo = vehicleDepartureLogMapper.selectByBookRecordId(departureVo.getBookRecordId());
departureLog.setMileageStart(departureVo.getMileage()); if (vehicleDepartureLogVo != null) {
departureLog.setState(VehicleDepartureState.DEPARTURE.getCode()); BeanUtil.copyProperties(departureVo, vehicleDepartureLogVo, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
departureLog.setBookRecordId(departureVo.getBookRecordId()); VehicleDepartureLog departureLog = vehicleDepartureLogVo.getVehicleDeparture(vehicleDepartureLogVo);
departureLog.setDepartureRemark(departureVo.getRemark()); departureLog.setDepartureTime(new Date());
if (vehicleBookRecord != null) { departureLog.setUpdateTime(new Date());
departureLog.setDepartureBranchCompanyId(vehicleBookRecord.getLiftCompany()); departureLog.setState(VehicleDepartureState.DEPARTURE.getCode());
departureLog.setUse(BookType.getByCode(vehicleBookRecord.getBookType())); departureLog.setDepartureRemark(departureVo.getRemark());
departureLog.setUser(vehicleBookRecord.getVehicleUsername()); if (vehicleBookRecord != null) {
departureLog.setUserTel(vehicleBookRecord.getVehicleUserPhone()); departureLog.setDepartureBranchCompanyId(vehicleBookRecord.getLiftCompany());
departureLog.setUse(BookType.getByCode(vehicleBookRecord.getBookType()));
departureLog.setUser(vehicleBookRecord.getVehicleUsername());
departureLog.setUserTel(vehicleBookRecord.getVehicleUserPhone());
}
vehicleDepartureLogMapper.updateByPrimaryKeySelective(departureLog);
} else {
// 出车记录
VehicleDepartureLog departureLog = new VehicleDepartureLog();
BeanUtils.copyProperties(departureVo, departureLog);
departureLog.setDepartureTime(new Date());
departureLog.setCreateTime(new Date());
departureLog.setMileageStart(departureVo.getMileage());
departureLog.setState(VehicleDepartureState.DEPARTURE.getCode());
departureLog.setBookRecordId(departureVo.getBookRecordId());
departureLog.setDepartureRemark(departureVo.getRemark());
if (vehicleBookRecord != null) {
departureLog.setDepartureBranchCompanyId(vehicleBookRecord.getLiftCompany());
departureLog.setUse(BookType.getByCode(vehicleBookRecord.getBookType()));
departureLog.setUser(vehicleBookRecord.getVehicleUsername());
departureLog.setUserTel(vehicleBookRecord.getVehicleUserPhone());
}
vehicleDepartureLogMapper.insert(departureLog);
} }
vehicleDepartureLogMapper.insert(departureLog);
}
// 车辆活动日志 // 车辆活动日志
VehicleActiveLog activeLog = new VehicleActiveLog(); VehicleActiveLog activeLog = new VehicleActiveLog();
activeLog.setVehicleId(departureVo.getVehicleId()); activeLog.setVehicleId(departureVo.getVehicleId());
activeLog.setActiveType(VehicleActiveType.Departure.getCode()); activeLog.setActiveType(VehicleActiveType.Departure.getCode());
activeLog.setStartTime(new Date()); activeLog.setStartTime(new Date());
activeLog.setCreateTime(new Date()); activeLog.setCreateTime(new Date());
vehicleActiveLogMapper.insert(activeLog); vehicleActiveLogMapper.insert(activeLog);
} else { } else {
throw new BaseException(ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getDesc(), throw new BaseException(ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getDesc(),
ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getCode()); ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getCode());
}
} catch (Exception e) {
e.printStackTrace();
} }
} }
...@@ -187,115 +191,115 @@ public class VehicleActiveService { ...@@ -187,115 +191,115 @@ public class VehicleActiveService {
return stringBuilder.toString(); return stringBuilder.toString();
} }
@Transactional
public void arrival(VehicleArrivalVo arrivalVo) { public void arrival(VehicleArrivalVo arrivalVo) {
Vehicle vehicle = vehicleMapper.selectByPrimaryKey(arrivalVo.getVehicleId()); try {
if (vehicle == null) { Vehicle vehicle = vehicleMapper.selectByPrimaryKey(arrivalVo.getVehicleId());
throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getDesc(), if (vehicle == null) {
ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode()); throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getDesc(),
} ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode());
if (StringUtils.isBlank(arrivalVo.getRecycleMan()) || StringUtils.isBlank(arrivalVo.getRecycleManTel())) { }
throw new BaseException(ResCode.CHECKUSER_AND_PHONE_NOT_NULL.getDesc(), if (StringUtils.isBlank(arrivalVo.getRecycleMan()) || StringUtils.isBlank(arrivalVo.getRecycleManTel())) {
ResCode.CHECKUSER_AND_PHONE_NOT_NULL.getCode()); throw new BaseException(ResCode.CHECKUSER_AND_PHONE_NOT_NULL.getDesc(),
} ResCode.CHECKUSER_AND_PHONE_NOT_NULL.getCode());
}
// if (!vehicle.getStatus().equals(VehicleStatus.DEPARTURE.getCode())) { // if (!vehicle.getStatus().equals(VehicleStatus.DEPARTURE.getCode())) {
// throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getDesc() + ", 车辆状态是:" + getVehicleStatus(vehicle.getStatus(), vehicle.getId()), // throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getDesc() + ", 车辆状态是:" + getVehicleStatus(vehicle.getStatus(), vehicle.getId()),
// ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getCode()); // ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getCode());
// } // }
Integer Mileagerest = vehicle.getMileageLastUpdate(); Integer Mileagerest = vehicle.getMileageLastUpdate();
Integer Mileagerest1 = arrivalVo.getMileage(); Integer Mileagerest1 = arrivalVo.getMileage();
if (Mileagerest1 == null) { if (Mileagerest1 == null) {
throw new BaseException(ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getDesc(), throw new BaseException(ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getDesc(),
ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getCode()); ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getCode());
}
if (Mileagerest != null && Mileagerest1 >= Mileagerest) {
VehicleBookRecord vehicleBookRecord = null;
if (arrivalVo.getBookRecordId() != null) {
vehicleBookRecord = vehicleBookRecordBiz.selectById(arrivalVo.getBookRecordId());
updateBookRecordStatus(vehicleBookRecord, 2);
} }
if (Mileagerest != null && Mileagerest1 >= Mileagerest) {
VehicleBookRecord vehicleBookRecord = null;
if (arrivalVo.getBookRecordId() != null) {
vehicleBookRecord = vehicleBookRecordBiz.selectById(arrivalVo.getBookRecordId());
updateBookRecordStatus(vehicleBookRecord, 2);
}
// 写入车辆公里数,还车分公司id // 写入车辆公里数,还车分公司id
vehicle.setMileageLastUpdate(Mileagerest1); vehicle.setMileageLastUpdate(Mileagerest1);
if (vehicleBookRecord != null) { if (vehicleBookRecord != null) {
vehicle.setParkBranchCompanyId(vehicleBookRecord.getRetCompany()); vehicle.setParkBranchCompanyId(vehicleBookRecord.getRetCompany());
} }
vehicle.setExpectDestinationBranchCompanyId(0); vehicle.setExpectDestinationBranchCompanyId(0);
vehicleMapper.updateByPrimaryKeySelective(vehicle); vehicleMapper.updateByPrimaryKeySelective(vehicle);
// 出车记录 // 出车记录
VehicleDepartureLogVo departureLogVo = vehicleDepartureLogMapper.selectByBookRecordId(arrivalVo.getBookRecordId()); VehicleDepartureLogVo departureLogVo = vehicleDepartureLogMapper.selectByBookRecordId(arrivalVo.getBookRecordId());
if (departureLogVo == null) { if (departureLogVo == null) {
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());
}
// 修改状态,确认是出车状态
//兼容错误还车流程,先查询,是否有其他出行记录
boolean flag = true;
VehicleDepartureLog departureLog = departureLogVo.getVehicleDeparture(departureLogVo);
List<VehicleDepartureLog> list = vehicleDepartureLogMapper.selectByVehicle(arrivalVo.getVehicleId());
for(VehicleDepartureLog vehicleDepartureLogVo : list) {
if(vehicleDepartureLogVo.getState() != 1 && vehicleDepartureLogVo.getId() > departureLog.getId()) { //后面还有未收车的记录
flag = false;
} }
} // 修改状态,确认是出车状态
if(flag) { //如果此条记录后面还有未收车记录,就不修改车辆状态 //兼容错误还车流程,先查询,是否有其他出行记录
int result = vehicleMapper.updateStatus(arrivalVo.getVehicleId(), VehicleStatus.NORMAL.getCode()); boolean flag = true;
VehicleDepartureLog departureLog = departureLogVo.getVehicleDeparture(departureLogVo);
List<VehicleDepartureLog> list = vehicleDepartureLogMapper.selectByVehicle(arrivalVo.getVehicleId());
for(VehicleDepartureLog vehicleDepartureLogVo : list) {
if(vehicleDepartureLogVo.getState() != 1 && vehicleDepartureLogVo.getId() > departureLog.getId()) { //后面还有未收车的记录
flag = false;
}
}
if(flag) { //如果此条记录后面还有未收车记录,就不修改车辆状态
int result = vehicleMapper.updateStatus(arrivalVo.getVehicleId(), 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());
// } // }
} }
DateTime arrivalDate = new DateTime(vehicleBookRecord.getBookEndDate()); DateTime arrivalDate = new DateTime(vehicleBookRecord.getBookEndDate());
DateTime actualArrivalDate = new DateTime(new Date()); DateTime actualArrivalDate = new DateTime(new Date());
//提前还车处理 //提前还车处理
if (actualArrivalDate.compareTo(arrivalDate) < 0) { //实际还车时间小于预计还车时间,需要释放后面的时间 if (actualArrivalDate.compareTo(arrivalDate) < 0) { //实际还车时间小于预计还车时间,需要释放后面的时间
BookVehicleVO bookVehicleVo = new BookVehicleVO(); BookVehicleVO bookVehicleVo = new BookVehicleVO();
BeanUtils.copyProperties(vehicleBookRecord, bookVehicleVo); BeanUtils.copyProperties(vehicleBookRecord, bookVehicleVo);
bookVehicleVo.setNotCheckTimeLegal(Boolean.TRUE); bookVehicleVo.setNotCheckTimeLegal(Boolean.TRUE);
bookVehicleVo.setBookStartDate(null); bookVehicleVo.setBookStartDate(null);
bookVehicleVo.setBookEndDate(null); bookVehicleVo.setBookEndDate(null);
bookVehicleVo.setUnbookStartDate(actualArrivalDate.toString(DATE_TIME_FORMATTER)); bookVehicleVo.setUnbookStartDate(actualArrivalDate.toString(DATE_TIME_FORMATTER));
bookVehicleVo.setUnbookEndDate(arrivalDate.toString(DATE_TIME_FORMATTER)); bookVehicleVo.setUnbookEndDate(arrivalDate.toString(DATE_TIME_FORMATTER));
try { try {
Boolean hasSuc = vehicleBiz.unbookVehicle(bookVehicleVo); Boolean hasSuc = vehicleBiz.unbookVehicle(bookVehicleVo);
if (!hasSuc) { if (!hasSuc) {
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) {
e.printStackTrace();
} }
} catch (Exception e) {
e.printStackTrace();
} }
} departureLog.setMileageEnd(arrivalVo.getMileage());
departureLog.setMileageEnd(arrivalVo.getMileage()); departureLog.setRecycleMan(arrivalVo.getRecycleMan());
departureLog.setRecycleMan(arrivalVo.getRecycleMan()); departureLog.setRecycleManTel(arrivalVo.getRecycleManTel());
departureLog.setRecycleManTel(arrivalVo.getRecycleManTel()); departureLog.setArrivalBranchCompanyId(arrivalVo.getArrivalBranchCompanyId());
departureLog.setArrivalBranchCompanyId(arrivalVo.getArrivalBranchCompanyId()); departureLog.setUpdateTime(new Date());
departureLog.setUpdateTime(new Date()); departureLog.setArrivalTime(new Date());
departureLog.setArrivalTime(new Date()); departureLog.setState(VehicleDepartureState.END.getCode());
departureLog.setState(VehicleDepartureState.END.getCode()); departureLog.setIllegalPic(arrivalVo.getIllegalPic());
departureLog.setIllegalPic(arrivalVo.getIllegalPic()); departureLog.setIllegalAmount(arrivalVo.getIllegalAmount());
departureLog.setIllegalAmount(arrivalVo.getIllegalAmount()); departureLog.setArrivalPic(arrivalVo.getArrivalPic());
departureLog.setArrivalPic(arrivalVo.getArrivalPic()); departureLog.setArrivalRemark(arrivalVo.getRemark());
departureLog.setArrivalRemark(arrivalVo.getRemark()); if (vehicleBookRecord != null) {
if (vehicleBookRecord != null) { departureLog.setArrivalBranchCompanyId(vehicleBookRecord.getRetCompany());
departureLog.setArrivalBranchCompanyId(vehicleBookRecord.getRetCompany()); }
} vehicleDepartureLogMapper.updateByPrimaryKeySelective(departureLog);
vehicleDepartureLogMapper.updateByPrimaryKeySelective(departureLog); // 车辆活动日志
// 车辆活动日志 VehicleActiveLog activeLog = vehicleActiveLogMapper.selectLastByVehicleId(arrivalVo.getVehicleId());
VehicleActiveLog activeLog = vehicleActiveLogMapper.selectLastByVehicleId(arrivalVo.getVehicleId()); if (activeLog == null) {
if (activeLog == null) { 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()); }
} activeLog.setEndTime(new Date());
activeLog.setEndTime(new Date()); activeLog.setUpdateTime(new Date());
activeLog.setUpdateTime(new Date()); vehicleActiveLogMapper.updateByPrimaryKeySelective(activeLog);
vehicleActiveLogMapper.updateByPrimaryKeySelective(activeLog);
//取消预定时间 bookInfo和bookRecord //取消预定时间 bookInfo和bookRecord
// BookVehicleVO bookVehicleVo = new BookVehicleVO(); // BookVehicleVO bookVehicleVo = new BookVehicleVO();
// BeanUtils.copyProperties(vehicleBookRecord, bookVehicleVo); // BeanUtils.copyProperties(vehicleBookRecord, bookVehicleVo);
// bookVehicleVo.setNotCheckTimeLegal(Boolean.TRUE); // bookVehicleVo.setNotCheckTimeLegal(Boolean.TRUE);
...@@ -311,9 +315,12 @@ public class VehicleActiveService { ...@@ -311,9 +315,12 @@ public class VehicleActiveService {
// } catch ( Exception e) { // } catch ( Exception e) {
// e.printStackTrace(); // e.printStackTrace();
// } // }
} else { } else {
throw new BaseException(ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getDesc(), throw new BaseException(ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getDesc(),
ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getCode()); ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getCode());
}
} catch (Exception e) {
e.printStackTrace();
} }
} }
......
...@@ -21,8 +21,8 @@ public class CompanyController extends BaseController<CompanyBaseBiz> { ...@@ -21,8 +21,8 @@ public class CompanyController extends BaseController<CompanyBaseBiz> {
@ApiOperation("同步分公司信息") @ApiOperation("同步分公司信息")
@PostMapping("synchro") @PostMapping("synchro")
public ObjectRestResponse<String> synchro() { public ObjectRestResponse synchro()throws Exception {
return baseBiz.synchro(); return baseBiz.synchro4();
} }
@ApiOperation("同步分公司地址") @ApiOperation("同步分公司地址")
......
...@@ -46,6 +46,13 @@ ...@@ -46,6 +46,13 @@
</foreach> </foreach>
) > 0 ) > 0
</if> </if>
<if test="notInIds != null">
and vmqc.id not in (
<foreach collection="notInIds.split(',')" item="noIdItem" index="noIdIndex">
#{noIdItem}
</foreach>
)
</if>
ORDER BY vmqc.id ASC ORDER BY vmqc.id ASC
</select> </select>
......
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