From 01fb3942136929b10d1fd704330f9d400b38bfb0 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期四, 23 十月 2025 18:09:19 +0800
Subject: [PATCH] 修改bug
---
UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/shunfeng/controller/rideCommentController.java | 526 +++++++++++++++++++++++++++++++++++-----------------------
1 files changed, 316 insertions(+), 210 deletions(-)
diff --git a/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/shunfeng/controller/rideCommentController.java b/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/shunfeng/controller/rideCommentController.java
index 88e5876..5f1ac22 100644
--- a/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/shunfeng/controller/rideCommentController.java
+++ b/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/shunfeng/controller/rideCommentController.java
@@ -13,14 +13,18 @@
import com.stylefeng.guns.modular.shunfeng.util.OrdersUtil;
import com.stylefeng.guns.modular.shunfeng.util.SensitiveWordUtil;
import com.stylefeng.guns.modular.system.dao.SensitiveWordsMapper;
-import com.stylefeng.guns.modular.system.model.SensitiveWords;
-import com.stylefeng.guns.modular.system.model.UserInfo;
+import com.stylefeng.guns.modular.system.model.*;
+import com.stylefeng.guns.modular.system.service.ICompanyService;
import com.stylefeng.guns.modular.system.service.ISystemNoticeService;
+import com.stylefeng.guns.modular.system.service.ITCarBrandService;
import com.stylefeng.guns.modular.system.service.IUserInfoService;
import com.stylefeng.guns.modular.system.util.DateUtil;
import com.stylefeng.guns.modular.system.util.GDMapElectricFenceUtil;
import com.stylefeng.guns.modular.system.util.PushUtil;
+import com.stylefeng.guns.modular.system.util.ResultUtil;
+import com.stylefeng.guns.modular.system.util.qianyuntong.OrderUtil;
import com.stylefeng.guns.modular.system.util.qianyuntong.UserUtil;
+import com.stylefeng.guns.modular.system.util.qianyuntong.model.*;
import io.swagger.annotations.*;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@@ -32,6 +36,7 @@
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
+import java.math.BigDecimal;
import java.util.*;
/**
@@ -50,9 +55,6 @@
/*顺风车设置*/
@Autowired
private IParamRideService paramRideService;
- /*系统设置*/
- @Autowired
- private IParamService paramService;
/*定时任务*/
@Autowired
private ITimeTaskService timeTaskService;
@@ -61,7 +63,7 @@
private IDriverRideService driverRideService;
/*顺风车品牌*/
@Autowired
- private IBrandService brandService;
+ private ITCarBrandService carBrandService;
/*评价*/
@Autowired
private IEvaluateService evaluateService;
@@ -88,6 +90,12 @@
@Autowired
private IFinancialService financialService;
+
+ @Autowired
+ private ICompanyService companyService;
+
+ @Autowired
+ private IOrderInvitationService orderInvitationService;
@@ -111,7 +119,7 @@
public Object authentication(Integer userId,String name,String identity,Integer type) {
try {
if (userId == null || userId == 0) {
- return ApiJson.returnNG("userId不能为空");
+ return ResultUtil.paranErr("userId不能为空");
}
/*发布顺风车行程实名认证*/
UserApply apply=new UserApply();
@@ -129,6 +137,7 @@
/*修改用户实名认证通过*/
UserInfo userInfo=new UserInfo();
userInfo.setId(userId);
+ userInfo.setIsAuth(2);
String sex = identity.substring(16, 17); //取指定位置的值(16位之后,17位结束;)
int b = Integer.parseInt(sex);//强制类型转换
if (b % 2 == 0) {
@@ -145,11 +154,11 @@
applyService.insert(apply);
Map<String,Object> reMap=new HashMap<>();
reMap.put("auditState", aBoolean);
- return ApiJson.returnOK(reMap);
+ return ResultUtil.success(reMap);
} catch (Exception e) {
e.printStackTrace();
}
- return ApiJson.returnNG("异常");
+ return ResultUtil.error("异常");
}
/**
@@ -164,7 +173,7 @@
public Object authentication(Integer userId,String headImg) {
// try {
// if (userId == null || userId == 0) {
-// return ApiJson.returnNG("userId不能为空");
+// return ResultUtil.paranErr("userId不能为空");
// }
// /*查询实名认证信息*/
// UserApply apply=applyService.selectOne(new EntityWrapper<UserApply>().eq("userId",userId)
@@ -202,7 +211,7 @@
// } catch (Exception e) {
// e.printStackTrace();
// }
- return ApiJson.returnNG("异常");
+ return ResultUtil.paranErr("异常");
}
/**
@@ -214,12 +223,12 @@
@ApiOperation(value = "获取车辆品牌列表", httpMethod = "GET")
public Object getBrandList(){
try {
- List<Brand> brands=brandService.selectList(null);
- return ApiJson.returnOK(brands);
+ List<TCarBrand> tCarBrands = carBrandService.selectList(null);
+ return ApiJson.returnOK(tCarBrands);
} catch (Exception e) {
e.printStackTrace();
}
- return ApiJson.returnNG("异常");
+ return ResultUtil.error("异常");
}
/**
@@ -238,10 +247,10 @@
public Object homeOrderCount(Integer userId,Integer type){
try {
if(ToolUtil.isEmpty(userId)){
- return ApiJson.returnNG("userId不能为空");
+ return ResultUtil.paranErr("userId不能为空");
}
if(ToolUtil.isEmpty(type)){
- return ApiJson.returnNG("type不能为空");
+ return ResultUtil.paranErr("type不能为空");
}
Integer count=0;
@@ -260,7 +269,7 @@
} catch (Exception e) {
e.printStackTrace();
}
- return ApiJson.returnNG("获取异常");
+ return ResultUtil.error("获取异常");
}
/**
@@ -279,10 +288,10 @@
public Object homeOrderList(Integer userId,Integer type,Integer current,Integer size){
try {
if(ToolUtil.isEmpty(userId)){
- return ApiJson.returnNG("userId不能为空");
+ return ResultUtil.paranErr("userId不能为空");
}
if(ToolUtil.isEmpty(type)){
- return ApiJson.returnNG("type不能为空");
+ return ResultUtil.paranErr("type不能为空");
}
List<OrderRideVo> rideVoList=new ArrayList<>();
OrderRideVo orderRideVo=new OrderRideVo();
@@ -305,7 +314,7 @@
} catch (Exception e) {
e.printStackTrace();
}
- return ApiJson.returnNG("获取异常");
+ return ResultUtil.error("获取异常");
}
/**
@@ -366,7 +375,7 @@
} catch (Exception e) {
e.printStackTrace();
}
- return ApiJson.returnNG("获取异常");
+ return ResultUtil.error("获取异常");
}
/**
@@ -401,22 +410,22 @@
String endName,Double money,Integer isDai,String lxPhone){
try {
if(ToolUtil.isEmpty(userId)){
- return ApiJson.returnNG("userId不能为空");
+ return ResultUtil.paranErr("userId不能为空");
}
if(ToolUtil.isEmpty(startTime)){
- return ApiJson.returnNG("startTime不能为空");
+ return ResultUtil.paranErr("startTime不能为空");
}
if(ToolUtil.isEmpty(num)){
- return ApiJson.returnNG("num不能为空");
+ return ResultUtil.paranErr("num不能为空");
}
if(ToolUtil.isEmpty(startName)){
- return ApiJson.returnNG("startName不能为空");
+ return ResultUtil.paranErr("startName不能为空");
}
if(ToolUtil.isEmpty(endName)){
- return ApiJson.returnNG("endName不能为空");
+ return ResultUtil.paranErr("endName不能为空");
}
if(ToolUtil.isEmpty(money)){
- return ApiJson.returnNG("money不能为空");
+ return ResultUtil.paranErr("money不能为空");
}
/*用户只能发布一个进行中的行程*/
/*EntityWrapper<OrderRide> entityWrapper=new EntityWrapper();
@@ -424,7 +433,7 @@
entityWrapper.in("state","1,2,3,4");
Integer count=orderRideService.selectCount(entityWrapper);
if(count>0){
- return ApiJson.returnNG("还有进行中的订单");
+ return ResultUtil.paranErr("还有进行中的订单");
}*/
/*用户可以发布多个订单*/
ParamRide paramRide=paramRideService.selectOne(new EntityWrapper<ParamRide>().eq("type",2));
@@ -455,15 +464,9 @@
orderRide.setState(1);//未支付状态
orderRideService.insert(orderRide);
//todo 定时人数 自动取消订单
- Param param = paramService.selectOne(new EntityWrapper<Param>().eq("type", 21));//顺风车支付倒计时设置(分钟)
Integer time =10;
Map<String,Object> reMap=new HashMap<>();
- if(param != null){
- time=Integer.parseInt(param.getContext());
- reMap.put("djs",time);
- }else{
- reMap.put("djs",time);
- }
+ reMap.put("djs",time);
reMap.put("orderId",orderRide.getId());
reMap.put("addTime",orderRide.getAddTime());
// 添加定时任务信息
@@ -479,11 +482,11 @@
maps.put("orderId",orderRide.getId());
maps.put("timeTaskId",timeTask.getId());
QuartzManager.addJob(CourseExamineRide.class,(CourseExamineRide.DSCE+orderRide.getId()).toUpperCase(), TimeJobType.UNLOCK, DateUtil.getDate_strYMdHms(System.currentTimeMillis() + 1000*60*time) , maps);
- return ApiJson.returnOK(orderRide.getId());
+ return ResultUtil.success(orderRide.getId());
} catch (Exception e) {
e.printStackTrace();
}
- return ApiJson.returnNG("异常");
+ return ResultUtil.error("异常");
}
/**
@@ -512,19 +515,19 @@
public Object driverAddTravel(Integer driverId,String startTime,Integer num,String startName,String endName,Double startLat,Double startLon,Double endLat,Double endLon){
try {
if(ToolUtil.isEmpty(driverId)){
- return ApiJson.returnNG("driverId不能为空");
+ return ResultUtil.paranErr("driverId不能为空");
}
if(ToolUtil.isEmpty(startTime)){
- return ApiJson.returnNG("startTime不能为空");
+ return ResultUtil.paranErr("startTime不能为空");
}
if(ToolUtil.isEmpty(num)){
- return ApiJson.returnNG("num不能为空");
+ return ResultUtil.paranErr("num不能为空");
}
if(ToolUtil.isEmpty(startName)){
- return ApiJson.returnNG("startName不能为空");
+ return ResultUtil.paranErr("startName不能为空");
}
if(ToolUtil.isEmpty(endName)){
- return ApiJson.returnNG("endName不能为空");
+ return ResultUtil.paranErr("endName不能为空");
}
/*用户的资料过期了不可以发布行程*/
DriverRide driverRide=driverRideService.selectById(driverId);
@@ -535,7 +538,7 @@
|| DateUtil.getDate(driverRide.getDutyInsuranceTime(), "yyyy-MM-dd").getTime()-new Date().getTime()<0
|| DateUtil.getDate(driverRide.getAnnualInspectionTime(), "yyyy-MM-dd").getTime()-new Date().getTime()<0
){
- return ApiJson.returnNG("您的证件已过期,请重新上传资料");
+ return ResultUtil.error("您的证件已过期,请重新上传资料");
}
}
/*1一个司机可以创建多个行程*/
@@ -560,7 +563,7 @@
} catch (Exception e) {
e.printStackTrace();
}
- return ApiJson.returnNG("异常");
+ return ResultUtil.error("异常");
}
@@ -607,51 +610,52 @@
String businessInsuranceTime,String businessInsuranceImg,String dutyInsuranceTime,String dutyInsuranceImg,String annualInspectionTime,String annualInspectionImg){
try {
if(ToolUtil.isEmpty(userId)){
- return ApiJson.returnNG("userId不能为空");
+ return ResultUtil.paranErr("userId不能为空");
}
if(ToolUtil.isEmpty(carType)){
- return ApiJson.returnNG("carType不能为空");
+ return ResultUtil.paranErr("carType不能为空");
}
if(ToolUtil.isEmpty(brandId)){
- return ApiJson.returnNG("brandId不能为空");
+ return ResultUtil.paranErr("brandId不能为空");
}
if(ToolUtil.isEmpty(carNum)){
- return ApiJson.returnNG("carNum不能为空");
+ return ResultUtil.paranErr("carNum不能为空");
}
if(ToolUtil.isEmpty(license)){
- return ApiJson.returnNG("license不能为空");
+ return ResultUtil.paranErr("license不能为空");
}
if(ToolUtil.isEmpty(licenseImg)){
- return ApiJson.returnNG("licenseImg不能为空");
+ return ResultUtil.paranErr("licenseImg不能为空");
}
if(ToolUtil.isEmpty(comInsuranceTime)){
- return ApiJson.returnNG("comInsuranceTime不能为空");
+ return ResultUtil.paranErr("comInsuranceTime不能为空");
}
if(ToolUtil.isEmpty(comInsuranceImg)){
- return ApiJson.returnNG("comInsuranceImg不能为空");
+ return ResultUtil.paranErr("comInsuranceImg不能为空");
}
if(ToolUtil.isEmpty(businessInsuranceTime)){
- return ApiJson.returnNG("businessInsuranceTime不能为空");
+ return ResultUtil.paranErr("businessInsuranceTime不能为空");
}
if(ToolUtil.isEmpty(businessInsuranceImg)){
- return ApiJson.returnNG("businessInsuranceImg不能为空");
+ return ResultUtil.paranErr("businessInsuranceImg不能为空");
}
if(ToolUtil.isEmpty(dutyInsuranceTime)){
- return ApiJson.returnNG("dutyInsuranceTime不能为空");
+ return ResultUtil.paranErr("dutyInsuranceTime不能为空");
}
if(ToolUtil.isEmpty(dutyInsuranceImg)){
- return ApiJson.returnNG("dutyInsuranceImg不能为空");
+ return ResultUtil.paranErr("dutyInsuranceImg不能为空");
}
if(ToolUtil.isEmpty(annualInspectionTime)){
- return ApiJson.returnNG("annualInspectionTime不能为空");
+ return ResultUtil.paranErr("annualInspectionTime不能为空");
}
if(ToolUtil.isEmpty(annualInspectionImg)){
- return ApiJson.returnNG("annualInspectionImg不能为空");
+ return ResultUtil.paranErr("annualInspectionImg不能为空");
}
DriverRide driverRide=new DriverRide();
driverRide.setBrandId(brandId);
driverRide.setUserId(userId);
driverRide.setByInviteCode(inviteCodeRide);
+ driverRide.setCompanyId(1);
driverRide.setCarType(carType);
driverRide.setCarNum(carNum);
driverRide.setLicense(license);
@@ -710,7 +714,7 @@
} catch (Exception e) {
e.printStackTrace();
}
- return ApiJson.returnNG("异常");
+ return ResultUtil.error("异常");
}
/**
@@ -724,19 +728,19 @@
public Object driverInfo(Integer driverId){
try {
if(ToolUtil.isEmpty(driverId)){
- return ApiJson.returnNG("driverId不能为空");
+ return ResultUtil.paranErr("driverId不能为空");
}
DriverRide driverRide=driverRideService.selectById(driverId);
/*获取司机品牌id*/
- Brand b=brandService.selectById(driverRide.getBrandId());
- if(b!=null){
- driverRide.setCarType(b.getName());
+ TCarBrand tCarBrand = carBrandService.selectById(driverRide.getBrandId());
+ if(tCarBrand!=null){
+ driverRide.setCarType(tCarBrand.getName());
}
return ApiJson.returnOK(driverRide);
} catch (Exception e) {
e.printStackTrace();
}
- return ApiJson.returnNG("异常");
+ return ResultUtil.error("异常");
}
/**
@@ -755,10 +759,10 @@
public Object cancelServiceMoney(Integer orderId,Integer type){
try {
if(ToolUtil.isEmpty(orderId)){
- return ApiJson.returnNG("orderId不能为空");
+ return ResultUtil.paranErr("orderId不能为空");
}
if(ToolUtil.isEmpty(type)){
- return ApiJson.returnNG("type不能为空");
+ return ResultUtil.paranErr("type不能为空");
}
Double serviceMoney=0d;
if(type==1){//用户
@@ -800,11 +804,11 @@
}
orderTravelService.updateById(orderTravel);//更新取消服务费
}
- return ApiJson.returnOK(serviceMoney);
+ return ResultUtil.success(serviceMoney);
} catch (Exception e) {
e.printStackTrace();
}
- return ApiJson.returnNG("异常");
+ return ResultUtil.error("异常");
}
/**
@@ -819,14 +823,14 @@
public Object userCancel(Integer orderId){
try {
if(ToolUtil.isEmpty(orderId)){
- return ApiJson.returnNG("orderId不能为空");
+ return ResultUtil.paranErr("orderId不能为空");
}
/*查看这个订单是否在进行中*/
OrderRide orderRide=orderRideService.selectById(orderId);
if(orderRide!=null){
/*查询该订单是否已经取消*/
if(orderRide.getState()==6){
- return ApiJson.returnNG("该订单已取消");
+ return ResultUtil.error("该订单已取消");
}
//用户取消给司机推送
if(orderRide.getDriverId()!=null) {
@@ -844,30 +848,85 @@
orderTravelService.updateById(orderTravel);
}
}
- return ApiJson.returnOK("");
+ return ResultUtil.success("");
} catch (Exception e) {
e.printStackTrace();
}
- return ApiJson.returnNG("异常");
+ return ResultUtil.error("异常");
}
+
+
+ private Integer getState(Integer state){
+ switch (state){
+ case 1:
+ return 7;
+ case 2:
+ return 1;
+ case 3:
+ return 4;
+ case 4:
+ return 5;
+ case 5:
+ return 8;
+ case 6:
+ return 10;
+ }
+ return null;
+ }
+
+
+
//用户取消退款
public void userCancelTuik(OrderRide orderRide){
+ UserInfo userInfo=userInfoService.selectById(orderRide.getUserId());
+ //查询三方判断订单是否完成支付
+ getPaymentStatus(userInfo, orderRide);
if(orderRide.getState()==2){//用户已经支付了订单但司机没有接单
orderRide.setTuiMoney(orderRide.getMoney());
}
- if(orderRide.getTuiMoney()>0){
+ if(null != orderRide.getTuiMoney() && orderRide.getTuiMoney()>0){
Financial financial= financialService.selectOne(new EntityWrapper<Financial>().eq("orderNum",orderRide.getOrderNum()));
String finNum=OrdersUtil.getOrderNoForPrefix("fin");
//todo 退款金额大于0需要退款
if(orderRide.getPayType()==1){//余额
- UserInfo userInfo=userInfoService.selectById(orderRide.getUserId());
userInfo.setBalance(userInfo.getBalance()+orderRide.getTuiMoney());
userInfoService.updateById(userInfo);
}else if(orderRide.getPayType()==2){
//微信
Integer money = new Double(orderRide.getMoney() * 100).intValue();
- Integer tMoney_ = new Double(orderRide.getTuiMoney()* 100).intValue();
- PayUtil.refundForWxpay(1, financial.getLsType(), orderRide.getOrderNum(), finNum, money,tMoney_ , "2");
+// Integer tMoney_ = new Double(orderRide.getTuiMoney()* 100).intValue();
+// PayUtil.refundForWxpay(1, financial.getLsType(), orderRide.getOrderNum(), finNum, money,tMoney_ , "2");
+
+ //中台订单退款操作
+ if(ToolUtil.isNotEmpty(orderRide.getZttravelId())){
+ TradeOrderRefundRequest request = new TradeOrderRefundRequest();
+ request.setPartnerPayId(orderRide.getZttravelId());
+ request.setPayId(financial.getLsType());
+ request.setRefundTotalFee(money + "");
+ request.setRemark("顺风车订单取消退款");
+ request.setRefundType("RF");
+
+ RefundInfoRequest refundInfo = new RefundInfoRequest();
+ refundInfo.setPayItemId(orderRide.getZttravelId());
+ refundInfo.setPayId(financial.getLsType());
+ refundInfo.setTradeFee(money + "");
+ request.setRefundInfos(new ArrayList<RefundInfoRequest>(){{
+ add(refundInfo);
+ }});
+ TradeOrderRefund tradeOrderRefund = OrderUtil.tradeOrderRefund(request);
+ //退款通知
+ OrderRefundNoticeRequest request2 = new OrderRefundNoticeRequest();
+ request2.setOrderId(orderRide.getZttravelId());
+ request2.setRefundPayNum(tradeOrderRefund.getRefundId());
+ request2.setRefundType("5");
+ request2.setApplyRefundCharge(BigDecimal.valueOf(orderRide.getMoney()));
+ request2.setActualRefundCharge(BigDecimal.valueOf(orderRide.getMoney()));
+ request2.setRefundAccount(userInfo.getOnconUUID());
+ request2.setRemark("顺风车订单取消退款");
+ OrderUtil.orderRefundNotice(request2);
+ }
+
+
}else if(orderRide.getPayType()==3){
}
@@ -883,6 +942,11 @@
f.setOrderType(4);
f.setLx(1);
financialService.insert(f);
+ }else{
+ //未支付的情况取消订单
+ if(ToolUtil.isNotEmpty(orderRide.getZttravelId())){
+ OrderUtil.tradeOrderCancel(orderRide.getZttravelId());
+ }
}
/*添加系统消息*/
try {
@@ -893,6 +957,51 @@
orderRide.setState(6);//取消状态
orderRideService.updateById(orderRide);
}
+
+
+
+ public void getPaymentStatus(UserInfo userInfo, OrderRide orderRide1){
+ GetTravelItineraryListRequest request1 = new GetTravelItineraryListRequest();
+ request1.setCustomerId(userInfo.getOnconUUID());
+ request1.setOrderNo("SF" + orderRide1.getId());
+ ListPage<List<TravelItinerary>> travelItineraryList = OrderUtil.getTravelItineraryList(request1);
+ TravelItinerary travelItinerary = travelItineraryList.getList().get(0);
+ if(travelItinerary.getStatus() != 7 || Arrays.asList(3, 11).contains(travelItinerary.getOrderStatus())){
+ GetPaymentInfoDataRequest getPaymentInfoDataRequest1 = new GetPaymentInfoDataRequest();
+ getPaymentInfoDataRequest1.setPartnerPayId(orderRide1.getZttravelId());
+ GetPaymentInfo getPaymentInfo1 = OrderUtil.paymentInfo(getPaymentInfoDataRequest1);
+
+ String trade_no = getPaymentInfo1.getPayId();
+ Financial financial = new Financial();
+ financial.setType(1);//类型 1=收入 2=支出
+ financial.setPayType("2");//支付类型 1=余额 2=微信 3=支付宝
+ financial.setMoney(orderRide1.getMoney());//支付金额
+ financial.setOrderNum(orderRide1.getOrderNum());//我们本地的订单号
+ financial.setLsType(trade_no);//流水号
+ financial.setAddTime(new Date());
+ financial.setTradeStatus("success");
+ //顺风车支付
+ //修改订单表中的订单流水和支付方式
+ orderRide1.setOutNum(financial.getLsType());//流水
+ orderRide1.setPayTime(new Date());
+ orderRide1.setPayType(2);
+ orderRide1.setState(2);
+ financial.setPwType(8);//顺风车
+ financial.setUserId(orderRide1.getUserId());
+ financial.setLx(1);//1=用户 2=司机
+ financial.setOrderType(4);//顺风车
+ financialService.insert(financial);
+ orderRideService.updateById(orderRide1);
+ /*添加系统消息*/
+ try {
+ systemNoticeService.addSystemNotice(1, "您成功支付从" + orderRide1.getStartName() + "到" + orderRide1.getEndName() + "的顺风车订单", orderRide1.getUserId(), 1);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+
/**
* 司机行程取消
* @param orderId
@@ -905,67 +1014,68 @@
public Object driverCancel(Integer orderId){
try {
if(ToolUtil.isEmpty(orderId)){
- return ApiJson.returnNG("orderId不能为空");
+ return ResultUtil.paranErr("orderId不能为空");
}
OrderTravel orderTravel=orderTravelService.selectById(orderId);
- if(orderTravel!=null){
- if(orderTravel.getState()==6){
- return ApiJson.returnNG("该订单已取消");
+ if(null == orderTravel){
+ return ResultUtil.error("无效的订单ID");
+ }
+ if(orderTravel.getState()==6){
+ return ResultUtil.error("该订单已取消");
+ }
+ DriverRide driverRide=driverRideService.selectById(orderTravel.getDriverId());
+ if(orderTravel.getServiceMoney()!=null && orderTravel.getServiceMoney()>0){
+ /*todo 更新司机余额*/
+ driverRide.setBalance(driverRide.getBalance()-orderTravel.getServiceMoney());
+ driverRideService.updateById(driverRide);
+ /* 更新司机用户余额(用户和司机用户一个账号余额)*/
+ UserInfo userInfo=userInfoService.selectOne(new EntityWrapper<UserInfo>().eq("driverId",orderTravel.getDriverId()));
+ if(userInfo!=null){
+ //用户余额可以为负数
+ userInfo.setBalance(userInfo.getBalance()-orderTravel.getServiceMoney());
+ userInfoService.updateById(userInfo);
}
- DriverRide driverRide=driverRideService.selectById(orderTravel.getDriverId());
- if(orderTravel.getServiceMoney()!=null && orderTravel.getServiceMoney()>0){
- /*todo 更新司机余额*/
- driverRide.setBalance(driverRide.getBalance()-orderTravel.getServiceMoney());
- driverRideService.updateById(driverRide);
- /* 更新司机用户余额(用户和司机用户一个账号余额)*/
- UserInfo userInfo=userInfoService.selectOne(new EntityWrapper<UserInfo>().eq("driverId",orderTravel.getDriverId()));
- if(userInfo!=null){
- //用户余额可以为负数
- userInfo.setBalance(userInfo.getBalance()-orderTravel.getServiceMoney());
- userInfoService.updateById(userInfo);
- }
- /*财务明细*/
- Financial f=new Financial();
- f.setAddTime(new Date());
- f.setType(1);//类型 1=收入 2=支出
- f.setMoney(orderTravel.getServiceMoney());
- f.setPwType(9);//9=顺风车取消服务费
- f.setOrderNum(orderTravel.getOrderNum());
- String finNum=OrdersUtil.getOrderNoForPrefix("fin");
- f.setLsType(finNum);
- f.setUserId(driverRide.getUserId());
- f.setOrderType(4);
- f.setLx(1);
- financialService.insert(f);
- //司机取消给用户推送
- }
- /*添加系统消息*/
- try {
- systemNoticeService.addSystemNotice(1, "您从"+orderTravel.getStartName()+"到"+orderTravel.getEndName()+"的顺风车行程已取消", driverRide.getUserId(), 1);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- orderTravel.setState(6);//取消状态
- orderTravelService.updateById(orderTravel);
- //todo 推送
- /*司机接单给用户发送消息*/
- OrderRide orderRide=orderRideService.selectOne(new EntityWrapper<OrderRide>().eq("travelId",orderId));
- if(orderRide!=null) {
- pushUtil.pushOrderState(1, orderRide.getUserId(), orderRide.getId(), 8, 6, null);
- }
- //取消乘客订单
- if(orderRide!=null && orderRide.getState()!=6){
- orderRide.setTuiMoney(orderRide.getMoney());
- orderRideService.updateById(orderRide);
- userCancelTuik(orderRide);
- }
+ /*财务明细*/
+ Financial f=new Financial();
+ f.setAddTime(new Date());
+ f.setType(1);//类型 1=收入 2=支出
+ f.setMoney(orderTravel.getServiceMoney());
+ f.setPwType(9);//9=顺风车取消服务费
+ f.setOrderNum(orderTravel.getOrderNum());
+ String finNum=OrdersUtil.getOrderNoForPrefix("fin");
+ f.setLsType(finNum);
+ f.setUserId(driverRide.getUserId());
+ f.setOrderType(4);
+ f.setLx(1);
+ financialService.insert(f);
+ //司机取消给用户推送
+ }
+ /*添加系统消息*/
+ try {
+ systemNoticeService.addSystemNotice(1, "您从"+orderTravel.getStartName()+"到"+orderTravel.getEndName()+"的顺风车行程已取消", driverRide.getUserId(), 1);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ orderTravel.setState(6);//取消状态
+ orderTravelService.updateById(orderTravel);
+ //todo 推送
+ /*司机接单给用户发送消息*/
+ OrderRide orderRide=orderRideService.selectOne(new EntityWrapper<OrderRide>().eq("travelId",orderId));
+ if(orderRide!=null) {
+ pushUtil.pushOrderState(1, orderRide.getUserId(), orderRide.getId(), 8, 6, null);
+ }
+ //取消乘客订单
+ if(orderRide!=null && orderRide.getState()!=6){
+ orderRide.setTuiMoney(orderRide.getMoney());
+ orderRideService.updateById(orderRide);
+ userCancelTuik(orderRide);
}
- return ApiJson.returnOK("");
+ return ResultUtil.success("");
} catch (Exception e) {
e.printStackTrace();
}
- return ApiJson.returnNG("异常");
+ return ResultUtil.error("异常");
}
/**
@@ -986,10 +1096,10 @@
public Object driverOperation(Integer userOrderId,Integer type,Integer driverOrderId){
try {
if(ToolUtil.isEmpty(driverOrderId)){
- return ApiJson.returnNG("driverOrderId不能为空");
+ return ResultUtil.paranErr("driverOrderId不能为空");
}
if(ToolUtil.isEmpty(type)){
- return ApiJson.returnNG("type不能为空");
+ return ResultUtil.paranErr("type不能为空");
}
OrderTravel orderTravel=orderTravelService.selectById(driverOrderId);//司机行程
/*用户的资料过期了不可以发布行程*/
@@ -1000,17 +1110,18 @@
|| DateUtil.getDate(driverRide.getDutyInsuranceTime(), "yyyy-MM-dd").getTime()-new Date().getTime()<0
|| DateUtil.getDate(driverRide.getAnnualInspectionTime(), "yyyy-MM-dd").getTime()-new Date().getTime()<0
){
- return ApiJson.returnNG("您的证件已过期,请重新上传资料");
+ return ResultUtil.error("您的证件已过期,请重新上传资料");
}
}
OrderRide orderRide=orderRideService.selectById(userOrderId);
if(orderRide!=null && orderRide.getState()==6){
- return ApiJson.returnNG("用户已取消该行程");
+ return ResultUtil.error("用户已取消该行程");
}
+ UserInfo userInfo=userInfoService.selectById(driverRide.getUserId());
if(orderTravel!=null){
if(type==1){//1确认同行 一个行程只能匹配一个订单
if(orderTravel.getState()==3){
- return ApiJson.returnNG("该行程已经绑定了用户订单");
+ return ResultUtil.error("该行程已经绑定了用户订单");
}
orderTravel.setState(3);
//绑定司机行程、设置用户订单状态
@@ -1027,8 +1138,9 @@
driverRide.setTotalOrders(driverRide.getTotalOrders()+1);
driverRideService.updateById(driverRide);
/*修改用户接单数和司机提成*/
- UserInfo userInfo=userInfoService.selectById(driverRide.getUserId());
+
userInfo.setBalance(userInfo.getBalance()+(orderRide.getMoney()-orderRide.getPlatformMoney()));
+ userInfo.setTotalOrders(userInfo.getTotalOrders() + 1);
userInfoService.updateById(userInfo);
Financial f=new Financial();
f.setAddTime(new Date());
@@ -1045,11 +1157,7 @@
if(ToolUtil.isNotEmpty(driverRide.getByInviteCode())){
/*计算推广用户的提成*/
UserInfo userInfo1=userInfoService.selectOne(new EntityWrapper<UserInfo>().eq("inviteCodeRide",driverRide.getByInviteCode()));
- Param param=paramService.selectOne(new EntityWrapper<Param>().eq("type",22));
Double discount=100d;
- if(param!=null){
- discount=Double.valueOf(param.getContext());
- }
Double money=orderRide.getMoney()*discount/100;//提成金额
userInfoService.updateById(userInfo1);
@@ -1078,12 +1186,24 @@
throw new RuntimeException(e);
}
}
+
+ if(null != orderRide.getZttravelId()){
+ //中台修改订单状态
+ ModifyTravelItineraryRequest request = new ModifyTravelItineraryRequest();
+ request.setOrderId(orderRide.getZttravelId());
+ request.setStatus(getState(orderRide.getState()));
+ if (null != orderRide.getDriverId()) {
+ request.setDriverId(driverRide.getEmpId().toString());
+ }
+ OrderUtil.modifyTravelItinerary(request);
+ }
+
pushUtil.pushOrderState(1, orderRide.getUserId(), orderRide.getId(), 8, orderRide.getState(), null);
- return ApiJson.returnOK("");
+ return ResultUtil.success("");
} catch (Exception e) {
e.printStackTrace();
}
- return ApiJson.returnNG("异常");
+ return ResultUtil.error("异常");
}
/**
* 用户评价
@@ -1107,16 +1227,16 @@
public Object evaluate(Integer orderId,Integer driverId,Integer userId,Integer score,String content){
try {
if(userId == null || userId == 0){
- return ApiJson.returnNG("userId不能为空");
+ return ResultUtil.paranErr("userId不能为空");
}
if(driverId == null || driverId == 0){
- return ApiJson.returnNG("driverId不能为空");
+ return ResultUtil.paranErr("driverId不能为空");
}
if(orderId == null || orderId == 0){
- return ApiJson.returnNG("orderId不能为空");
+ return ResultUtil.paranErr("orderId不能为空");
}
if(score == null || score == 0){
- return ApiJson.returnNG("score不能为空");
+ return ResultUtil.paranErr("score不能为空");
}
Evaluate evaluate=new Evaluate();
evaluate.setAddTime(new Date());
@@ -1134,7 +1254,7 @@
SensitiveWordUtil.init(sensitiveWordSet);
boolean result = SensitiveWordUtil.contains(content);
if(result){
- return ApiJson.returnNG("评价内容包含敏感词");
+ return ResultUtil.error("评价内容包含敏感词");
}
}
evaluate.setContent(content);
@@ -1148,8 +1268,8 @@
DriverRide driverRide=driverRideService.selectById(driverId);
if(driverRide!=null){
/*计算司机的评分*/
- driverRide.setEvaluateNum(driverRide.getEvaluateNum()+1);
- driverRide.setEvaluateScore(driverRide.getEvaluateScore()+score);
+ driverRide.setEvaluateNum((null != driverRide.getEvaluateNum() ? driverRide.getEvaluateNum() : 0 )+1);
+ driverRide.setEvaluateScore((null == driverRide.getEvaluateScore() ? 0 : driverRide.getEvaluateScore())+score);
driverRideService.updateById(driverRide);
}
/*标记订单已评价*/
@@ -1161,11 +1281,11 @@
orderRideService.updateById(orderTaxi);
evaluateService.insert(evaluate);
/*需要反订单数据*/
- return ApiJson.returnOK(orderId);
+ return ResultUtil.success(orderId);
} catch (Exception e) {
e.printStackTrace();
}
- return ApiJson.returnNG("");
+ return ResultUtil.error("");
}
/**
@@ -1191,13 +1311,13 @@
public Object complaints(Integer driverId,Integer userId,String content,String reMark,Integer type,Integer orderId) {
try {
if (userId == null || userId == 0) {
- return ApiJson.returnNG("userId不能为空");
+ return ResultUtil.paranErr("userId不能为空");
}
if (driverId == null || driverId == 0) {
- return ApiJson.returnNG("driverId不能为空");
+ return ResultUtil.paranErr("driverId不能为空");
}
if (orderId == null || orderId == 0) {
- return ApiJson.returnNG("orderId不能为空");
+ return ResultUtil.paranErr("orderId不能为空");
}
Complaints complaints=new Complaints();
complaints.setAddTime(new Date());
@@ -1212,7 +1332,7 @@
SensitiveWordUtil.init(sensitiveWordSet);
boolean result = SensitiveWordUtil.contains(content);
if(result){
- return ApiJson.returnNG("投诉内容包含敏感词");
+ return ResultUtil.error("投诉内容包含敏感词");
}
complaints.setContent(content);
complaints.setReMark(reMark);
@@ -1240,11 +1360,11 @@
orderTravel.setIsComplaint(2);
orderTravelService.updateById(orderTravel);
}
- return ApiJson.returnOK("投诉成功");
+ return ResultUtil.success("投诉成功");
} catch (Exception e) {
e.printStackTrace();
}
- return ApiJson.returnNG("");
+ return ResultUtil.error("");
}
/**
* 用户邀请司机接单(需要发送消息)
@@ -1262,16 +1382,21 @@
public Object myOrders(Integer orderId,Integer userId){
try {
if(ToolUtil.isEmpty(orderId)){
- return ApiJson.returnNG("orderId不能为空");
+ return ResultUtil.paranErr("orderId不能为空");
}
if(ToolUtil.isEmpty(userId)){
- return ApiJson.returnNG("userId不能为空");
+ return ResultUtil.paranErr("userId不能为空");
}
OrderTravel orderTravel=orderTravelService.selectById(orderId);
UserInfo userInfo_=userInfoService.selectOne(new EntityWrapper<UserInfo>().eq("driverId",orderTravel.getDriverId()));//司机用户
OrderRide orderRide=orderRideService.selectOne(new EntityWrapper<OrderRide>().eq("userId",userId)
.eq("state",2));
if(orderRide!=null){
+ OrderInvitation orderInvitation = new OrderInvitation();
+ orderInvitation.setOrderRideId(orderRide.getId());
+ orderInvitation.setOrderTravelId(orderTravel.getId());
+ orderInvitation.setInsertTime(new Date());
+ orderInvitationService.insert(orderInvitation);
String message="您发布的"+DateUtil.getDateToString(orderTravel.getStartTime(),"MM月dd日")+"的行程有乘客邀请您同行";
/*添加系统消息*/
try {
@@ -1280,12 +1405,14 @@
throw new RuntimeException(e);
}
}
- return ApiJson.returnOK("邀请成功");
+ return ResultUtil.success("邀请成功");
} catch (Exception e) {
e.printStackTrace();
}
- return ApiJson.returnNG("异常");
+ return ResultUtil.error("异常");
}
+
+
/**
* 用户订单匹配列表页面,用户订单去匹配司机的行程
* @param type 搜索条件:1默认排序(根据线路、时间,人数综合匹配排序721),2时间最早,3距离最近
@@ -1299,23 +1426,15 @@
@ApiOperation(value = "用户订单匹配列表页面,用户订单去匹配司机的行程", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "int"),
- @ApiImplicitParam(name = "type", value = "1默认排序(根据线路、时间,人数综合匹配排序721),2时间最早,3距离最近", dataType = "int"),
- @ApiImplicitParam(name = "lon", value = "经度", dataType = "double"),
- @ApiImplicitParam(name = "lat", value = "纬度", dataType = "double"),
+ @ApiImplicitParam(name = "type", value = "1默认排序(根据线路、时间,人数综合匹配排序721),2时间最早,3距离最近", dataType = "int")
})
- public Object userMatchingOrderList(Integer orderId,Integer current,Integer size,Integer type,Double lon,Double lat){
+ public Object userMatchingOrderList(Integer orderId,Integer current,Integer size,Integer type){
try {
if(ToolUtil.isEmpty(orderId)){
- return ApiJson.returnNG("orderId不能为空");
+ return ResultUtil.paranErr("orderId不能为空");
}
if(ToolUtil.isEmpty(type)){
- return ApiJson.returnNG("type不能为空");
- }
- if(ToolUtil.isEmpty(lon)){
- return ApiJson.returnNG("lon不能为空");
- }
- if(ToolUtil.isEmpty(lat)){
- return ApiJson.returnNG("lat不能为空");
+ return ResultUtil.paranErr("type不能为空");
}
OrderRide orderRide=orderRideService.selectById(orderId);
current=current==null?1:current;
@@ -1325,16 +1444,17 @@
OrderRideVo orderRideVo=new OrderRideVo();
orderRideVo.setCurrent(current);
orderRideVo.setSize(size);
- orderRideVo.setLon(lon);
- orderRideVo.setLat(lat);
+ orderRideVo.setLon(orderRide.getStartLon());
+ orderRideVo.setLat(orderRide.getStartLat());
orderRideVo.setNum(orderRide.getNum());
+ orderRideVo.setId(orderId);
orderRideVo.setType(type+1);//搜索条件:1默认排序(根据线路、时间,人数综合匹配排序721),2时间最早,3距离最近
List<OrderRideVo> orderRides=orderTravelService.getOrderTravel(orderRideVo);
- return ApiJson.returnOK(orderRides);
+ return ResultUtil.success(orderRides);
} catch (Exception e) {
e.printStackTrace();
}
- return ApiJson.returnNG("异常");
+ return ResultUtil.error("异常");
}
/**
@@ -1352,24 +1472,16 @@
@ApiOperation(value = "司机订单匹配列表页面(司机的订单去匹配乘客订单)", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "int"),
- @ApiImplicitParam(name = "type", value = "1默认排序(根据线路、时间,人数综合匹配排序721),2时间最早,3距离最近,4价格最低", dataType = "int"),
- @ApiImplicitParam(name = "lon", value = "经度", dataType = "double"),
- @ApiImplicitParam(name = "lat", value = "纬度", dataType = "double"),
+ @ApiImplicitParam(name = "type", value = "1默认排序(根据线路、时间,人数综合匹配排序721),2时间最早,3距离最近,4价格最低", dataType = "int")
})
- public Object driverMatchingOrderList(Integer orderId,Integer current,Integer size,Integer type,Double lon,Double lat){
+ public Object driverMatchingOrderList(Integer orderId,Integer current,Integer size,Integer type){
try {
try {
if(ToolUtil.isEmpty(orderId)){
- return ApiJson.returnNG("orderId不能为空");
+ return ResultUtil.paranErr("orderId不能为空");
}
if(ToolUtil.isEmpty(type)){
- return ApiJson.returnNG("type不能为空");
- }
- if(ToolUtil.isEmpty(lon)){
- return ApiJson.returnNG("lon不能为空");
- }
- if(ToolUtil.isEmpty(lat)){
- return ApiJson.returnNG("lat不能为空");
+ return ResultUtil.paranErr("type不能为空");
}
OrderTravel orderTravel=orderTravelService.selectById(orderId);
current=current==null?1:current;
@@ -1380,18 +1492,18 @@
orderRideVo.setCurrent(current);
orderRideVo.setSize(size);
orderRideVo.setNum(orderTravel.getNum());
- orderRideVo.setLon(lon);
- orderRideVo.setLat(lat);
+ orderRideVo.setLon(orderTravel.getStartLon());
+ orderRideVo.setLat(orderTravel.getStartLat());
orderRideVo.setType(type+1);//搜索条件:1默认排序(根据线路、时间,人数综合匹配排序721),2时间最早,3距离最近,4价格最低
List<OrderRideVo> orderRides=orderRideService.getOrderRide(orderRideVo);
- return ApiJson.returnOK(orderRides);
+ return ResultUtil.success(orderRides);
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
- return ApiJson.returnNG("异常");
+ return ResultUtil.error("异常");
}
/**
@@ -1412,10 +1524,10 @@
public Object orderInfo(Integer orderId,Integer type,Double lon,Double lat) {
try {
if(ToolUtil.isEmpty(orderId)){
- return ApiJson.returnNG("orderId不能为空");
+ return ResultUtil.paranErr("orderId不能为空");
}
if(ToolUtil.isEmpty(type)){
- return ApiJson.returnNG("type不能为空");
+ return ResultUtil.paranErr("type不能为空");
}
//取司机的经纬度
OrderRideInfoVo orderRideInfoVo=new OrderRideInfoVo();
@@ -1429,19 +1541,13 @@
orderRideInfoVo=orderTravelService.getOrderInfo(orderRideInfoVo);
}
/*获取顺风车订单支付倒计时*/
- Param param = paramService.selectOne(new EntityWrapper<Param>().eq("type", 21));//顺风车支付倒计时设置(分钟)
Integer time =10;
- if(param != null){
- time=Integer.parseInt(param.getContext());
- orderRideInfoVo.setDjs(time);
- }else{
- orderRideInfoVo.setDjs(time);
- }
- return ApiJson.returnOK(orderRideInfoVo);
+ orderRideInfoVo.setDjs(time);
+ return ResultUtil.success(orderRideInfoVo);
} catch (Exception e) {
e.printStackTrace();
}
- return ApiJson.returnNG("异常");
+ return ResultUtil.error("异常");
}
/**
@@ -1456,10 +1562,10 @@
public Object orderInfo(String inviteCode,Integer type) {
try {
if(ToolUtil.isEmpty(inviteCode)){
- return ApiJson.returnNG("inviteCode不能为空");
+ return ResultUtil.paranErr("inviteCode不能为空");
}
if(ToolUtil.isEmpty(type)){
- return ApiJson.returnNG("type不能为空");
+ return ResultUtil.paranErr("type不能为空");
}
Integer count=0;
if(type==1){
@@ -1467,11 +1573,11 @@
}else {
count=userInfoService.selectCount(new EntityWrapper<UserInfo>().eq("inviteCodeRide",inviteCode));
}
- return ApiJson.returnOK(count);
+ return ResultUtil.success(count);
} catch (Exception e) {
e.printStackTrace();
}
- return ApiJson.returnNG("异常");
+ return ResultUtil.error("异常");
}
/**
@@ -1486,7 +1592,7 @@
public Object orderInfo(Integer driverId) {
try {
if(ToolUtil.isEmpty(driverId)){
- return ApiJson.returnNG("driverId不能为空");
+ return ResultUtil.paranErr("driverId不能为空");
}
DriverRide driverRide=driverRideService.selectById(driverId);
Integer count=0;
@@ -1499,11 +1605,11 @@
count=1;
}
}
- return ApiJson.returnOK(count);
+ return ResultUtil.success(count);
} catch (Exception e) {
e.printStackTrace();
}
- return ApiJson.returnNG("异常");
+ return ResultUtil.error("异常");
}
}
--
Gitblit v1.7.1