puzhibing
2023-02-15 2811bab657aab4145b65a45a824fb63e93b58e30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package com.stylefeng.guns.modular.system.util;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.modular.system.dao.OrderCancelMapper;
import com.stylefeng.guns.modular.system.model.Driver;
import com.stylefeng.guns.modular.system.model.OrderCancel;
import com.stylefeng.guns.modular.system.model.OrderPrivateCar;
import com.stylefeng.guns.modular.system.service.IDriverService;
import com.stylefeng.guns.modular.system.service.IOrderPositionService;
import com.stylefeng.guns.modular.system.service.IOrderPrivateCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.util.*;
import java.util.regex.Pattern;
 
/**
 * 上传安全平台数据
 */
@Component
public class PushMinistryOfTransportUtil {
 
    @Resource
    private OrderCancelMapper orderCancelMapper;
 
    @Autowired
    private GDMapGeocodingUtil gdMapGeocodingUtil;
 
    @Autowired
    private IOrderPrivateCarService orderPrivateCarService;
 
    @Autowired
    private IDriverService driverService;
 
    @Autowired
    private HttpClientUtil httpClientUtil;
 
    private String path = "http://120.77.11.218:8868/";
 
 
 
 
    /**
     * 订单撤销接口
     * @param orderId
     */
    public void orderCancel(Integer orderId){
        OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId);
        Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
        OrderCancel query = orderCancelMapper.query(orderId, 1, null, null, 2);
        Map<String, String> geocode = null;
        try {
            geocode = gdMapGeocodingUtil.geocode(orderPrivateCar.getBoardingLon().toString(),
                    orderPrivateCar.getBoardingLat().toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("Address", Integer.valueOf(geocode.get("districtCode")));//上车地点行政区划代码
        jsonObject.put("OrderId", orderPrivateCar.getOrderNum());//订单编号
        jsonObject.put("OrderTime", orderPrivateCar.getOrderNum());//订单时间YYYYMMDDhhmmss
        jsonObject.put("CancelTime", query.getInsertTime());//订单撤销时间YYYYMMDDhhmmss
        jsonObject.put("Operator", "3");//撤销发起方(1:乘客,2:驾驶员,3:平台公司)
        jsonObject.put("CancelTypeCode", null != driver ? driver.getDriveCard() : "");//机动车驾驶证编号
        jsonObject.put("CancelReason", query.getReason());//撤销或违约原因
        Map<String, Object> map = new HashMap<>();
        map.put("orderCancel", jsonObject.toJSONString());
 
        Map<String, String> header = new HashMap<>();
        header.put("Connection", "keep-alive");
        header.put("Content-Type", "application/x-www-form-urlencoded");
        header.put("Accept", "*/*");
        header.put("Accept-Encoding", "gzip");
        header.put("Accept-Charset", "utf-8");
        String result = httpClientUtil.pushHttpRequset("POST", path + "ministryOfTransport/orderCancel", map,header,"form");
        System.err.println("------------------------订单撤销接口-------------------:" + result);
    }
 
 
 
 
 
 
 
    private int phoneExp(String phone){
        /**
         * 中国移动号码正则
         * 139、138、137、136、135、134、147、150、151、152、157、158、159、178、182、183、184、187、188、198、195
         * 虚拟运营商号段: 1703、1705、1706、165
         **/
         String MOBILE_PATTERN = "(^1(3[4-9]|47|5[0-27-9]|65|78|8[2-478]|98)\\d{8}$)|(^170[356]\\d{7}$)";
 
        /**
         * 中国电信号码正则
         * 133、149、153、173、177、180、181、189、199、191
         * 虚拟运营商号段: 162、1700、1701、1702
         **/
         String TELECOM_PATTERN = "(^1(33|49|53|62|7[37]|8[019]|9[19])\\d{8}$)|(^170[012]\\d{7}$)";
 
        /**
         * 中国联通号码正则
         * 130、131、132、155、156、185、186、145、175、176、166、140
         * 虚拟运营商号段: 171、1707、1708、1709、167
         **/
         String UNICOM_PATTERN = "(^1(3[0-2]|4[05]|5[56]|6[67]|7[156]|8[56])\\d{8}$)|(^170[7-9]\\d{7}$)";
        if(Pattern.matches(UNICOM_PATTERN, phone)){
           return 1;
        }
        if(Pattern.matches(MOBILE_PATTERN, phone)){
            return 2;
        }
        if(Pattern.matches(TELECOM_PATTERN, phone)){
            return 3;
        }
        return 4;
    }
}