puzhibing
2023-02-11 ea719b0443b8ccbc6d17349796936664ff3261d0
UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java
@@ -1,5 +1,6 @@
package com.stylefeng.guns.modular.api;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.core.util.ToolUtil;
@@ -15,6 +16,10 @@
import com.stylefeng.guns.modular.system.model.UserInfo;
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.util.*;
import com.stylefeng.guns.modular.system.util.Tingg.model.CallbackRequest;
import com.stylefeng.guns.modular.system.util.Tingg.model.CallbackResponse;
import com.stylefeng.guns.modular.system.util.Tingg.model.CheckoutRequest;
import com.stylefeng.guns.modular.system.util.Tingg.model.Payments;
import com.stylefeng.guns.modular.system.warpper.*;
import com.stylefeng.guns.modular.taxi.model.OrderTaxi;
import com.stylefeng.guns.modular.taxi.model.TransactionDetails;
@@ -86,9 +91,6 @@
    private IOrderCharteredCarService orderCharteredCarService;
    @Autowired
    private PushMinistryOfTransportUtil pushMinistryOfTransportUtil;
    @Autowired
    private ITransactionDetailsService transactionDetailsService;
    @Autowired
@@ -96,9 +98,6 @@
    @Autowired
    private PayMoneyUtil payMoneyUtil;
    @Value("${pushMinistryOfTransport}")
    private boolean pushMinistryOfTransport;
    @Value("${filePath}")
