Forráskód Böngészése

Merge remote-tracking branch 'origin/master'

yanliming 4 éve
szülő
commit
034de44a0d

+ 45 - 7
common/src/main/java/com/jpsoft/bus/modules/bus/callback/GpsDataCallbackImpl.java

@@ -1,17 +1,12 @@
 package com.jpsoft.bus.modules.bus.callback;
 
 import cn.hutool.core.lang.UUID;
-import com.jpsoft.bus.modules.bus.entity.ShiftInfo;
-import com.jpsoft.bus.modules.bus.service.GpsService;
-import com.jpsoft.bus.modules.bus.service.ShiftInfoService;
+import com.jpsoft.bus.modules.bus.entity.*;
+import com.jpsoft.bus.modules.bus.service.*;
 import com.jpsoft.bus.modules.common.utils.CommonUtil;
 import com.jpsoft.gps.callback.GpsDataCallback;
 import com.jpsoft.gps.utils.GPSUtil;
 import com.jpsoft.bus.config.GpsParamConfig;
-import com.jpsoft.bus.modules.bus.entity.GpsDataInfo;
-import com.jpsoft.bus.modules.bus.entity.VehicleInfo;
-import com.jpsoft.bus.modules.bus.service.GpsDataInfoService;
-import com.jpsoft.bus.modules.bus.service.VehicleInfoService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.joda.time.DateTime;
@@ -36,6 +31,12 @@ public class GpsDataCallbackImpl implements GpsDataCallback {
     @Autowired
     private GpsService gpsService;
 
+    @Autowired
+    private StationInfoService stationInfoService;
+
+    @Autowired
+    private PassengerInfoService passengerInfoService;
+
     @Autowired
     private ShiftInfoService shiftInfoService;
 
@@ -120,6 +121,43 @@ public class GpsDataCallbackImpl implements GpsDataCallback {
                         if (!shiftInfo.getCurrentStationId().equals(stationId)){
                             shiftInfo.setCurrentStationId(stationId);
                             shiftInfoService.update(shiftInfo);
+
+                            //当前站点
+                            StationInfo currentStation = stationInfoService.get(stationId);
+                            //此线路的所有站点
+                            List<StationInfo> stationInfoList = stationInfoService.findByRouteId(shiftInfo.getRouteId());
+
+                            //站点集合大小
+                            int stationSize = stationInfoList.size();
+
+                            int currentStationIndex = stationInfoList.indexOf(currentStation);
+
+
+
+                            //查询乘客表是否有过站的情况
+
+                            List<PassengerInfo> passengerInfoList = passengerInfoService.findByShiftStatusPayStatusNotTicketDown(shiftInfo.getId(),"1","1",stationId);
+                            if (passengerInfoList.size()>0){
+                                for (PassengerInfo passengerInfo : passengerInfoList){
+
+                                    //乘客购票的下车站点
+                                    StationInfo downStation = stationInfoService.get(passengerInfo.getTicketDownStationId());
+                                    int downStationIndex = stationInfoList.indexOf(downStation);
+                                    //按照线路顺行并且当前站点大于乘客购票站点,则过站
+                                    if (shiftInfo.getStartStationId().equals(stationInfoList.get(0).getId()) && currentStationIndex > downStationIndex){
+                                        passengerInfo.setPayStatus("2");
+                                        passengerInfoService.update(passengerInfo);
+                                    }
+
+                                    //按照线路逆行并且当前站点小于乘客购票站点,则过站
+                                    if (!shiftInfo.getStartStationId().equals(stationInfoList.get(0).getId()) && currentStationIndex < downStationIndex){
+                                        passengerInfo.setPayStatus("2");
+                                        passengerInfoService.update(passengerInfo);
+                                    }
+
+
+                                }
+                            }
                         }
                     }
                 }catch (Exception ex){

+ 2 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/dao/PassengerInfoDAO.java

@@ -17,4 +17,6 @@ public interface PassengerInfoDAO {
 	List<PassengerInfo> search(Map<String,Object> searchParams,List<Sort> sortList);
 
     List<PassengerInfo> findByPersonIdShiftIdStatus(Long personId, String shiftId, String status);
+
+    List<PassengerInfo> findByShiftStatusPayStatusNotTicketDown(String shiftId, String status, String payStatus,String ticketDownStationId);
 }

+ 2 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/service/PassengerInfoService.java

@@ -24,4 +24,6 @@ public interface PassengerInfoService {
     void passengerFace(VehicleInfo vehicleInfo, ShiftInfo shiftInfo, String retFileUrl, String recordTime, String stationId,String personId) throws Exception;
 
 	DriverBuyTicketDTO driverBuyTicket(PassengerInfo passengerInfo, String ticketUpStationId, String ticketDownStationId, String ticketType, String goodsTicket, String totalFee, String payName,String paymentId) throws Exception;
+
+    List<PassengerInfo> findByShiftStatusPayStatusNotTicketDown(String shiftId, String status, String payStatus,String ticketDownStationId);
 }

+ 9 - 1
common/src/main/java/com/jpsoft/bus/modules/bus/service/impl/PassengerInfoServiceImpl.java

@@ -201,9 +201,12 @@ public class PassengerInfoServiceImpl implements PassengerInfoService {
 			orderInfo.setPassengerId(passengerInfo.getId());
 			orderInfo.setTicketType(ticketType);
 			orderInfo.setGoodsTicket(new BigDecimal(goodsTicket));
-
 			orderInfoService.insert(orderInfo);
 
+			//乘客购票状态修改
+            passengerInfo.setPayStatus("1");
+            update(passengerInfo);
+
 
 		}else {
 
@@ -245,4 +248,9 @@ public class PassengerInfoServiceImpl implements PassengerInfoService {
 
 		return driverBuyTicketDTO;
 	}
+
+    @Override
+    public List<PassengerInfo> findByShiftStatusPayStatusNotTicketDown(String shiftId, String status, String payStatus,String ticketDownStationId) {
+        return passengerInfoDAO.findByShiftStatusPayStatusNotTicketDown(shiftId,status,payStatus,ticketDownStationId);
+    }
 }

+ 11 - 0
common/src/main/resources/mapper/bus/PassengerInfo.xml

@@ -193,4 +193,15 @@
 			and status_ = #{status}
 		</if>
 	</select>
+
+	<select id="findByShiftStatusPayStatusNotTicketDown" resultMap="PassengerInfoMap">
+		<![CDATA[
+		select  * from bus_passenger_info
+		where del_flag = 0
+		and vehicle_shift_id = #{shiftId}
+		and status_ = #{status}
+		and pay_status = #{payStatus}
+		and ticket_down_station_id <> #{ticketDownStationId}
+		]]>
+	</select>
 </mapper>

+ 26 - 3
web/src/main/java/com/jpsoft/bus/modules/driver/controller/DriverApiController.java

@@ -56,6 +56,9 @@ public class DriverApiController {
     @Autowired
     private PaymentInfoService paymentInfoService;
 
+    @Autowired
+    private CompanyInfoService companyInfoService;
+
     @Autowired
     private ShiftInfoService shiftInfoService;
 
@@ -715,10 +718,30 @@ public class DriverApiController {
                 throw new Exception("当前车辆不存在");
             }
 
+            String paymentId = "";
+            CompanyInfo companyInfo = companyInfoService.get(vehicleInfo.getCompanyId());
             PaymentInfo paymentInfo = paymentInfoService.findByCompanyId(vehicleInfo.getCompanyId());
-            if (paymentInfo == null){
-                throw new Exception("车辆对应公司为配置收款账户");
+            if (paymentInfo != null){
+                paymentId = paymentInfo.getId();
             }
+            else {
+                if ("1".equals(companyInfo.getType())){
+                    throw new Exception("车辆对应公司未配置收款账户");
+                }
+                if (!"1".equals(companyInfo.getType())){
+                    CompanyInfo companyInfo1 = companyInfoService.get(companyInfo.getParentId());
+                    PaymentInfo paymentInfo1 = paymentInfoService.findByCompanyId(companyInfo1.getId());
+                    if (paymentInfo1 != null){
+                        paymentId = paymentInfo1.getId();
+                    }
+
+                }
+            }
+
+            if (StringUtils.isBlank(paymentId)){
+                throw new Exception("对应公司收款账户异常,请核验");
+            }
+
 
             List<ShiftInfo> shiftInfoList = shiftInfoService.findByVehicleIdAndStatus(vehicleInfo.getId(),"1");
             if (shiftInfoList.size() == 0){
@@ -728,7 +751,7 @@ public class DriverApiController {
             PassengerInfo passengerInfo = passengerInfoService.get(id);
 
 
-            DriverBuyTicketDTO driverBuyTicketDTO = passengerInfoService.driverBuyTicket(passengerInfo,ticketUpStationId,ticketDownStationId,ticketType,goodsTicket,totalFee,payName,paymentInfo.getId());
+            DriverBuyTicketDTO driverBuyTicketDTO = passengerInfoService.driverBuyTicket(passengerInfo,ticketUpStationId,ticketDownStationId,ticketType,goodsTicket,totalFee,payName,paymentId);
 
             messageResult.setData(driverBuyTicketDTO);
             messageResult.setResult(true);

+ 6 - 0
web/src/main/java/com/jpsoft/bus/modules/pay/wechat/WxPayController.java

@@ -175,6 +175,12 @@ public class WxPayController {
                         throw new Exception("支付已完成,但未找到此订单号的流水");
                     }
 
+                    mergeOrderInfo.setPayStatus(20);
+                    mergeOrderInfo.setPayName("wechat");
+                    mergeOrderInfo.setTransactionId(params.get("trade_no"));
+                    mergeOrderInfo.setUpdateTime(new Date());
+                    mergeOrderInfoService.update(mergeOrderInfo);
+
                     List<OrderInfo> orderInfoList = orderInfoService.findByMergeOrderId(mergeOrderInfo.getId());
 
                     if (orderInfoList.size()>0){