Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master'

yanliming 4 gadi atpakaļ
vecāks
revīzija
8c0da39c01

+ 14 - 1
common/src/main/java/com/jpsoft/bus/modules/bus/callback/GpsDataCallbackImpl.java

@@ -137,13 +137,17 @@ public class GpsDataCallbackImpl implements GpsDataCallback {
                         ShiftInfo shiftInfo = shiftInfoList.get(0);
                         String stationId = gpsService.getLatelyStation(v.getId());
 
+                        StationInfo currentStation = stationInfoService.get(stationId);
+
+
+
                         //站点发生变化时
                         if (!shiftInfo.getCurrentStationId().equals(stationId)){
                             shiftInfo.setCurrentStationId(stationId);
                             shiftInfoService.update(shiftInfo);
 
                             //当前站点
-                            StationInfo currentStation = stationInfoService.get(stationId);
+                          //  StationInfo currentStation = stationInfoService.get(stationId);
                             //此线路的所有站点
                             List<StationInfo> stationInfoList = stationInfoService.findByRouteId(shiftInfo.getRouteId());
 
@@ -254,6 +258,15 @@ public class GpsDataCallbackImpl implements GpsDataCallback {
                             gpsDataInfo0.setStationId(shiftInfo.getCurrentStationId());
                             gpsDataInfoService.update(gpsDataInfo0);
                         }
+
+                        //判断车辆和当前站点的位置关系
+                        if (gpsService.matchDistance(currentStation,v,50)){
+                            shiftInfo.setCurrentStationStatus("1");
+                            shiftInfoService.update(shiftInfo);
+                        }else {
+                            shiftInfo.setCurrentStationStatus("2");
+                            shiftInfoService.update(shiftInfo);
+                        }
                     }
                 }catch (Exception ex){
                     log.error(ex.getMessage(),ex);

+ 2 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/dto/NearbyShiftDTO.java

@@ -21,5 +21,7 @@ public class NearbyShiftDTO {
 
     private Integer distance;
 
+    private Integer stationNum;
+
     private String licensePlateNumber;
 }

+ 2 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/dto/PassengerDetailDTO.java

@@ -66,4 +66,6 @@ public class PassengerDetailDTO {
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
     @ApiModelProperty(value = "下车时间")
     private Date downTime;
+
+    private String ticketType;
 }

+ 2 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/entity/ShiftInfo.java

@@ -29,6 +29,8 @@ public class ShiftInfo {
     private String startStationId;
     @ApiModelProperty(value = "当前站点")
     private String currentStationId;
+    @ApiModelProperty(value = "车和当前站点的关系(1:站点上,2:站点和站点间)")
+    private String currentStationStatus = "1";
     @ApiModelProperty(value = "状态值(1:进行中,2:结束)")
     private String status;
     @ApiModelProperty(value = "终点站")

+ 3 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/service/GpsService.java

@@ -1,6 +1,7 @@
 package com.jpsoft.bus.modules.bus.service;
 
 import com.jpsoft.bus.modules.bus.dto.StationStatusDTO;
+import com.jpsoft.bus.modules.bus.entity.StationInfo;
 import com.jpsoft.bus.modules.bus.entity.VehicleInfo;
 
 import java.util.Date;
@@ -21,4 +22,6 @@ public interface GpsService {
      * @return
      */
     String getLatelyStation(String id) throws Exception;
+
+    boolean matchDistance(StationInfo stationInfo, VehicleInfo vehicleInfo, int distance);
 }

+ 5 - 1
common/src/main/java/com/jpsoft/bus/modules/bus/service/impl/GpsServiceImpl.java

@@ -304,6 +304,9 @@ public class GpsServiceImpl implements GpsService {
 
         if (shiftInfoList.size() > 0) {
             ShiftInfo shiftInfo = shiftInfoList.get(0);
+
+
+
             RouteInfo routeInfo = routeInfoService.get(shiftInfo.getRouteId());
 
             List<StationInfo> stationInfoList = stationInfoService.findByRouteId(routeInfo.getId());
@@ -374,7 +377,8 @@ public class GpsServiceImpl implements GpsService {
      * @param distance
      * @return
      */
-    private boolean matchDistance(StationInfo stationInfo,VehicleInfo vehicleInfo,int distance){
+    @Override
+    public boolean matchDistance(StationInfo stationInfo,VehicleInfo vehicleInfo,int distance){
         GlobalCoordinates source = new GlobalCoordinates(Double.valueOf(vehicleInfo.getLatitude()), Double.valueOf(vehicleInfo.getLongitude()));
         GlobalCoordinates target = new GlobalCoordinates(Double.valueOf(stationInfo.getLatitude()), Double.valueOf(stationInfo.getLongitude()));
 

+ 2 - 0
common/src/main/java/com/jpsoft/bus/modules/pay/service/impl/AlipayServiceImpl.java

@@ -109,6 +109,7 @@ public class AlipayServiceImpl implements AlipayService {
 
         Integer payStatus = 40;
 
+        MergeOrderInfo mergeOrderInfo = mergeOrderInfoService.get(orderInfo.getMergeOrderId());
 
 
         AlipayClient alipayClient = new DefaultAlipayClient(aliPayConfig.getServiceUrl(), aliPayConfig.getAppId(), aliPayConfig.getPrivateKey(), "json", aliPayConfig.getInputCharset(), aliPayConfig.getZfbPublicKey(), aliPayConfig.getSignType());
@@ -117,6 +118,7 @@ public class AlipayServiceImpl implements AlipayService {
 
         Map<String, Object> maps = new HashMap<>();
         maps.put("trade_no", orderInfo.getTransactionId());
+        maps.put("out_trade_no",mergeOrderInfo.getOutOrderNo());
         maps.put("refund_reason", "正常退款");
         maps.put("refund_amount", orderInfo.getPayFee());
 

+ 15 - 1
common/src/main/java/com/jpsoft/bus/modules/pay/service/impl/WechatServiceImpl.java

@@ -7,6 +7,7 @@ import com.ijpay.wxpay.WxPayApi;
 import com.ijpay.wxpay.model.RefundModel;
 import com.ijpay.wxpay.model.UnifiedOrderModel;
 import com.jpsoft.bus.config.WxJpsoftConfig;
+import com.jpsoft.bus.modules.base.dto.MergeOrderDTO;
 import com.jpsoft.bus.modules.base.entity.MergeOrderInfo;
 import com.jpsoft.bus.modules.base.entity.OrderInfo;
 import com.jpsoft.bus.modules.base.entity.PaymentInfo;
@@ -118,8 +119,20 @@ public class WechatServiceImpl implements WechatService {
 
         Integer payStatus = 40;
 
+        MergeOrderInfo mergeOrderInfo = mergeOrderInfoService.get(orderInfo.getMergeOrderId());
 
-        String totalFee = orderInfo.getTotalFee().multiply(new BigDecimal(100)).setScale(0).toString();
+        List<OrderInfo> orderInfoList = orderInfoService.findByMergeOrderId(mergeOrderInfo.getId());
+        BigDecimal totalDecimal = BigDecimal.ZERO;
+        if (orderInfoList.size()>0){
+            for (OrderInfo orderInfo1 : orderInfoList){
+                if (orderInfo1.getPayStatus() != 10){
+                    totalDecimal = totalDecimal.add(orderInfo1.getPayFee());
+                }
+            }
+        }
+
+
+        String totalFee = totalDecimal.multiply(new BigDecimal(100)).setScale(0).toString();
         String refundFeeStr = orderInfo.getPayFee().multiply(new BigDecimal(100)).setScale(0).toString();
 
 
@@ -129,6 +142,7 @@ public class WechatServiceImpl implements WechatService {
                 .sub_mch_id(wxJpsoftConfig.getSubMchId())
                 .nonce_str(WxPayKit.generateStr())
                 .transaction_id(orderInfo.getTransactionId())
+                .out_trade_no(mergeOrderInfo.getOutOrderNo())
                 .out_refund_no(WxPayKit.generateStr())
                 .total_fee(totalFee)
                 .refund_fee(refundFeeStr)

+ 6 - 1
common/src/main/resources/mapper/bus/ShiftInfo.xml

@@ -10,6 +10,7 @@
 			<result property="routeId" column="route_id" />
 			<result property="startStationId" column="start_station_id" />
 			<result property="currentStationId" column="current_station_id" />
+			<result property="currentStationStatus" column="current_station_status"/>
 			<result property="status" column="status_" />
 			<result property="endStationId" column="end_station_id" />
 			<result property="createBy" column="create_by" />
@@ -33,7 +34,7 @@
 	-->
 	<![CDATA[
 		insert into bus_shift_info
-	    (id_,driver_id,vehicle_id,route_id,start_station_id,current_station_id,status_,end_station_id,create_by,create_time,update_by,update_time,del_flag,finish_time)
+	    (id_,driver_id,vehicle_id,route_id,start_station_id,current_station_id,current_station_status,status_,end_station_id,create_by,create_time,update_by,update_time,del_flag,finish_time)
 		values
 		(
 #{id,jdbcType=VARCHAR}
@@ -42,6 +43,7 @@
 ,#{routeId,jdbcType=VARCHAR}
 ,#{startStationId,jdbcType=VARCHAR}
 ,#{currentStationId,jdbcType=VARCHAR}
+,#{currentStationStatus,jdbcType=VARCHAR}
 ,#{status,jdbcType=VARCHAR}
 ,#{endStationId,jdbcType=VARCHAR}
 ,#{createBy,jdbcType=VARCHAR}
@@ -74,6 +76,9 @@
 				<if test="currentStationId!=null">
 		current_station_id=#{currentStationId,jdbcType=VARCHAR},
 		</if>
+			<if test="currentStationStatus!=null">
+				current_station_status=#{currentStationStatus,jdbcType=VARCHAR},
+			</if>
 				<if test="status!=null">
 		status_=#{status,jdbcType=VARCHAR},
 		</if>

+ 2 - 0
web/src/main/java/com/jpsoft/bus/config/WebMvcConfig.java

@@ -79,6 +79,8 @@ public class WebMvcConfig implements WebMvcConfigurer {
 				.excludePathPatterns("/bus/deviceCmdApi/queryPadLatestVersion")
 				.excludePathPatterns("/mobile/passengerApi/passengerMessageNoReadNum")
 				.excludePathPatterns("/mobile/passengerApi/passengerMessage")
+				.excludePathPatterns("/mobile/passengerApi/mergeInfo")
+				.excludePathPatterns("/mobile/passengerApi/passengerRecordList")
 
 				;
 	}

+ 1 - 0
web/src/main/java/com/jpsoft/bus/modules/driver/controller/DriverApiController.java

@@ -711,6 +711,7 @@ public class DriverApiController {
             passengerDetailDTO.setLocalImageUrl(passengerInfo.getLocalImageUrl());
             passengerDetailDTO.setUpTime(passengerInfo.getUpTime());
             passengerDetailDTO.setUpStationId(passengerInfo.getUpStationId());
+            passengerDetailDTO.setTicketType(passengerInfo.getTicketType());
 
             //上车站点
             StationInfo upStationInfo = stationInfoService.get(passengerInfo.getUpStationId());

+ 63 - 7
web/src/main/java/com/jpsoft/bus/modules/mobile/controller/PassengerApiController.java

@@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil;
 import cn.hutool.crypto.symmetric.DES;
 import cn.hutool.db.sql.Order;
 import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.databind.PropertyMetadata;
 import com.github.pagehelper.Page;
 import com.jpsoft.bus.config.OSSConfig;
 import com.jpsoft.bus.modules.base.dto.MergeOrderDTO;
@@ -348,6 +349,7 @@ public class PassengerApiController {
             map.put("longitude", vehicleInfo.getLongitude());
             map.put("latitude", vehicleInfo.getLatitude());
             map.put("currentStationId", shiftInfo.getCurrentStationId());
+            map.put("currentStationStatus",shiftInfo.getCurrentStationStatus());
             messageResult.setData(map);
             messageResult.setResult(true);
             messageResult.setCode(200);
@@ -1025,6 +1027,7 @@ public class PassengerApiController {
             Map<String,Object> searchParams = new HashMap<>();
             searchParams.put("openId",openId);
             searchParams.put("readStatus",false);
+            searchParams.put("shiftStatus","1");
 
             List<Sort> sortList = new ArrayList<>();
             sortList.add(new Sort("create_time","desc"));
@@ -1055,21 +1058,20 @@ public class PassengerApiController {
     @PostMapping("passengerRecordList")
     @ApiOperation(value = "乘车记录")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "token", value = "令牌", paramType = "form"),
-            @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form")
+            @ApiImplicitParam(name = "openId", value = "openId", paramType = "form")
     })
-    public MessageResult<Map> passengerRecordList(String token, @RequestAttribute String subject,@RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex, @RequestParam(value = "pageSize", defaultValue = "5") int pageSize) {
+    public MessageResult<Map> passengerRecordList(String openId,@RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex, @RequestParam(value = "pageSize", defaultValue = "5") int pageSize) {
         MessageResult<Map> messageResult = new MessageResult<>();
 
         try {
 
-            UserInfo userInfo = userInfoService.get(Long.parseLong(subject));
-            if (userInfo == null){
-                throw new Exception("请先注册信息");
+
+            if (StringUtils.isBlank(openId)){
+                throw new Exception("openId为空");
             }
 
             Map<String,Object> searchParams = new HashMap<>();
-            searchParams.put("openId",userInfo.getOpenId());
+            searchParams.put("openId",openId);
             searchParams.put("payStatus",20);
 
             List<Sort> sortList = new ArrayList<>();
@@ -1288,4 +1290,58 @@ public class PassengerApiController {
         return messageResult;
     }
 
+    @PostMapping("mergeInfo")
+    @ApiOperation(value = "综合账单详情")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "outOrderNo", value = "商户订单号", paramType = "form")
+    })
+    public MessageResult<Map> mergeInfo(String outOrderNo) {
+        MessageResult<Map> messageResult = new MessageResult<>();
+
+        try {
+
+            List<PassengerRecordDTO> list = new ArrayList<>();
+            MergeOrderInfo mergeOrderInfo = mergeOrderInfoService.findByOutOrderNo(outOrderNo);
+            ShiftInfo shiftInfo = shiftInfoService.get(mergeOrderInfo.getVehicleShiftId());
+            if (mergeOrderInfo != null){
+                List<OrderInfo> orderInfoList = orderInfoService.findByMergeOrderId(mergeOrderInfo.getId());
+                if (orderInfoList.size()>0){
+                    for (OrderInfo orderInfo : orderInfoList){
+                        PassengerRecordDTO passengerRecordDTO = new PassengerRecordDTO();
+
+                        //乘客记录
+                        PassengerInfo passengerInfo = passengerInfoService.get(orderInfo.getPassengerId());
+                        passengerRecordDTO.setId(orderInfo.getId());
+                        passengerRecordDTO.setImageUrl(passengerInfo.getImageUrl());
+                        //开始站点
+                        StationInfo startStation = stationInfoService.get(orderInfo.getTicketUpStationId());
+                        //终点站
+                        StationInfo endStation = stationInfoService.get(orderInfo.getTicketDownStationId());
+                        passengerRecordDTO.setStartStation(startStation.getName());
+                        passengerRecordDTO.setEndStation(endStation.getName());
+                        passengerRecordDTO.setTicketType(orderInfo.getTicketType());
+                        passengerRecordDTO.setTicketTypeName(passengerRecordDTO.getTicketTypeName(passengerRecordDTO.getTicketType()));
+                        passengerRecordDTO.setGoodTicket(orderInfo.getGoodsTicket());
+                        passengerRecordDTO.setPayTime(DateUtil.format(orderInfo.getPayTime(),"yyyy-MM-dd HH:mm:ss"));
+                        passengerRecordDTO.setTotalFee(orderInfo.getTotalFee());
+                        list.add(passengerRecordDTO);
+                    }
+                }
+            }
+            Map<String,Object> map = new HashMap<>();
+            map.put("id",shiftInfo.getVehicleId());
+            map.put("list",list);
+
+            messageResult.setData(map);
+            messageResult.setResult(true);
+            messageResult.setCode(200);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
 }

+ 6 - 6
web/src/main/resources/application-dev.yml

@@ -7,14 +7,14 @@ spring:
   datasource:
 
     #开发环境
-     url: jdbc:log4jdbc:mysql://192.168.33.20:3306/smart-bus?autoReconnect=true&characterEncoding=utf8&serverTimezone=GMT%2B8
-     username: root
-     password: jpsoft2016
+#     url: jdbc:log4jdbc:mysql://192.168.33.20:3306/smart-bus?autoReconnect=true&characterEncoding=utf8&serverTimezone=GMT%2B8
+#     username: root
+#     password: jpsoft2016
 
     #测试环境
-#     url: jdbc:log4jdbc:mysql://47.92.161.104:3336/jp_housekeeper_2.0?autoReconnect=true&characterEncoding=utf8&serverTimezone=GMT%2B8
-#     username: root
-#     password: jpsoft8121234
+     url: jdbc:log4jdbc:mysql://47.92.161.104:3336/smart-bus?autoReconnect=true&characterEncoding=utf8&serverTimezone=GMT%2B8
+     username: root
+     password: jpsoft8121234
 
     #正式环境
 #     url: jdbc:log4jdbc:mysql://122.189.98.152:3336/jp_housekeeper?autoReconnect=true&characterEncoding=utf8&serverTimezone=GMT%2B8