@@ -228,18 +227,33 @@
            @ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<List<TravelRecordWarpper>> queryMyTravelRecord(Integer pageNum, Integer size, HttpServletRequest request){
    public ResultUtil<List<TravelRecordWarpper>> queryMyTravelRecord(Integer pageNum, Integer size, Integer language, HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            String name = language == 1 ? "专车订单" : language == 2 ? "Private car order" : "Commande de voiture exclusive";
            pageNum = (pageNum - 1) * size;
            List<Map<String, Object>> maps = orderCancelService.queryCancel(uid, 2);
            for (Map<String, Object> map : maps) {
                Integer orderType = Integer.valueOf(map.get("orderType").toString());
                if(1 == orderType){
                    map.put("name", language == 1 ? "专车订单取消" : language == 2 ? "Private car order cancelled" : "Annulation de commande de voiture exclusive");
                }
                if(4 == orderType){
                    map.put("name", language == 1 ? "市内小件物流订单取消" : language == 2 ? "The small parts logistics order in the city has been cancelled" : "Annulation de commande pour la logistique de petites pièces dans la ville");
                }
            }
            List<Map<String, Object>> list = orderPrivateCarService.queryMyTravelRecord(uid);//专车
//            List<Map<String, Object>> list1 = orderTaxiService.queryMyTravelRecord(uid);//出租车
//            List<Map<String, Object>> list2 = orderCrossCityService.queryMyTravelRecord(uid);//跨城车
            for (Map<String, Object> map : list) {
                map.put("name", name);
            }
            name = language == 1 ? "市内小件物流" : language == 2 ? "Small parts logistics in the city" : "Logistique de petites pièces dans la ville";
            List<Map<String, Object>> list3 = orderLogisticsService.queryMyTravelRecord(uid);//小件物流
            for (Map<String, Object> map : list3) {
                map.put("name", name);
            }
            List<TransactionDetails> transactionDetails = transactionDetailsService.selectList(new EntityWrapper<TransactionDetails>().eq("state", 1)
                    .eq("type", 1).eq("userType", 1).eq("userId", uid).eq("orderType", 3).like("remark", "%跨城订单取消退款%"));
            List<Map<String, Object>> list4 = new ArrayList<>();
@@ -696,9 +710,9 @@
            @ApiImplicitParam(value = "用户id", name = "uid", required = true, dataType = "int"),
            @ApiImplicitParam(value = "附加参数{\"key\":\"value\"}", name = "content", required = true, dataType = "string")
    })
    public ResultUtil weChatPay(Integer orderId, Integer orderType, Integer type, Integer userType, Integer uid, String content){
    public ResultUtil weChatPay(Integer orderId, Integer orderType, Integer type, Integer userType, Integer uid, String content, Integer language){
        try {
            return orderService.weChatPay(orderId, orderType, type, userType, uid, content);
            return orderService.weChatPay(orderId, orderType, type, userType, uid, content, language);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
@@ -873,12 +887,12 @@
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "id", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=跨城)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "支付方式(1=手机支付,2=银行卡支付,3=余额)", name = "payType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "支付方式(1=线上支付,3=余额)", name = "payType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "取消单id(取消操作返回)", name = "cancleId", required = false, dataType = "int"),
            @ApiImplicitParam(value = "支付端(1=用户APP端,2=司机APP端,3=用户小程序端)", name = "type", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil cancleOrderTaxi(Integer id, Integer orderType, Integer payType, Integer cancleId, Integer type, HttpServletRequest request){
    public ResultUtil cancleOrderTaxi(Integer id, Integer orderType, Integer payType, Integer cancleId, Integer type, Integer language, HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
@@ -886,11 +900,11 @@
            }
            switch (orderType){
                case 1:
                    return orderPrivateCarService.cancleOrderPrivateCar(id, payType, cancleId, type);
                case 2:
                    return orderTaxiService.cancleOrderTaxi(id, payType, cancleId, type);
                case 3:
                    return orderCrossCityService.cancleOrderCrossCity(id, payType, cancleId, type);
                    return orderPrivateCarService.cancleOrderPrivateCar(id, payType, "user_" + uid, cancleId, type, language);
//                case 2:
//                    return orderTaxiService.cancleOrderTaxi(id, payType, cancleId, type);
//                case 3:
//                    return orderCrossCityService.cancleOrderCrossCity(id, payType, cancleId, type);
            }
            return ResultUtil.success();
        }catch (Exception e){
@@ -1043,16 +1057,16 @@
     */
    @ResponseBody
    @PostMapping("/api/taxi/payTaxiOrder")
    @ApiOperation(value = "订单完成支付订单操作", tags = {"用户端-出租车", "用户端-专车", "用户端-跨城", "用户端-小件物流"}, notes = "")
    @ApiOperation(value = "订单完成支付订单操作【1.0】", tags = {"用户端-出租车", "用户端-专车", "用户端-跨城", "用户端-小件物流"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "支付方式(1=手机支付,2=银行卡支付,3=余额,4=线下支付)", name = "payType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "支付方式(1=线上支付,3=余额,4=线下支付)", name = "payType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=跨城,4=同城小件物流,5=跨城小件物流)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "优惠券id", name = "couponId", required = false, dataType = "int"),
            @ApiImplicitParam(value = "支付端(1=用户APP端,2=司机APP端,3=用户小程序端)", name = "type", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil payTaxiOrder(Integer payType, Integer orderId, Integer orderType, Integer couponId, Integer type, HttpServletRequest request){
    public ResultUtil payTaxiOrder(Integer payType, Integer orderId, Integer orderType, Integer couponId, Integer type, Integer language, HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
@@ -1060,15 +1074,15 @@
            }
            switch (orderType){
                case 1:
                    return orderPrivateCarService.payPrivateCarOrder(payType, orderId, couponId, type);
                case 2:
                    return orderTaxiService.payTaxiOrder(payType, orderId, couponId, type);
                case 3:
                    return orderCrossCityService.payCrossCityOrder(payType, orderId, couponId, type);
                    return orderPrivateCarService.payPrivateCarOrder(payType, "user_" + uid, orderId, couponId, type, language);
//                case 2:
//                    return orderTaxiService.payTaxiOrder(payType, orderId, couponId, type);
//                case 3:
//                    return orderCrossCityService.payCrossCityOrder(payType, orderId, couponId, type);
                case 4:
                    return orderLogisticsService.payLogisticsOrder(payType, orderId, type);
                case 5:
                    return orderLogisticsService.payLogisticsOrder(payType, orderId, type);
                    return orderLogisticsService.payLogisticsOrder(payType, "user_" + uid, orderId, type, language);
//                case 5:
//                    return orderLogisticsService.payLogisticsOrder(payType, orderId, type, language);
            }
            return ResultUtil.success();
        }catch (Exception e){
@@ -1096,9 +1110,9 @@
            @ApiImplicitParam(value = "评价内容", name = "content", required = false, dataType = "String"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil orderEvaluate(Integer orderId, Integer orderType, Integer fraction, String content){
    public ResultUtil orderEvaluate(Integer orderId, Integer orderType, Integer fraction, String content, Integer language){
        try {
            ResultUtil resultUtil = orderEvaluateService.saveData(orderId, orderType, fraction, content);
            ResultUtil resultUtil = orderEvaluateService.saveData(orderId, orderType, fraction, content, language);
            if(resultUtil.getCode() == 200){
                switch (orderType){
                    case 1:
@@ -1173,11 +1187,11 @@
            @ApiImplicitParam(value = "订单类型", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil shareRedEnvelope(Integer orderId, Integer orderType){
    public ResultUtil shareRedEnvelope(Integer orderId, Integer orderType, Integer language){
        try {
            switch (orderType){
                case 1:
                    return orderPrivateCarService.shareRedEnvelope(orderId);
                    return orderPrivateCarService.shareRedEnvelope(orderId, language);
                case 2:
                    return orderTaxiService.shareRedEnvelope(orderId);
                case 3:
@@ -1195,21 +1209,31 @@
    /**
     * 取消订单微信回调
     * @param request
     * @param callbackRequest
     */
    @ResponseBody
    @PostMapping("/base/wxCancelOrderTaxi")
    public void wxCancelOrderTaxi(HttpServletRequest request, HttpServletResponse response){
    public CallbackResponse wxCancelOrderTaxi(@RequestBody CallbackRequest callbackRequest){
        CallbackResponse callbackResponse = new CallbackResponse();
        try {
            Map<String, String> map = payMoneyUtil.weixinpayCallback(request);//icbcPayUtil.payCallback(request);
            if(null != map){
                String out_trade_no = map.get("out_trade_no");
                String order_id = map.get("transaction_id");
            /**
             * 指示服务是否成功或付费的总体请求代码。。
             * 177-部分付费请求
             * 178-表明请求已全额支付
             * 179-表示请求已部分支付但已过期。
             * 129-请求已过期,未付款。
             * 180.商户拒绝请求
             * 183-商户接受请求,我们可以结算资金
             * 188-商户收到请求。
             */
            String request_status_code = callbackRequest.getRequest_status_code();
            String out_trade_no = callbackRequest.getMerchant_transaction_id();
            if("177".equals(request_status_code) || "178".equals(request_status_code)){
                Payments payments = callbackRequest.getPayments().get(0);
                String order_id = payments.getPayer_transaction_id();
                if(ToolUtil.isNotEmpty(out_trade_no)){
                    String[] split = out_trade_no.split("_");
                    Integer id = Integer.valueOf(split[0]);
                    Integer type = Integer.valueOf(split[1]);
                    Integer type = Integer.valueOf(out_trade_no.substring(17, 18));
                    Integer id = Integer.valueOf(out_trade_no.substring(18));
                    switch (type){
                        case 1:
                            orderPrivateCarService.payCancelOrderPrivateCar(id, order_id, 1);
@@ -1221,12 +1245,23 @@
                            orderCrossCityService.payCancelOrderCrossCity(id, order_id, 1);
                            break;
                    }
                    callbackResponse.setCheckout_request_id(order_id);
                    callbackResponse.setMerchant_transaction_id(out_trade_no);
                    callbackResponse.setStatus_code("183");
                    callbackResponse.setStatus_description("Payment processed successfully");
                    callbackResponse.setReceipt_number(UUIDUtil.getRandomCode(16));
                }
                response.getOutputStream().print("success");
            }else{
                callbackResponse.setCheckout_request_id(UUIDUtil.getRandomCode(16));
                callbackResponse.setMerchant_transaction_id(out_trade_no);
                callbackResponse.setStatus_code("180");
                callbackResponse.setStatus_description("means payment rejected.");
                callbackResponse.setReceipt_number(UUIDUtil.getRandomCode(16));
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return callbackResponse;
    }
@@ -1271,23 +1306,35 @@
    /**
     * 完成订单微信支付回调
     * @param request
     * @param
     */
    @ResponseBody
    @PostMapping("/base/wxPayOrderTaxi")
    public void wxPayOrderTaxi(HttpServletRequest request, HttpServletResponse response){
    public CallbackResponse wxPayOrderTaxi(@RequestBody CallbackRequest callbackRequest){
        CallbackResponse callbackResponse = new CallbackResponse();
        try {
            Map<String, String> map = payMoneyUtil.weixinpayCallback(request);//icbcPayUtil.payCallback(request);
            if(null != map){
                String out_trade_no = map.get("out_trade_no");
                String order_id = map.get("transaction_id");
            /**
             * 指示服务是否成功或付费的总体请求代码。。
             * 177-部分付费请求
             * 178-表明请求已全额支付
             * 179-表示请求已部分支付但已过期。
             * 129-请求已过期,未付款。
             * 180.商户拒绝请求
             * 183-商户接受请求,我们可以结算资金
             * 188-商户收到请求。
             */
            String request_status_code = callbackRequest.getRequest_status_code();
            String out_trade_no = callbackRequest.getMerchant_transaction_id();
            if("177".equals(request_status_code) || "178".equals(request_status_code)){
                Payments payments = callbackRequest.getPayments().get(0);
                String order_id = payments.getPayer_transaction_id();
                if(ToolUtil.isNotEmpty(out_trade_no)){
                    String[] split = out_trade_no.split("_");
                    Integer id = Integer.valueOf(split[0]);
                    Integer type = Integer.valueOf(split[1]);
                    Integer type = Integer.valueOf(out_trade_no.substring(17, 18));
                    Integer language = Integer.valueOf(out_trade_no.substring(18, 19));
                    Integer id = Integer.valueOf(out_trade_no.substring(19));
                    switch (type){
                        case 1:
                            orderPrivateCarService.payOrderPrivateCarCallback(id, order_id, 1);
                            orderPrivateCarService.payOrderPrivateCarCallback(id, order_id, 1, language);
                            break;
                        case 2:
                            orderTaxiService.payOrderTaxiCallback(id, order_id, 1);
@@ -1296,18 +1343,29 @@
                            orderCrossCityService.payOrderCrossCityCallback(id, order_id, 1);
                            break;
                        case 4:
                            orderLogisticsService.payOrderLogisticsCallback(id, order_id, 1);
                            orderLogisticsService.payOrderLogisticsCallback(id, order_id, 1, language);
                            break;
                        case 5:
                            orderLogisticsService.payOrderLogisticsCallback(id, order_id, 1);
                            orderLogisticsService.payOrderLogisticsCallback(id, order_id, 1, language);
                            break;
                    }
                    response.getOutputStream().print("success");
                    callbackResponse.setCheckout_request_id(order_id);
                    callbackResponse.setMerchant_transaction_id(out_trade_no);
                    callbackResponse.setStatus_code("183");
                    callbackResponse.setStatus_description("Payment processed successfully");
                    callbackResponse.setReceipt_number(UUIDUtil.getRandomCode(16));
                }
            }else{
                callbackResponse.setCheckout_request_id(UUIDUtil.getRandomCode(16));
                callbackResponse.setMerchant_transaction_id(out_trade_no);
                callbackResponse.setStatus_code("180");
                callbackResponse.setStatus_description("means payment rejected.");
                callbackResponse.setReceipt_number(UUIDUtil.getRandomCode(16));
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return callbackResponse;
    }
@@ -1327,9 +1385,10 @@
                    String[] split = out_trade_no.split("_");
                    Integer id = Integer.valueOf(split[0]);
                    Integer type = Integer.valueOf(split[1]);
                    Integer language = Integer.valueOf(split[2]);
                    switch (type){
                        case 1:
                            orderPrivateCarService.payOrderPrivateCarCallback(id, order_id, 2);
                            orderPrivateCarService.payOrderPrivateCarCallback(id, order_id, 2, language);
                            break;
                        case 2:
                            orderTaxiService.payOrderTaxiCallback(id, order_id, 2);
@@ -1338,10 +1397,10 @@
                            orderCrossCityService.payOrderCrossCityCallback(id, order_id, 2);
                            break;
                        case 4:
                            orderLogisticsService.payOrderLogisticsCallback(id, order_id, 2);
                            orderLogisticsService.payOrderLogisticsCallback(id, order_id, 2, language);
                            break;
                        case 5:
                            orderLogisticsService.payOrderLogisticsCallback(id, order_id, 2);
                            orderLogisticsService.payOrderLogisticsCallback(id, order_id, 2, language);
                            break;
                    }
                    response.setContentType("text/html;charset=UTF-8");