Pu Zhibing
2025-08-06 0efb002d79eda0b1ef539cf8a029f14b5395f83e
合并代码
9个文件已修改
377 ■■■■ 已修改文件
EurekaQYTTravel/src/main/resources/application.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
MessagePushTravel/src/main/java/com/sinata/push/util/RedisUtil.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/shunfeng/controller/PayInfoController.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/shunfeng/controller/rideCommentController.java 180 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/vo/TripSheetVo.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/TaskUtil.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/OrderUtil.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/QianYunTongProperties.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserQYTTravel/guns-admin/src/test/java/com/stylefeng/guns/GunsApplicationTest.java 164 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
EurekaQYTTravel/src/main/resources/application.yml
@@ -16,7 +16,7 @@
eureka:
  instance:
    hostname: 127.0.0.1 #注册中心地址
    hostname: 192.168.110.106 #注册中心地址
  client:
    service-url: #客户端调用地址
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
MessagePushTravel/src/main/java/com/sinata/push/util/RedisUtil.java
@@ -4,6 +4,7 @@
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;
@@ -13,8 +14,8 @@
@Component
public class RedisUtil {
    @Autowired
    private RedisTemplate<String, String> redisTemplate;
    @Resource
    private RedisTemplate<String, Object> redisTemplate;
    /**
@@ -44,7 +45,7 @@
     * @return
     */
    public String getValue(String key){
        return redisTemplate.opsForValue().get(key);
        return (String) redisTemplate.opsForValue().get(key);
    }
UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/shunfeng/controller/PayInfoController.java
@@ -10,8 +10,12 @@
import com.stylefeng.guns.modular.system.service.ISystemNoticeService;
import com.stylefeng.guns.modular.system.service.IUserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@@ -22,7 +26,7 @@
/**
 * 支付相关接口
 */
@Api(tags = "顺风车支付相关接口")
@Api("顺风车支付相关接口")
@Controller
@RequestMapping("/api/payInfo")
public class PayInfoController {
@@ -117,7 +121,12 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/payOnline")
    @PostMapping("/payOnline")
    @ApiOperation(value = "线上支付", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderId", value = "订单id", dataType = "int"),
            @ApiImplicitParam(name = "payType", value = "支付类型 1=支付宝,2 = 微信 3:银行卡 4:小程序", dataType = "int"),
    })
    public Object payOnline(Integer orderId,Integer type,String code,Integer payType,Integer isBalance,HttpServletRequest request,Integer couponId){
        try {
            if(orderId == null || orderId == 0){
UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/shunfeng/controller/rideCommentController.java
@@ -21,11 +21,13 @@
import com.stylefeng.guns.modular.system.util.GDMapElectricFenceUtil;
import com.stylefeng.guns.modular.system.util.PushUtil;
import com.stylefeng.guns.modular.system.util.qianyuntong.UserUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.*;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@@ -98,7 +100,14 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/authentication")
    @PostMapping("/authentication")
    @ApiOperation(value = "发布顺风车行程实名认证", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户id", dataType = "int"),
            @ApiImplicitParam(name = "name", value = "姓名", dataType = "string"),
            @ApiImplicitParam(name = "identity", value = "身份证", dataType = "string"),
            @ApiImplicitParam(name = "type", value = "1用户,2司机", dataType = "int"),
    })
    public Object authentication(Integer userId,String name,String  identity,Integer type) {
        try {
            if (userId == null || userId == 0) {
@@ -150,7 +159,8 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/faceAuthentication")
    @PostMapping("/faceAuthentication")
    @ApiOperation(value = "人脸识别", httpMethod = "POST")
    public Object authentication(Integer userId,String headImg) {
//        try {
//            if (userId == null || userId == 0) {
@@ -200,7 +210,8 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/getBrandList")
    @GetMapping("/getBrandList")
    @ApiOperation(value = "获取车辆品牌列表", httpMethod = "GET")
    public Object getBrandList(){
        try {
            List<Brand> brands=brandService.selectList(null);
@@ -218,7 +229,12 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/homeOrderCount")
    @GetMapping("/homeOrderCount")
    @ApiOperation(value = "顺风车首页(待处理订单数)", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户id", dataType = "int"),
            @ApiImplicitParam(name = "type", value = "1用户,2司机", dataType = "int"),
    })
    public Object homeOrderCount(Integer userId,Integer type){
        try {
            if(ToolUtil.isEmpty(userId)){
@@ -254,7 +270,12 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/homeOrderList")
    @GetMapping("/homeOrderList")
    @ApiOperation(value = "顺风车首页(待处理订单列表)", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户id", dataType = "int"),
            @ApiImplicitParam(name = "type", value = "1用户待处理订单:进行中的订单 2司机待处理订单:进行中的订单 3我的顺风车行程", dataType = "int"),
    })
    public Object homeOrderList(Integer userId,Integer type,Integer current,Integer size){
        try {
            if(ToolUtil.isEmpty(userId)){
@@ -293,7 +314,15 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/orderPrice")
    @PostMapping("/orderPrice")
    @ApiOperation(value = "根据输入的开始结束经纬度和人数获取订单价格", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "num", value = "人数", dataType = "int"),
            @ApiImplicitParam(name = "startLat", value = "起点纬度", dataType = "double"),
            @ApiImplicitParam(name = "startLon", value = "起点经度", dataType = "double"),
            @ApiImplicitParam(name = "endLat", value = "终点纬度", dataType = "double"),
            @ApiImplicitParam(name = "endLon", value = "终点经度", dataType = "double"),
    })
    public Object orderPrice(Integer num,Double startLat,Double startLon,Double endLat,Double endLon){
        try {
            String locationS=startLon+","+startLat;
@@ -352,7 +381,22 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/userAddOrder")
    @PostMapping("/userAddOrder")
    @ApiOperation(value = "用户下单", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户id", dataType = "int"),
            @ApiImplicitParam(name = "startTime", value = "出行时间", dataType = "string"),
            @ApiImplicitParam(name = "num", value = "出行人数", dataType = "int"),
            @ApiImplicitParam(name = "startName", value = "起点名称", dataType = "string"),
            @ApiImplicitParam(name = "startLat", value = "起点纬度", dataType = "double"),
            @ApiImplicitParam(name = "startLon", value = "起点经度", dataType = "double"),
            @ApiImplicitParam(name = "endName", value = "终点名称", dataType = "string"),
            @ApiImplicitParam(name = "endLat", value = "终点纬度", dataType = "double"),
            @ApiImplicitParam(name = "endLon", value = "终点经度", dataType = "double"),
            @ApiImplicitParam(name = "money", value = "金额", dataType = "double"),
            @ApiImplicitParam(name = "isDai  1=是 2=否", value = "是否代喊  1=是 2=否", dataType = "int"),
            @ApiImplicitParam(name = "lxPhone", value = "联系电话", dataType = "string"),
    })
    public Object addOrder(Integer userId,String startTime,Integer num,String startName,Double startLat,Double startLon,Double endLat,Double endLon,
                           String endName,Double money,Integer isDai,String lxPhone){
        try {
@@ -452,7 +496,19 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/driverAddTravel")
    @PostMapping("/driverAddTravel")
    @ApiOperation(value = "司机创建行程", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "driverId", value = "司机id", dataType = "int"),
            @ApiImplicitParam(name = "startTime", value = "出行时间", dataType = "string"),
            @ApiImplicitParam(name = "num", value = "出行人数", dataType = "int"),
            @ApiImplicitParam(name = "startName", value = "起点名称", dataType = "string"),
            @ApiImplicitParam(name = "startLat", value = "起点纬度", dataType = "double"),
            @ApiImplicitParam(name = "startLon", value = "起点经度", dataType = "double"),
            @ApiImplicitParam(name = "endName", value = "终点名称", dataType = "string"),
            @ApiImplicitParam(name = "endLat", value = "终点纬度", dataType = "double"),
            @ApiImplicitParam(name = "endLon", value = "终点经度", dataType = "double"),
    })
    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)){
@@ -527,7 +583,26 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/driverAudit")
    @PostMapping("/driverAudit")
    @ApiOperation(value = "用户申请顺风车司机/修改司机资料", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户id", dataType = "int"),
            @ApiImplicitParam(name = "brandId", value = "品牌id", dataType = "int"),
            @ApiImplicitParam(name = "driverId", value = "司机id", dataType = "int"),
            @ApiImplicitParam(name = "carType", value = "车辆品牌", dataType = "string"),
            @ApiImplicitParam(name = "carNum", value = "车牌", dataType = "string"),
            @ApiImplicitParam(name = "inviteCodeRide", value = "别人的邀请码", dataType = "string"),
            @ApiImplicitParam(name = "license", value = "驾驶证号", dataType = "string"),
            @ApiImplicitParam(name = "licenseImg", value = "驾驶证图片", dataType = "string"),
            @ApiImplicitParam(name = "comInsuranceTime", value = "交强险到期时间", dataType = "string"),
            @ApiImplicitParam(name = "comInsuranceImg", value = "交强险照片", dataType = "string"),
            @ApiImplicitParam(name = "businessInsuranceTime", value = "商业险到期时间", dataType = "string"),
            @ApiImplicitParam(name = "businessInsuranceImg", value = "商业险图片", dataType = "string"),
            @ApiImplicitParam(name = "dutyInsuranceTime", value = "驾乘人员责任险到期时间", dataType = "string"),
            @ApiImplicitParam(name = "dutyInsuranceImg", value = "驾乘人员责任险照片", dataType = "string"),
            @ApiImplicitParam(name = "annualInspectionTime", value = "年检到期时间", dataType = "string"),
            @ApiImplicitParam(name = "annualInspectionImg", value = "年检图片", dataType = "string"),
    })
    public Object driverAudit(Integer userId,Integer brandId,Integer driverId,String carType,String carNum,String inviteCodeRide,String license,String licenseImg,String comInsuranceTime,String comInsuranceImg,
                              String businessInsuranceTime,String businessInsuranceImg,String dutyInsuranceTime,String dutyInsuranceImg,String annualInspectionTime,String annualInspectionImg){
        try {
@@ -644,7 +719,8 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/driverInfo")
    @GetMapping("/driverInfo")
    @ApiOperation(value = "获取司机资料", httpMethod = "GET")
    public Object driverInfo(Integer driverId){
        try {
            if(ToolUtil.isEmpty(driverId)){
@@ -670,7 +746,12 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/cancelServiceMoney")
    @GetMapping("/cancelServiceMoney")
    @ApiOperation(value = "司机用户获取取消的服务费(同时计算退款金额)", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderId", value = "订单id", dataType = "int"),
            @ApiImplicitParam(name = "type", value = "1用户,2司机", dataType = "int")
    })
    public Object cancelServiceMoney(Integer orderId,Integer type){
        try {
            if(ToolUtil.isEmpty(orderId)){
@@ -733,7 +814,8 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/userCancel")
    @PostMapping("/userCancel")
    @ApiOperation(value = "用户订单取消 待出行之前才可以取消", httpMethod = "POST")
    public Object userCancel(Integer orderId){
        try {
            if(ToolUtil.isEmpty(orderId)){
@@ -818,7 +900,8 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/driverCancel")
    @PostMapping("/driverCancel")
    @ApiOperation(value = "司机行程取消", httpMethod = "POST")
    public Object driverCancel(Integer orderId){
        try {
            if(ToolUtil.isEmpty(orderId)){
@@ -892,7 +975,13 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/driverOperation")
    @PostMapping("/driverOperation")
    @ApiOperation(value = "司机确认同行,接到乘客,送达乘客", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userOrderId", value = "用户订单id", dataType = "int"),
            @ApiImplicitParam(name = "type", value = "1确认同行 2接到乘客,3送达乘客", dataType = "int"),
            @ApiImplicitParam(name = "driverOrderId", value = "司机订单id", dataType = "int")
    })
    @Transactional
    public Object driverOperation(Integer userOrderId,Integer type,Integer driverOrderId){
        try {
@@ -1006,7 +1095,15 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/evaluate")
    @PostMapping("/evaluate")
    @ApiOperation(value = "用户评价", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderId", value = "订单id", dataType = "int"),
            @ApiImplicitParam(name = "driverId", value = "司机id", dataType = "int"),
            @ApiImplicitParam(name = "userId", value = "用户id", dataType = "int"),
            @ApiImplicitParam(name = "score", value = "评分", dataType = "int"),
            @ApiImplicitParam(name = "content", value = "评价内容", dataType = "string")
    })
    public Object evaluate(Integer orderId,Integer driverId,Integer userId,Integer score,String  content){
        try {
            if(userId == null || userId == 0){
@@ -1081,7 +1178,16 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/complaints")
    @PostMapping("/complaints")
    @ApiOperation(value = "投诉", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "driverId", value = "司机id", dataType = "int"),
            @ApiImplicitParam(name = "userId", value = "用户id", dataType = "int"),
            @ApiImplicitParam(name = "content", value = "投诉内容", dataType = "string"),
            @ApiImplicitParam(name = "reMark", value = "备注", dataType = "string"),
            @ApiImplicitParam(name = "type", value = "1=顺风车用户,2=顺风车司机", dataType = "int"),
            @ApiImplicitParam(name = "orderId", value = "订单id", dataType = "int")
    })
    public Object complaints(Integer driverId,Integer userId,String  content,String reMark,Integer type,Integer orderId) {
        try {
            if (userId == null || userId == 0) {
@@ -1147,7 +1253,12 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/userInvite")
    @PostMapping("/userInvite")
    @ApiOperation(value = "用户邀请司机接单(需要发送消息)", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户id", dataType = "int"),
            @ApiImplicitParam(name = "orderId", value = "订单id", dataType = "int")
    })
    public Object myOrders(Integer orderId,Integer userId){
        try {
            if(ToolUtil.isEmpty(orderId)){
@@ -1184,7 +1295,14 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/userMatchingOrderList")
    @PostMapping("/userMatchingOrderList")
    @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"),
    })
    public Object userMatchingOrderList(Integer orderId,Integer current,Integer size,Integer type,Double lon,Double lat){
        try {
            if(ToolUtil.isEmpty(orderId)){
@@ -1230,7 +1348,14 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/driverMatchingOrderList")
    @PostMapping("/driverMatchingOrderList")
    @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"),
    })
    public Object driverMatchingOrderList(Integer orderId,Integer current,Integer size,Integer type,Double lon,Double lat){
        try {
            try {
@@ -1276,7 +1401,14 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/orderInfo")
    @GetMapping("/orderInfo")
    @ApiOperation(value = "订单详情", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderId", value = "订单id", dataType = "int"),
            @ApiImplicitParam(name = "type", value = "1=用户订单,2=司机订单", dataType = "int"),
            @ApiImplicitParam(name = "lon", value = "经度", dataType = "double"),
            @ApiImplicitParam(name = "lat", value = "纬度", dataType = "double"),
    })
    public Object orderInfo(Integer orderId,Integer type,Double lon,Double lat) {
        try {
            if(ToolUtil.isEmpty(orderId)){
@@ -1319,7 +1451,8 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/checkInviteCode")
    @PostMapping("/checkInviteCode")
    @ApiOperation(value = "验证输入的邀请码是否正确", httpMethod = "POST")
    public Object orderInfo(String inviteCode,Integer type) {
        try {
            if(ToolUtil.isEmpty(inviteCode)){
@@ -1348,7 +1481,8 @@
     * @return
     */
    @ResponseBody
    @RequestMapping("/checkInsuranceTime")
    @PostMapping("/checkInsuranceTime")
    @ApiOperation(value = "验证司机证件是否过期", httpMethod = "POST")
    public Object orderInfo(Integer driverId) {
        try {
            if(ToolUtil.isEmpty(driverId)){
UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/vo/TripSheetVo.java
@@ -1,6 +1,7 @@
package com.stylefeng.guns.modular.system.model.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -11,9 +12,9 @@
import java.util.List;
@Data
@ApiModel
@AllArgsConstructor
@NoArgsConstructor
@Getter
public class TripSheetVo {
    @ApiModelProperty(value = "是否获取全部行程订单")
    private boolean allOrders;
UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/TaskUtil.java
@@ -84,7 +84,7 @@
            //修改过期的商家优惠券
            userMerchantCouponService.updateExpired();
            //处理超时未支付的订单
            timoutNoPayment();
//            timoutNoPayment();
        } catch (Exception e) {
            e.printStackTrace();
        }
UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/OrderUtil.java
@@ -502,7 +502,7 @@
     * @return
     */
    public static PayInfo tradePayOff(TradePayOffData tradePayOffData) {
        tradePayOffData.setPartnerId("5400004");
        tradePayOffData.setPartnerId("5400005");
        tradePayOffData.setTimeout("72H");
        tradePayOffData.setScene("TRAFFIC");
        tradePayOffData.setCurrency("RMB");
UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/QianYunTongProperties.java
@@ -16,8 +16,8 @@
    /**
     * 私钥地址
     */
//    String privateKeyPath = "C:\\Users\\39373\\Desktop\\黔云通\\private_key_test.pem";
    String privateKeyPath = "C:\\Users\\Admin\\Desktop\\qyt\\private_key_test.pem";
    String privateKeyPath = "C:\\Users\\39373\\Desktop\\黔云通\\private_key_test.pem";
//    String privateKeyPath = "C:\\Users\\Admin\\Desktop\\qyt\\private_key_test.pem";
    /**
     * 私钥地址
     */
UserQYTTravel/guns-admin/src/test/java/com/stylefeng/guns/GunsApplicationTest.java
@@ -1,18 +1,146 @@
//package com.stylefeng.guns;
//
//import org.junit.runner.RunWith;
//import org.springframework.boot.test.context.SpringBootTest;
//import org.springframework.test.context.junit4.SpringRunner;
//
///**
// * SpringBoot方式启动类
// *
// * @author stylefeng
// * @Date 2017/5/21 12:06
// */
//@RunWith(SpringRunner.class)
//@SpringBootTest
//public class GunsApplicationTest {
//
//
//}
package com.stylefeng.guns;
import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar;
import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService;
import com.stylefeng.guns.modular.system.model.Company;
import com.stylefeng.guns.modular.system.model.Driver;
import com.stylefeng.guns.modular.system.model.UserInfo;
import com.stylefeng.guns.modular.system.service.ICompanyService;
import com.stylefeng.guns.modular.system.service.IDriverService;
import com.stylefeng.guns.modular.system.service.IUserInfoService;
import com.stylefeng.guns.modular.system.util.qianyuntong.OrderUtil;
import com.stylefeng.guns.modular.system.util.qianyuntong.model.*;
import com.stylefeng.guns.modular.taxi.service.IPaymentRecordService;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.math.BigDecimal;
import java.util.List;
/**
 * SpringBoot方式启动类
 *
 * @author stylefeng
 * @Date 2017/5/21 12:06
 */
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
public class GunsApplicationTest {
    @Autowired
    private IOrderPrivateCarService orderPrivateCarService;
    @Autowired
    private IUserInfoService userInfoService;
    @Autowired
    private IDriverService driverService;
    @Autowired
    private ICompanyService companyService;
    @Autowired
    private IPaymentRecordService paymentRecordService;
    @Test
    public void test(){
        OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(211);
        //使用备付金进行支付订单
        TradePayOffData tradePayOffData = new TradePayOffData();
        tradePayOffData.setPartnerPayId(orderPrivateCar.getTravelId());
        tradePayOffData.setTotalFee(Double.valueOf(orderPrivateCar.getOrderMoney() * 100).intValue() + "");
        tradePayOffData.setOrderDesc("完成订单");
        PayInfo payInfo = OrderUtil.tradePayOff(tradePayOffData);
        String retCode = payInfo.getRetCode();
        if (!"000000".equals(retCode)) {
            log.error("备付金支付失败:{}", payInfo.getRetMsg());
            return;
        }
        PayInfoData data = payInfo.getData();
        String status = data.getStatus();
        if ("3".equals(status)) {
            log.error("备付金支付失败:{}", payInfo.getRetMsg());
            return;
        }
        PayInfoData payInfoData = payInfo.getData();
        PaymentInfo paymentInfo = payInfoData.getPaymentInfos().get(0);
        //支付成功,通知三方
        PaymentOrderRequest paymentOrderRequest = new PaymentOrderRequest();
        paymentOrderRequest.setPayItemId(paymentInfo.getPayItemId());
        paymentOrderRequest.setPaymentInfo(payInfoData.getPaymentInfos());
        paymentOrderRequest.setOrderId("PR" + orderPrivateCar.getId());
        paymentOrderRequest.setCharge(BigDecimal.valueOf(orderPrivateCar.getOrderMoney()));
        paymentOrderRequest.setPayTime(data.getPayTime());
        paymentOrderRequest.setPaymentSerialNumber(payInfoData.getPayId());
        OrderInfo orderInfo1 = OrderUtil.paymentOrder(paymentOrderRequest);
        //查询三方订单状态
        Driver driver1 = driverService.selectById(orderPrivateCar.getDriverId());
        Company company = companyService.selectById(driver1.getCompanyId());
        UserInfo userInfo1 = userInfoService.selectById(orderPrivateCar.getUserId());
        GetTravelItineraryListRequest request = new GetTravelItineraryListRequest();
        request.setCustomerId(userInfo1.getOnconUUID());
        request.setOrderNo("PR" + orderPrivateCar.getId());
        request.setDriverId(driver1.getEmpId().toString());
        ListPage<List<TravelItinerary>> travelItineraryList = OrderUtil.getTravelItineraryList(request);
        Integer status1 = travelItineraryList.getList().get(0).getStatus();
        if(9 != status1){
            //中台修改订单状态
            ModifyTravelItineraryRequest request1 = new ModifyTravelItineraryRequest();
            request1.setOrderId(orderPrivateCar.getTravelId());
            request1.setStatus(9);
            if (null != orderPrivateCar.getDriverId()) {
                request1.setDriverId(driver1.getEmpId().toString());
                request1.setSupplierShopId(company.getEnterCode());
            }
            if (2 == orderPrivateCar.getPromotion()) {
                Driver driver2 = driverService.selectById(orderPrivateCar.getPromotionDriverId());
                request1.setPromoterId(driver2.getEmpId().toString());
            }
            OrderUtil.modifyTravelItinerary(request1);
        }
        String payId = payInfo.getData().getPayId();
        //copy原始订单后生成追缴单
        OrderPrivateCar orderPrivateCar1 = new OrderPrivateCar();
        BeanUtils.copyProperties(orderPrivateCar, orderPrivateCar1);
        orderPrivateCar1.setId(null);
        orderPrivateCar1.setRecoveryOrder(1);
        //修改原始订单为支付状态
        orderPrivateCar.setState(8);
        orderPrivateCar.setPayType(5);
        orderPrivateCar.setPayMoney(orderPrivateCar.getOrderMoney());
        orderPrivateCarService.updateById(orderPrivateCar);
        //添加三方支付记录
        try {
            paymentRecordService.saveData(1, orderPrivateCar.getUserId(), 1, orderPrivateCar.getId(), 1, 3, orderPrivateCar.getOrderMoney(), payId, 2);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        Driver driver = driverService.selectById(orderPrivateCar1.getDriverId());
        UserInfo userInfo = userInfoService.selectById(orderPrivateCar1.getUserId());
        //调用三方创建订单
        CreateOrderRequest createOrderRequest = new CreateOrderRequest();
        createOrderRequest.setTreatShopId(driver.getEmpId().toString());
        createOrderRequest.setField1("{\"profitSharing\":\"0\",\"isPromote\":\"0\"}");
        createOrderRequest.setCharge(new BigDecimal(orderPrivateCar1.getOrderMoney()));
        createOrderRequest.setOrderNo("PR" + orderPrivateCar1.getId());
        createOrderRequest.setCustomerId(userInfo.getOnconUUID());
        OrderInfo orderInfo = OrderUtil.tradeOrderCreate(createOrderRequest);
        orderPrivateCar1.setTravelId(orderInfo.getOrderId());
        orderPrivateCar1.setIsCreated(1);
        //保存追缴单
        orderPrivateCarService.insert(orderPrivateCar1);
    }
}