From 127c4d704298c4ed4ca00acaa6f722ddf881b01e Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期三, 23 七月 2025 21:17:06 +0800 Subject: [PATCH] 增加管理后台顺风车相关模块代码 --- ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TOrderCrossCityController.java | 121 ++++++++++++---------------------------- 1 files changed, 37 insertions(+), 84 deletions(-) diff --git a/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TOrderCrossCityController.java b/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TOrderCrossCityController.java index b2ddd2f..fb7f16c 100644 --- a/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TOrderCrossCityController.java +++ b/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TOrderCrossCityController.java @@ -1,18 +1,13 @@ package com.stylefeng.guns.modular.system.controller.specialTrain; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.plugins.Page; import com.stylefeng.guns.core.base.controller.BaseController; import com.stylefeng.guns.core.beetl.ShiroExtUtil; import com.stylefeng.guns.core.common.constant.factory.PageFactory; -import com.stylefeng.guns.core.shiro.ShiroKit; import com.stylefeng.guns.core.shiro.ShiroUser; import com.stylefeng.guns.core.util.SinataUtil; import com.stylefeng.guns.core.util.ToolUtil; -import com.stylefeng.guns.modular.system.controller.general.TDriverController; -import com.stylefeng.guns.modular.system.controller.util.GetOpenBodySig; import com.stylefeng.guns.modular.system.dao.LineShiftDriverMapper; import com.stylefeng.guns.modular.system.dao.OrderCancelMapper; import com.stylefeng.guns.modular.system.model.*; @@ -21,21 +16,22 @@ import com.stylefeng.guns.modular.system.util.PayMoneyUtil; import com.stylefeng.guns.modular.system.util.PushURL; import com.stylefeng.guns.modular.system.util.ResultUtil; -import org.apache.commons.lang.time.DateFormatUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Sort; +import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.data.mongodb.core.query.Criteria; +import org.springframework.data.mongodb.core.query.Query; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStreamReader; import java.math.BigDecimal; -import java.util.*; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * 跨城出行订单控制器 @@ -54,21 +50,24 @@ @Autowired private ITServerCarmodelService tServerCarmodelService; - + @Autowired private ITLineService itLineService; - + @Autowired private ITOrderPositionService tOrderPositionService; - + private ResultUtil resultUtil; - + @Autowired private ITUserService userService; - - @Value("${filePath}") - private String filePath; - + + @Resource + private MongoTemplate mongoTemplate; + @Autowired + private ShiroExtUtil shiroExtUtil; + + /** * 跳转到跨城出行订单首页 */ @@ -76,7 +75,7 @@ public String index(Model model) { //服务快车车型 List<TServerCarmodel> carmodelList = tServerCarmodelService.selectList(new EntityWrapper<TServerCarmodel>().eq("type", 2).eq("state", 1)); - model.addAttribute("carmodelList",carmodelList); + model.addAttribute("carmodelList", carmodelList); //线路 List<TLine> lineList = itLineService.selectList(new EntityWrapper<TLine>().last(" where not FIND_IN_SET(state,'3')")); model.addAttribute("lineList",lineList); @@ -101,41 +100,28 @@ model.addAttribute("tOrderCrossCityId",tOrderCrossCityId); return PREFIX + "tOrderCrossCity_track.html"; } - + /** * 获取订单轨迹 + * * @param orderDetailId * @return */ @ResponseBody @RequestMapping(value = "/getOrderTrack", method = RequestMethod.POST) - public ResultUtil getOrderTrack(String orderDetailId){ - if(ToolUtil.isNotEmpty(orderDetailId)){ + public ResultUtil getOrderTrack(Integer orderDetailId) { + if (ToolUtil.isNotEmpty(orderDetailId)) { try { - //将数据存储到文件中 - File file = new File(filePath + orderDetailId + "_3.txt"); - if(!file.exists()){ - return ResultUtil.success(new ArrayList<>()); - } - //读取文件(字符流) - BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF-8")); - //循环取出数据 - String str = null; - StringBuffer sb = new StringBuffer(); - while ((str = in.readLine()) != null) { - sb.append(str); - } - List<TOrderPosition> list = JSONArray.parseArray(sb.toString(), TOrderPosition.class); -// List<TOrderPosition> list = tOrderPositionService.selectList(new EntityWrapper<TOrderPosition>().eq("orderType", 3).eq("orderId", orderDetailId).orderBy("insertTime")); - /*if(list.size() == 0){ - return ResultUtil.error("该订单没有运行轨迹"); - }*/ - resultUtil = ResultUtil.success(list); - }catch (Exception e){ + Query query = new Query() + .addCriteria(Criteria.where("orderId").is(orderDetailId).and("orderType").is(3)) + .with(new Sort(Sort.Direction.ASC, "insertTime")); + List<TOrderPosition> positions = mongoTemplate.find(query, TOrderPosition.class); + resultUtil = ResultUtil.success(positions); + } catch (Exception e) { e.printStackTrace(); resultUtil = ResultUtil.runErr(); } - }else { + } else { resultUtil = ResultUtil.paranErr(); } return resultUtil; @@ -165,7 +151,7 @@ endTime = timeArray[1]; } Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(); - page.setRecords(tOrderCrossCityService.getCrossCityOrderList(page, beginTime, endTime, ShiroExtUtil.getUser().getRoleType(), ShiroExtUtil.getUser().getObjectId(), orderNum, orderSource, userName, userPhone, passengers, passengersPhone, serverCarModelId, driver, lineId, state)); + page.setRecords(tOrderCrossCityService.getCrossCityOrderList(page, beginTime, endTime, shiroExtUtil.getUser().getRoleType(), shiroExtUtil.getUser().getObjectId(), orderNum, orderSource, userName, userPhone, passengers, passengersPhone, serverCarModelId, driver, lineId, state)); return super.packForBT(page); } @@ -190,9 +176,6 @@ @Autowired private IIncomeService incomeService; -@Autowired -private TDriverController tDriverController; - /** * 取消跨城出行订单 @@ -201,16 +184,16 @@ @ResponseBody public Object cancel(@RequestParam Integer tOrderCrossCityId) throws Exception { TOrderCrossCity tOrderCrossCity = tOrderCrossCityService.selectById(tOrderCrossCityId); - ShiroUser user = ShiroExtUtil.getUser(); - + ShiroUser user = shiroExtUtil.getUser(); + TOrderCrossCity orderCrossCity = tOrderCrossCityService.selectById(tOrderCrossCityId); - if(orderCrossCity.getState() > 5 && orderCrossCity.getState() != 11 && orderCrossCity.getState() != 7){ + if (orderCrossCity.getState() > 5 && orderCrossCity.getState() != 11 && orderCrossCity.getState() != 7) { return ResultUtil.error("订单状态不在可取消范围内"); } orderCrossCity.setState(10); tOrderCrossCityService.updateById(orderCrossCity); - - if(orderCrossCity.getDriverId() != null){ + + if (orderCrossCity.getDriverId() != null) { //修改司机信息 LineShiftDriver lineShiftDriver = lineShiftDriverMapper.selectById(orderCrossCity.getLineShiftDriverId()); lineShiftDriver.setLaveSeat(lineShiftDriver.getLaveSeat() + orderCrossCity.getPeopleNumber() > lineShiftDriver.getTotalSeat() ? @@ -350,34 +333,4 @@ return SUCCESS_TIP; } - - public static ResultUtil cancleMoney(BigDecimal amount,String no) throws Exception { - JSONObject json = new JSONObject(); - json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss")); // 报文请求时间 -// json.put("merOrderId", Util.getMerOrderId("34U0")); // 商户订单号 - json.put("merOrderId", no); // 商户订单号 - json.put("mid", "898150841210108"); // 商户号 - json.put("tid", "84UJWSE8"); // 终端号 - json.put("instMid", "QRPAYDEFAULT"); // 业务类型 - BigDecimal multiply = amount.multiply(new BigDecimal(100)); - int money = multiply.intValue(); - json.put("refundAmount",money); // 支付总金额 - System.err.println("请求报文json:\n" + json); - String url = "https://test-api-open.chinaums.com/v1/netpay/refund"; -// String url = "https://api-mop.chinaums.com/v1/netpay/refund"; - //OPEN-BODY-SIG 方式 - String result = GetOpenBodySig.sendOpenBodySig(url, json.toString()); - System.err.println("响应报文json:\n" + result); - JSONObject jsonObject = JSONObject.parseObject(result); - Object appPayRequest = jsonObject.get("appPayRequest"); - System.out.println(appPayRequest); - return ResultUtil.success(appPayRequest); - } - - @Autowired - private ITEnterpriseWithdrawalService tEnterpriseWithdrawalService; - @Autowired - private IUserWithdrawalService userWithdrawalService; - - } -- Gitblit v1.7.1