Pu Zhibing
4 天以前 4c4dc127cdc9c41f2bfb3c138108529856e031b8
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
package com.supersavedriving.user.modular.system.service.impl;
 
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.supersavedriving.user.core.util.ToolUtil;
import com.supersavedriving.user.modular.system.dao.TOrderCheckMapper;
import com.supersavedriving.user.modular.system.model.*;
import com.supersavedriving.user.modular.system.service.*;
import com.supersavedriving.user.modular.system.util.*;
import com.supersavedriving.user.modular.system.util.GaoDe.MapUtil;
import com.supersavedriving.user.modular.system.util.GaoDe.model.District;
import com.supersavedriving.user.modular.system.warpper.*;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 订单 服务实现类
 * </p>
 *
 * @author administrator
 * @since 2025-07-23
 */
@Service
@Log4j2
public class TOrderCheckServiceImpl extends ServiceImpl<TOrderCheckMapper, TOrderCheck> implements TOrderCheckService {
 
    @Autowired
    private IAppUserService appUserService;
 
    @Autowired
    private IBranchOfficeService branchOfficeService;
 
    @Autowired
    private ISystemConfigService systemConfigService;
 
    @Autowired
    private IDriverService driverService;
 
    @Autowired
    private IRevenueService revenueService;
 
    @Autowired
    private IAccountChangeDetailService accountChangeDetailService;
 
    @Autowired
    private PushUtil pushUtil;
 
    @Autowired
    private TUserCouponService tUserCouponService;
 
    @Autowired
    private TCheckCarExplainService tCheckCarExplainService;
 
 
    @Resource
    private RedisTemplate<String, String> redisTemplate;
 
    @Override
    public ResultUtil travelOrder(Integer uid, CheckOrder checkOrder) {
        // 102=已接单(正在前往取车地),104=到达预约点(用户待支付车检),105=开始服务,106=车检完成,107=前往还车地,108=到达还车地
        List<Integer> state = Arrays.asList(101, 102,  104, 105, 106, 107, 107, 108);
        TOrderCheck order = this.selectOne(new EntityWrapper<TOrderCheck>().eq("userId", uid).eq("status", 1).in("state", state));
        if(null != order){
            return ResultUtil.error("您还有正在进行的订单");
        }
        AppUser appUser = appUserService.selectById(uid);
        order = this.selectOne(new EntityWrapper<TOrderCheck>().eq("userPhone", appUser.getPhone()).eq("status", 1).in("state", state));
        if(null != order){
            return ResultUtil.error("您还有正在进行的订单");
        }
 
 
        String startAddress = checkOrder.getStartAddress();
        startAddress = startAddress.replaceAll("& #40;", "(");
        startAddress = startAddress.replaceAll("& #41;", ")");
        checkOrder.setStartAddress(startAddress);
        if(ToolUtil.isNotEmpty(checkOrder.getEndAddress())){
            String endAddress = checkOrder.getEndAddress();
            endAddress = endAddress.replaceAll("& #40;", "(");
            endAddress = endAddress.replaceAll("& #41;", ")");
            checkOrder.setEndAddress(endAddress);
        }
 
        order = new TOrderCheck();
 
        if(checkOrder.getReInspection()!=null && checkOrder.getReInspection()==1){
            TOrderCheck tOrderCheck = this.selectById(checkOrder.getOrderId());
            if(tOrderCheck.getCheckStatus()!=2){
                return ResultUtil.error("你已通过车检,无需重复提交");
            }
            // 支付了车检  下次不用支付
            if(tOrderCheck.getCheckPayTime()!=null){
                order.setReInspection(1);
            }
 
        }
 
 
        BeanUtils.copyProperties(checkOrder, order);
        order.setStartLng(checkOrder.getUserLng());
        order.setStartLat(checkOrder.getUserLat());
        order.setUserId(uid);
        order.setStatus(1);
        order.setCreateTime(new Date());
        order.setState(100);
        String city = "";
        Integer branchOfficeId = null;
        District geocode = MapUtil.geocode(checkOrder.getUserLng().toString(), checkOrder.getUserLat().toString());
        if(null != geocode){
            String districtCode = geocode.getDistrictCode();
            order.setAreaCode(districtCode);
            BranchOffice branchOffice = branchOfficeService.selectOne(new EntityWrapper<BranchOffice>().eq("status", 1).eq("districtCode", districtCode));
            if(null == branchOffice){
                String cityCode = geocode.getCityCode();
 
                branchOffice = branchOfficeService.selectOne(new EntityWrapper<BranchOffice>().eq("status", 1).eq("cityCode", cityCode));
                if(null == branchOffice){
                    String provinceCode = geocode.getProvinceCode();
                    branchOffice = branchOfficeService.selectOne(new EntityWrapper<BranchOffice>().eq("status", 1).eq("provinceCode", provinceCode));
                }
            }
            if(null == branchOffice){
                return ResultUtil.error("暂无企业服务");
            }
            branchOfficeId = branchOffice.getId();
        }else {
            return ResultUtil.error("暂无企业服务");
        }
        order.setCreateTime(new Date());
        order.setBranchOfficeId(branchOfficeId);
 
        order = getOrderPrice(branchOfficeId,order);
 
        this.insert(order);
 
 
 
        // 添加代检车新订单通知到Redis
        addCheckCarOrderNotification(order.getId(), branchOfficeId);
 
 
        return ResultUtil.success(order.getId());
    }
 
    /**
     * 添加代检车新订单通知到Redis
     * @param orderId 订单ID
     * @param branchOfficeId 分公司ID
     */
    private void addCheckCarOrderNotification(Integer orderId, Integer branchOfficeId) {
        try {
            String orderIdStr = orderId.toString();
 
            // 添加到平台通知队列(使用Redis List)
            String platformKey = "newCheckCarOrder:platform";
            List<String> existingPlatformOrders = redisTemplate.opsForList().range(platformKey, 0, -1);
 
            // 检查是否已存在该订单ID,避免重复
            if (existingPlatformOrders == null || !existingPlatformOrders.contains(orderIdStr)) {
                // 添加到列表左侧
                redisTemplate.opsForList().leftPush(platformKey, orderIdStr);
                // 设置过期时间24小时
                redisTemplate.expire(platformKey, 24, TimeUnit.HOURS);
            }
 
            // 添加到分公司通知队列(使用Redis List)
            String branchKey = "newCheckCarOrder:branch:" + branchOfficeId;
            List<String> existingBranchOrders = redisTemplate.opsForList().range(branchKey, 0, -1);
 
            // 检查是否已存在该订单ID,避免重复
            if (existingBranchOrders == null || !existingBranchOrders.contains(orderIdStr)) {
                // 添加到列表左侧
                redisTemplate.opsForList().leftPush(branchKey, orderIdStr);
                // 设置过期时间24小时
                redisTemplate.expire(branchKey, 24, TimeUnit.HOURS);
            }
 
 
        } catch (Exception e) {
            log.error("添加代检车新订单通知到Redis失败: 订单ID={}, 分公司ID={}, 错误: {}", orderId, branchOfficeId, e.getMessage(), e);
            // 通知失败不影响主流程,只记录日志
        }
    }
 
    @Override
    public ResultUtil getCheckOrderInfo(String userLat, String userLng) {
        District geocode = MapUtil.geocode(userLng, userLat);
        if(null != geocode){
            String districtCode = geocode.getDistrictCode();
            BranchOffice branchOffice = branchOfficeService.selectOne(new EntityWrapper<BranchOffice>().eq("status", 1).eq("districtCode", districtCode));
            if(null == branchOffice){
                String cityCode = geocode.getCityCode();
 
                branchOffice = branchOfficeService.selectOne(new EntityWrapper<BranchOffice>().eq("status", 1).eq("cityCode", cityCode));
                if(null == branchOffice){
                    String provinceCode = geocode.getProvinceCode();
                    branchOffice = branchOfficeService.selectOne(new EntityWrapper<BranchOffice>().eq("status", 1).eq("provinceCode", provinceCode));
                }
            }
            if(null == branchOffice){
                TCheckCarExplain branchOfficeId = tCheckCarExplainService.selectOne(new EntityWrapper<TCheckCarExplain>().eq("branchOfficeId", -1).last(" limit 1"));
                return ResultUtil.success(branchOfficeId);
            }
            Integer id = branchOffice.getId();
            TCheckCarExplain branchOfficeId = tCheckCarExplainService.selectOne(new EntityWrapper<TCheckCarExplain>().eq("branchOfficeId", id).orderBy("id", false).last(" limit 1"));
            return ResultUtil.success(branchOfficeId);
 
        }
        TCheckCarExplain branchOfficeId = tCheckCarExplainService.selectOne(new EntityWrapper<TCheckCarExplain>().eq("branchOfficeId", -1).last(" limit 1"));
        return ResultUtil.success(branchOfficeId);
    }
 
    @Override
    public ResultUtil cancelOrder(Integer uid, Long orderId) {
        TOrderCheck order = this.selectById(orderId);
        if(null == order){
            return ResultUtil.error("订单不存在");
        }
        if(order.getUserId() != uid){
            return ResultUtil.error("无权限取消");
        }
        if(order.getState() > 100){
            return ResultUtil.error("不能取消订单");
        }
        order.setState(111);
        this.updateById(order);
        return ResultUtil.success();
    }
 
    @Override
    public ResultUtil payCheckOrder(Integer uid, PayCheckOrder payCheckOrder) throws Exception {
        TOrderCheck order = this.selectById(payCheckOrder.getOrderId());
 
        AppUser appUser = appUserService.selectById(uid);
 
        //开始支付操作
        if(payCheckOrder.getType() == 1){//车检费
            if(payCheckOrder.getCouponId()!=null){
                TUserCoupon tUserCoupon = tUserCouponService.selectById(payCheckOrder.getCouponId());
                if(null == tUserCoupon){
                    return ResultUtil.error("优惠券不存在");
                }
                if(tUserCoupon.getExpireTime().getTime()<System.currentTimeMillis()){
                    return ResultUtil.error("优惠券已过期");
                }
                if(!tUserCoupon.getUserId().equals(uid)){
                    return ResultUtil.error("无此优惠券");
                }
                if (!tUserCoupon.getAreaCode().equals(order.getAreaCode())) {
                    return ResultUtil.error("该优惠券不可用");
                }
                // 计算新的价格
                order.setCheckMoney(order.getCheckMoney().subtract(tUserCoupon.getMoney()));
                order.setDiscountedPriceCheck(tUserCoupon.getMoney());
                order.setCouponIdCheck(tUserCoupon.getId());
            }
            order.setCheckCode(UUIDUtil.getTimeStr() + UUIDUtil.getNumberRandom(5));
            this.updateById(order);
            return weixinPay(order, appUser, order.getCheckMoney(), order.getCheckCode(),"车检费");
        }else if(payCheckOrder.getType()==2){
            if(payCheckOrder.getCouponId()!=null){
                TUserCoupon tUserCoupon = tUserCouponService.selectById(payCheckOrder.getCouponId());
                if(null == tUserCoupon){
                    return ResultUtil.error("优惠券不存在");
                }
                if(tUserCoupon.getExpireTime().getTime()<System.currentTimeMillis()){
                    return ResultUtil.error("优惠券已过期");
                }
                if(!tUserCoupon.getUserId().equals(uid)){
                    return ResultUtil.error("无此优惠券");
                }
                if (!tUserCoupon.getAreaCode().equals(order.getAreaCode())) {
                    return ResultUtil.error("该优惠券不可用");
                }
                // 计算新的价格
                order.setPayMoney(order.getPayMoney().subtract(tUserCoupon.getMoney()));
                order.setDiscountedPrice(tUserCoupon.getMoney());
                if(order.getBranchOfficeId()!=null){
                    SystemConfig systemConfig1 = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 3).eq("companyId", order.getBranchOfficeId()));
                    if(systemConfig1!=null) {
                        JSONObject jsonObject1 = JSON.parseObject(systemConfig1.getContent());
                        Double num5 = jsonObject1.getDouble("num5");
                        SystemConfig systemConfig2 = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 3).eq("companyId", 1).eq("branchOfficeId", order.getBranchOfficeId()));
                        if(systemConfig2!=null){
                            JSONObject jsonObject2 = JSON.parseObject(systemConfig2.getContent());
                            // 平台抽成
                            Double num6 = jsonObject2.getDouble("num5");
                            if(num6!=null){
                                num6 = num5 - num6;
                                order.setCompanyMoney(new BigDecimal(num6));
                            }
                        }
 
                        order.setOrderMoney(order.getPayMoney().subtract(new BigDecimal(num5)));
                    }
                }else {
                    Driver driver = driverService.selectById(order.getDriverId());
                    SystemConfig systemConfig1 = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 3).eq("companyId", driver.getBranchOfficeId()));
                    if(systemConfig1!=null) {
                        JSONObject jsonObject1 = JSON.parseObject(systemConfig1.getContent());
                        Double num5 = jsonObject1.getDouble("num5");
                        SystemConfig systemConfig2 = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 3).eq("companyId", 1).eq("branchOfficeId", driver.getBranchOfficeId()));
                        if(systemConfig2!=null){
                            JSONObject jsonObject2 = JSON.parseObject(systemConfig2.getContent());
                            // 平台抽成
                            Double num6 = jsonObject2.getDouble("num5");
                            if(num6!=null){
                                num6 = num5 - num6;
                                order.setCompanyMoney(new BigDecimal(num6));
                            }
                        }
 
                        order.setOrderMoney(order.getPayMoney().subtract(new BigDecimal(num5)));
                    }
                }
                order.setCouponId(tUserCoupon.getId());
            }
            order.setCode(UUIDUtil.getTimeStr() + UUIDUtil.getNumberRandom(5));
            this.updateById(order);
            return weixinPay(order, appUser, order.getPayMoney(), order.getCode(),"服务费");
        }
        return ResultUtil.success();
    }
 
    @Override
    public ResultUtil orderPayCallback(Integer type, TOrderCheck order, String s1) throws Exception {
        if(type==1){
            if(order.getState() != 104){
                return ResultUtil.success();
            }
            order.setState(105);
            order.setCheckPayTime(new Date());
            this.updateById(order);
 
            pushUtil.pushCheckOrderStatus(order.getUserId(), 1, Long.valueOf(order.getId()), order.getState());
            if(null != order.getDriverId()) {
                PushCheckOrderInfoWarpper pushOrderInfoWarpper = new PushCheckOrderInfoWarpper();
                pushOrderInfoWarpper.setId(Long.valueOf(order.getId()));
                pushOrderInfoWarpper.setState(order.getState());
                pushOrderInfoWarpper.setType(1);
                pushUtil.pushCheckOrderInfo(order.getDriverId(), 2, pushOrderInfoWarpper);
            }
            return ResultUtil.success();
        }
        if(type==2){
            Integer couponId = order.getCouponId();
            if(couponId!=null){
                // 修改已使用状态
                TUserCoupon tUserCoupon = tUserCouponService.selectById(couponId);
                tUserCoupon.setState(2);
                tUserCouponService.updateById(tUserCoupon);
            }
            if(order.getState() != 108){
                return ResultUtil.success();
            }
            order.setState(109);
            order.setPayTime(new Date());
            this.updateById(order);
            //添加收入明细
            saveCommissionWX(order);
 
            pushUtil.pushCheckOrderStatus(order.getUserId(), 1, Long.valueOf(order.getId()), order.getState());
            if(null != order.getDriverId()) {
                PushCheckOrderInfoWarpper pushOrderInfoWarpper = new PushCheckOrderInfoWarpper();
                pushOrderInfoWarpper.setId(Long.valueOf(order.getId()));
                pushOrderInfoWarpper.setState(order.getState());
                pushOrderInfoWarpper.setType(2);
                pushUtil.pushCheckOrderInfo(order.getDriverId(), 2, pushOrderInfoWarpper);
            }
            return ResultUtil.success();
        }
        return ResultUtil.success();
    }
 
    @Override
    public CheckOrderInfoWarpper queryOrderInfo(Integer uid, Long orderId) {
        TOrderCheck order = this.selectById(orderId);
        if(!order.getUserId().equals(uid)){
            return null;
        }
        CheckOrderInfoWarpper orderInfoWarpper = this.baseMapper.queryOrderInfo(orderId);
        if(ToolUtil.isEmpty(orderInfoWarpper.getAvatar())){
            orderInfoWarpper.setAvatar("https://csxdj.obs.cn-south-1.myhuaweicloud.com:443/66cc269703a84e4da87fb21e2c21ab1f.png");
        }
        orderInfoWarpper.setDriverId(order.getDriverId());
        Driver driver = driverService.selectById(orderInfoWarpper.getDriverId());
        orderInfoWarpper.setDriverAvatar(driver.getAvatar());
        orderInfoWarpper.setDriverName(driver.getName());
        orderInfoWarpper.setDriverPhone(driver.getPhone());
        return orderInfoWarpper;
    }
 
    @Override
    public List<CheckOrderListWarpper> queryCheckOrderList(Integer uid, Integer state, Integer pageNum, Integer pageSize) {
        pageNum = (pageNum - 1) * pageSize;
        return this.baseMapper.queryCheckOrderList(uid, state, pageNum, pageSize);
    }
 
    @Override
    public ResultUtil orderAppraise(Integer uid, Long orderId, Integer score, String content) {
        TOrderCheck tOrderCheck = this.baseMapper.selectById(orderId);
        if(tOrderCheck.getState() != 109 || !tOrderCheck.getUserId().equals(uid)){
            return ResultUtil.error("不能进行评价");
        }
        tOrderCheck.setCommentRate(score);
        tOrderCheck.setCommentStr(content);
        tOrderCheck.setCommentTime(new Date());
        tOrderCheck.setState(110);
        this.baseMapper.updateById(tOrderCheck);
        return ResultUtil.success();
    }
 
    @Override
    public List<CheckCouponWarpper> queryPayCouponList(Integer uid, Long orderId) {
        TOrderCheck tOrderCheck = this.baseMapper.selectById(orderId);
        if(!tOrderCheck.getUserId().equals(uid)){
            return Collections.emptyList();
        }
        List<TUserCoupon> tUserCoupons = tUserCouponService.selectList(new EntityWrapper<TUserCoupon>().eq("user_id", uid).eq("state", 1).lt("expiration_date", new Date()).eq("areaCode", tOrderCheck.getAreaCode()));
        // tUserCoupons 转化为 List<CheckCouponWarpper>
        List<CheckCouponWarpper> collect = tUserCoupons.stream().map(tUserCoupon -> {
            CheckCouponWarpper checkCouponWarpper = new CheckCouponWarpper();
            checkCouponWarpper.setId(tUserCoupon.getId());
            checkCouponWarpper.setCouponName(tUserCoupon.getCouponName());
            checkCouponWarpper.setCouponPreferentialAmount(tUserCoupon.getMoney().doubleValue());
            checkCouponWarpper.setExpirationDate(tUserCoupon.getExpireTime().getTime());
            return checkCouponWarpper;
        }).collect(Collectors.toList());
        return collect;
    }
 
 
    public void saveCommissionWX(TOrderCheck order) throws Exception{
        Driver driver = driverService.selectById(order.getDriverId());
        //司机订单收入
        Revenue revenue = new Revenue();
        revenue.setType(1);
        revenue.setUserType(2);
        revenue.setUserId(driver.getId());
        revenue.setOrderId(Long.valueOf(order.getId()));
        revenue.setAmount(order.getOrderMoney().doubleValue());
        revenue.setCreateTime(new Date());
        revenueService.insert(revenue);
 
        AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
        accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(5));
        accountChangeDetail.setUserType(2);
        accountChangeDetail.setUserId(driver.getId());
        accountChangeDetail.setType(1);
        accountChangeDetail.setChangeType(1);
        accountChangeDetail.setOrderId(Long.valueOf(order.getId()));
        accountChangeDetail.setOldData(driver.getBalance());
        accountChangeDetail.setExplain("订单收入");
        accountChangeDetail.setCreateTime(new Date());
        accountChangeDetail.setNewData(new BigDecimal(driver.getBalance()).add(order.getOrderMoney()).doubleValue());
        driver.setBalance(new BigDecimal(driver.getBalance()).add(order.getOrderMoney()).doubleValue());
        driverService.updateById(driver);
        accountChangeDetailService.saveData(accountChangeDetail);
    }
 
 
 
 
    public ResultUtil weixinPay(TOrderCheck order, AppUser appUser,BigDecimal payMoney,String code,String body) throws Exception {
        order.setPayType(1);
        return MiniAppPay.payCheck(appUser.getOpenid(), payMoney.multiply(new BigDecimal(100)).setScale(0, RoundingMode.HALF_EVEN).longValue() + "", "/base/order/orderPayCallback", code,body);
    }
 
        public TOrderCheck getOrderPrice(Integer branchOfficeId,TOrderCheck order){
        SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 5).eq("companyId", branchOfficeId));
        SystemConfig systemConfig1 = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 3).eq("companyId", branchOfficeId));
        if(null == systemConfig){
            order.setCheckMoney(BigDecimal.ZERO);
            order.setOrderMoney(BigDecimal.ZERO);
        }
        JSONObject jsonObject = JSON.parseObject(systemConfig.getContent());
        JSONObject extraCost = jsonObject.getJSONObject("ExtraCost");
 
        Double num11 = extraCost.getDouble("num11");//车检费 油车
        Double num12 = extraCost.getDouble("num12");//车检费 油车
        Double num13 = extraCost.getDouble("num13");//服务费
 
        Integer carType = order.getCarType();
        if(carType==1){
            if(num11!=null){
                order.setCheckMoney(new BigDecimal(num11));
            }
        }
        if(carType==2){
            if(num12!=null){
                order.setCheckMoney(new BigDecimal(num12));
            }
        }
 
        if(num13!=null){
            order.setPayMoney(new BigDecimal(num13));
            if(systemConfig1!=null){
                JSONObject jsonObject1 = JSON.parseObject(systemConfig1.getContent());
                // 分公司抽成
                Double num5 = jsonObject1.getDouble("num5");
                SystemConfig systemConfig2 = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 3).eq("companyId", 1).eq("branchOfficeId", branchOfficeId));
                if(systemConfig2!=null){
                    JSONObject jsonObject2 = JSON.parseObject(systemConfig2.getContent());
                    // 平台抽成
                    Double num6 = jsonObject2.getDouble("num5");
                    if(num6!=null){
                        num6 = num5 - num6;
                        order.setCompanyMoney(new BigDecimal(num6));
                    }
                }
                order.setOrderMoney(order.getPayMoney().subtract(new BigDecimal(num5)));
            }else {
                order.setOrderMoney(order.getPayMoney());
            }
 
        }
        return order;
    }
 
}