| | |
| | | import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; |
| | | import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService; |
| | | import com.stylefeng.guns.modular.crossCity.server.impl.OrderCrossCityServiceImpl; |
| | | import com.stylefeng.guns.modular.smallLogistics.model.OrderLogistics; |
| | | import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService; |
| | | import com.stylefeng.guns.modular.specialTrain.dao.OrderPrivateCarMapper; |
| | | import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar; |
| | | import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService; |
| | | import com.stylefeng.guns.modular.system.dao.*; |
| | | import com.stylefeng.guns.modular.system.dao.RegionMapper; |
| | | import com.stylefeng.guns.modular.system.dao.SensitiveWordsMapper; |
| | | import com.stylefeng.guns.modular.system.dao.SysIntegralMapper; |
| | | import com.stylefeng.guns.modular.system.dao.UserActivityDiscount1Mapper; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.*; |
| | |
| | | import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; |
| | | import com.stylefeng.guns.modular.taxi.service.IPaymentRecordService; |
| | | import com.stylefeng.guns.modular.taxi.service.ITransactionDetailsService; |
| | | import org.bouncycastle.crypto.tls.MACAlgorithm; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | |
| | | |
| | | @Autowired |
| | | private IUserRedPacketRecordService userRedPacketRecordService; |
| | | |
| | | |
| | | @Autowired |
| | | private GDMapGeocodingUtil gdMapGeocodingUtil; |
| | | |
| | | |
| | | @Autowired |
| | | private ICompanyCityService companyCityService; |
| | | |
| | | |
| | | @Autowired |
| | | private PushUtil pushUtil; |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | |
| | | @Resource |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | @Autowired |
| | | private RestTemplate internalRestTemplate; |
| | | |
| | | |
| | | @Autowired |
| | | private IUserActivityRedenvelopeService userActivityRedenvelopeService; |
| | | |
| | | |
| | | @Autowired |
| | | private IDriverOrdersService driverOrdersService; |
| | | |
| | | |
| | | @Autowired |
| | | private IIncomeService incomeService; |
| | | |
| | |
| | | public synchronized ResultUtil<BaseWarpper> taxiOrder(OrderTaxi orderTaxi, Integer uid) throws Exception { |
| | | //定义用户所属公司 |
| | | UserInfo userInfo1 = userInfoService.selectById(uid); |
| | | if (null == userInfo1 || userInfo1.getFlag() == 3) { |
| | | return ResultUtil.error("无效的账户"); |
| | | } |
| | | if (2 == userInfo1.getState()) { |
| | | return ResultUtil.error("账号已被冻结,请联系管理员"); |
| | | } |
| | | Company query = companyCityService.query(String.valueOf(orderTaxi.getStartLon()), String.valueOf(orderTaxi.getStartLat())); |
| | | if(null == query){ |
| | | if (null == query) { |
| | | return ResultUtil.error("出发点暂未开通"); |
| | | } |
| | | if(null != userInfo1.getCompanyId() && 0 != userInfo1.getCompanyId()){ |
| | | if (null != userInfo1.getCompanyId() && 0 != userInfo1.getCompanyId()) { |
| | | userInfo1.setCompanyId(query.getId()); |
| | | userInfoService.updateById(userInfo1); |
| | | } |
| | | |
| | | if(orderTaxi.getTravelTime().getTime() > (System.currentTimeMillis() + 600000)){ |
| | | |
| | | if (orderTaxi.getTravelTime().getTime() > (System.currentTimeMillis() + 600000)) { |
| | | orderTaxi.setOrderType(2); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 1.出租车、专车、跨城有待支付的订单不能叫车 |
| | | * 2.小件物流有未完成的订单可以下跨城、专车、出租车 |
| | |
| | | System.out.println("取消订单:"+query); |
| | | if(null != query){ |
| | | if(payType == 1){//微信支付 |
| | | String value = redisUtil.getValue("appletOpenId"); |
| | | String value = (String) redisTemplate.opsForValue().get("appletOpenId"); |
| | | String appletsOpenId = null; |
| | | if(ToolUtil.isNotEmpty(value)){ |
| | | JSONObject jsonObject = JSON.parseObject(value); |
| | |
| | | // resultUtil = ResultUtil.error(map.get("msg"), ""); |
| | | // } |
| | | } |
| | | if(payType == 3){//余额支付 |
| | | if(userInfo.getBalance() != null && userInfo.getBalance() < query.getMoney()){ |
| | | if(payType == 3) {//余额支付 |
| | | if (userInfo.getBalance() != null && userInfo.getBalance() < query.getMoney()) { |
| | | return ResultUtil.error("余额不足,无法完成支付"); |
| | | } |
| | | resultUtil= appOrderController.moneyPay(id,userInfo.getId(),query.getMoney()); |
| | | if(resultUtil.getCode()==500){ |
| | | return ResultUtil.error("电子余额不足,无法完成支付"); |
| | | } |
| | | |
| | | // resultUtil= appOrderController.moneyPay(id,userInfo.getId(),query.getMoney()); |
| | | // if(resultUtil.getCode()==500){ |
| | | // return ResultUtil.error("电子余额不足,无法完成支付"); |
| | | // } |
| | | |
| | | userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(query.getMoney())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | //添加交易明细 |
| | | transactionDetailsService.saveData(uid, "出租车取消订单", query.getMoney(), 2, 1, 1, 2, id); |
| | | userInfoService.updateById(userInfo); |
| | | |
| | | |
| | | //解除小号绑定 |
| | | if(orderTaxi.getBindId() != null){ |
| | | if (orderTaxi.getBindId() != null) { |
| | | chinaMobileUtil.midAxbUnBindSend(orderTaxi.getBindId(), orderTaxi.getTelX(), (System.currentTimeMillis() + 600000)); |
| | | } |
| | | |
| | |
| | | }).start(); |
| | | |
| | | //用户付款后,删除限制司机6分钟不能接单的标识 |
| | | String vehicle = redisUtil.getValue("VEHICLE"); |
| | | String vehicle = (String) redisTemplate.opsForValue().get("VEHICLE"); |
| | | if(ToolUtil.isNotEmpty(vehicle)){ |
| | | JSONArray jsonArray = JSON.parseArray(vehicle); |
| | | for(int i = 0; i < jsonArray.size(); i++){ |
| | |
| | | break; |
| | | } |
| | | } |
| | | redisUtil.setStrValue("VEHICLE", jsonArray.toJSONString()); |
| | | redisTemplate.opsForValue().set("VEHICLE", jsonArray.toJSONString()); |
| | | } |
| | | systemNoticeService.addSystemNotice(1, "您已使用余额成功完成出行订单支付,谢谢使用!", uid, 1); |
| | | } |
| | |
| | | }).start(); |
| | | |
| | | //用户付款后,删除限制司机6分钟不能接单的标识 |
| | | String vehicle = redisUtil.getValue("VEHICLE"); |
| | | String vehicle = (String) redisTemplate.opsForValue().get("VEHICLE"); |
| | | if(ToolUtil.isNotEmpty(vehicle)){ |
| | | JSONArray jsonArray = JSON.parseArray(vehicle); |
| | | for(int i = 0; i < jsonArray.size(); i++){ |
| | |
| | | break; |
| | | } |
| | | } |
| | | redisUtil.setStrValue("VEHICLE", jsonArray.toJSONString()); |
| | | redisTemplate.opsForValue().set("VEHICLE", jsonArray.toJSONString()); |
| | | } |
| | | systemNoticeService.addSystemNotice(1, "您已使用余额成功完成出行订单支付,谢谢使用!", uid, 1); |
| | | |
| | |
| | | if(Integer.valueOf(String.valueOf(map.get("state"))) == 11){ |
| | | map.put("state", map.get("oldState")); |
| | | } |
| | | String driverId = redisUtil.getValue("DEVICE_" + map.get("driverId")); |
| | | String driverId = (String) redisTemplate.opsForValue().get("DEVICE_" + map.get("driverId")); |
| | | map.put("device", ToolUtil.isNotEmpty(driverId) ? 2 : 1); |
| | | map.put("orderType", 2); |
| | | return map; |
| | |
| | | public OrderServerWarpper queryOrderServer(Integer orderId, Integer uid) throws Exception { |
| | | OrderServerWarpper orderServerWarpper = new OrderServerWarpper(); |
| | | OrderTaxi orderTaxi = this.selectById(orderId); |
| | | if(null == orderTaxi){ |
| | | if (null == orderTaxi) { |
| | | return orderServerWarpper; |
| | | } |
| | | //计算预计距离和剩余时间 |
| | | String value = redisUtil.getValue("DRIVER" + String.valueOf(orderTaxi.getDriverId())); |
| | | if(null == value || "".equals(value)){ |
| | | System.err.println("司机没有上传位置信息"); |
| | | |
| | | //调用获取轨迹中的数据 |
| | | List<Map<String, Object>> list = orderPositionService.queryTrack(orderId, 2); |
| | | if(list.size() > 0){ |
| | | Map<String, Object> map = list.get(list.size() - 1); |
| | | value = map.get("lon") + "," + map.get("lat"); |
| | | String value = null; |
| | | if (null != orderTaxi.getDriverId()) { |
| | | value = (String) redisTemplate.opsForValue().get("DRIVER" + orderTaxi.getDriverId()); |
| | | if (null == value || "".equals(value)) { |
| | | System.err.println("司机没有上传位置信息"); |
| | | |
| | | //调用获取轨迹中的数据 |
| | | List<Map<String, Object>> list = orderPositionService.queryTrack(orderId, 2); |
| | | if (list.size() > 0) { |
| | | Map<String, Object> map = list.get(list.size() - 1); |
| | | value = map.get("lon") + "," + map.get("lat"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | orderServerWarpper.setOrderId(orderTaxi.getId()); |
| | | orderServerWarpper.setOrderType(2); |
| | | orderServerWarpper.setState(orderTaxi.getState()); |
| | | orderServerWarpper.setLon(null != value ? value.split(",")[0] : "0.0"); |
| | | orderServerWarpper.setLat(null != value ? value.split(",")[1] : "0.0"); |
| | | orderServerWarpper.setReassignNotice(orderTaxi.getReassignNotice()); |
| | | if(orderTaxi.getState() == 2 || orderTaxi.getState() == 3){//前往预约地 |
| | | if (orderTaxi.getState() == 2 || orderTaxi.getState() == 3) {//前往预约地 |
| | | // TODO: 2023/11/4 无法修改 |
| | | Map<String, String> distance = gdMapElectricFenceUtil.getDistance(value, orderTaxi.getStartLon() + "," + orderTaxi.getStartLat(), 1); |
| | | String d = "0"; |
| | | String t = "0"; |
| | | if(null == distance){ |
| | | if (null == distance) { |
| | | System.err.println("查询距离出错了"); |
| | | }else{ |
| | | } else { |
| | | d = new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000), new MathContext(2, RoundingMode.HALF_EVEN)).toString(); |
| | | t = new BigDecimal(distance.get("duration")).divide(new BigDecimal(60), new MathContext(2, RoundingMode.HALF_EVEN)).intValue() + ""; |
| | | } |
| | |
| | | userRedPacketRecord.setUserId(orderTaxi.getUserId()); |
| | | userRedPacketRecordService.insert(userRedPacketRecord); |
| | | } |
| | | appOrderController.moneyPay(orderTaxi.getId(),orderTaxi.getUserId(),money); |
| | | // appOrderController.moneyPay(orderTaxi.getId(),orderTaxi.getUserId(),money); |
| | | return ResultUtil.success(baseWarpper); |
| | | } |
| | | |
| | |
| | | }).start(); |
| | | |
| | | //用户付款后,删除限制司机6分钟不能接单的标识 |
| | | String vehicle = redisUtil.getValue("VEHICLE"); |
| | | String vehicle = (String) redisTemplate.opsForValue().get("VEHICLE"); |
| | | if(ToolUtil.isNotEmpty(vehicle)){ |
| | | JSONArray jsonArray = JSON.parseArray(vehicle); |
| | | for(int i = 0; i < jsonArray.size(); i++){ |
| | |
| | | break; |
| | | } |
| | | } |
| | | redisUtil.setStrValue("VEHICLE", jsonArray.toJSONString()); |
| | | redisTemplate.opsForValue().set("VEHICLE", jsonArray.toJSONString()); |
| | | } |
| | | |
| | | |
| | |
| | | public void run() { |
| | | try { |
| | | orderIds.add(orderTaxi.getId());//添加记录,防止调用接口重复提醒无人接单 |
| | | String vehicle = redisUtil.getValue("VEHICLE"); |
| | | String vehicle = (String) redisTemplate.opsForValue().get("VEHICLE"); |
| | | List<Integer> integers = new ArrayList<>(); |
| | | if(ToolUtil.isNotEmpty(vehicle)){ |
| | | if (ToolUtil.isNotEmpty(vehicle)) { |
| | | integers = JSON.parseArray(vehicle).toJavaList(Integer.class); |
| | | } |
| | | Company query = companyCityService.query(String.valueOf(orderTaxi.getStartLon()), String.valueOf(orderTaxi.getStartLat()));//获取起点所属分公司 |
| | | List<PushOrder> querys = pushOrderService.querys(null, 2, query.getId());//获取需要推送的次数 |
| | | boolean b = false; |
| | | for(int i = 1; i <= querys.size(); i++){ |
| | | if(b){ |
| | | for (int i = 1; i <= querys.size(); i++) { |
| | | PushOrder pushOrder = pushOrderService.querys(i, 2, query.getId()).get(0); |
| | | System.out.println("pushOrder:" + pushOrder); |
| | | //获取空闲司机 |
| | | List<Driver> list = driverService.queryIdleDriver(2, orderTaxi.getStartLon(), orderTaxi.getStartLat(), pushOrder.getPushDistance(), null);//所有附近空闲司机 |
| | | if (list.size() > 0) { |
| | | double driverProportion = pushOrder.getDriverProportion() / 100;//推送占比计算成小数 |
| | | int lastIndex = Double.valueOf(list.size() * driverProportion).intValue();//计算占比转成整数(下标截取) |
| | | lastIndex = lastIndex == 0 ? list.size() : lastIndex; |
| | | list = list.subList(0, lastIndex);//获取空闲司机中占比数据 |
| | | for (Driver driver : list) {//开始进行推送 |
| | | //查询是否在限制推单范围内 |
| | | boolean bo = false; |
| | | for (Integer integer : integers) { |
| | | if (integer.compareTo(driver.getId()) == 0) { |
| | | bo = true; |
| | | break; |
| | | } |
| | | } |
| | | if (bo) { |
| | | continue; |
| | | } |
| | | pushUtil.pushOrderState(2, driver.getId(), orderTaxi.getId(), 2, orderTaxi.getState(), pushOrder.getPushTime()); |
| | | } |
| | | } |
| | | Thread.sleep(pushOrder.getPushTime() * 1000);//设置等待时间 |
| | | OrderTaxi orderTaxi1 = OrderTaxiServiceImpl.this.selectById(orderTaxi.getId()); |
| | | Integer state = orderTaxi1.getState(); |
| | | if (state != 1) { |
| | | break; |
| | | } |
| | | PushOrder pushOrder = pushOrderService.querys(i, 2, query.getId()).get(0); |
| | | System.out.println("pushOrder:"+pushOrder); |
| | | int i2 = pushOrder.getPushTime() / 10; |
| | | if(i2==0){ |
| | | i2=1; |
| | | } |
| | | System.out.println(i2); |
| | | for (int i1 = 0; i1 < i2 ; i1++) { |
| | | Integer state = 0; |
| | | //批量订单 |
| | | if(type == 3){ |
| | | OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderTaxi.getId()); |
| | | if(null == orderPrivateCar || orderPrivateCar.getState() != 1){ |
| | | b = true; |
| | | break; |
| | | } |
| | | }else{ |
| | | state = orderTaxiMapper.selectById(orderTaxi.getId()).getState(); |
| | | if(state != 1){ |
| | | b = true; |
| | | break; |
| | | } |
| | | } |
| | | //获取空闲司机 |
| | | List<Driver> list = driverService.queryIdleDriver(2, orderTaxi.getStartLon(), orderTaxi.getStartLat(), pushOrder.getPushDistance(), null);//所有附近空闲司机 |
| | | if(list.size() > 0){ |
| | | double driverProportion = pushOrder.getDriverProportion() / 100;//推送占比计算成小数 |
| | | int lastIndex = Double.valueOf(list.size() * driverProportion).intValue();//计算占比转成整数(下标截取) |
| | | lastIndex = lastIndex == 0 ? list.size() : lastIndex; |
| | | list = list.subList(0, lastIndex);//获取空闲司机中占比数据 |
| | | for(Driver driver : list){//开始进行推送 |
| | | //查询是否在限制推单范围内 |
| | | boolean bo = false; |
| | | for(Integer integer : integers){ |
| | | if(integer.compareTo(driver.getId()) == 0){ |
| | | bo = true; |
| | | break; |
| | | } |
| | | } |
| | | if(bo){ |
| | | continue; |
| | | } |
| | | pushUtil.pushOrderState(2, driver.getId(), orderTaxi.getId(), 2, orderTaxi.getState(), pushOrder.getPushTime()); |
| | | } |
| | | } |
| | | Thread.sleep( 10000);//设置等待时间 |
| | | if(i == querys.size() && state == 1){ |
| | | pushUtil.pushEndPush(1, orderTaxi.getUserId(), orderTaxi.getId(), 2); |
| | | orderIds.remove(orderTaxi.getId()); |
| | | } |
| | | if (i == querys.size() && state == 1) { |
| | | pushUtil.pushEndPush(1, orderTaxi.getUserId(), orderTaxi.getId(), 2); |
| | | orderIds.remove(orderTaxi.getId()); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | resultUtil = payMoneyUtil.alipay("感谢费", "感谢费", "", orderId + "_2_" + UUIDUtil.getRandomCode(5), money.toString(), "/base/aliPayThankYouFee"); |
| | | paymentRecordService.saveData(1, uid, 1, orderId, 2, 2, money, "", 1);//添加预支付数据 |
| | | } |
| | | if(payType == 3){//余额支付 |
| | | if(userInfo.getBalance() == null || userInfo.getBalance() < money){ |
| | | if(payType == 3) {//余额支付 |
| | | if (userInfo.getBalance() == null || userInfo.getBalance() < money) { |
| | | return ResultUtil.error("余额不足,无法完成支付"); |
| | | } |
| | | resultUtil= appOrderController.moneyPay(orderId,userInfo.getId(),money); |
| | | if(resultUtil.getCode()==500){ |
| | | return ResultUtil.error("电子余额不足,无法完成支付"); |
| | | } |
| | | // resultUtil= appOrderController.moneyPay(orderId,userInfo.getId(),money); |
| | | // if(resultUtil.getCode()==500){ |
| | | // return ResultUtil.error("电子余额不足,无法完成支付"); |
| | | // } |
| | | userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | |
| | | |
| | | SysIntegral query1 = sysIntegralMapper.query(orderTaxi.getCompanyId()); |
| | | userInfo.setIntegral(userInfo.getIntegral() + (money.intValue() * query1.getIntegral()));//积分 |
| | | |
| | | |
| | | //添加交易明细 |
| | | transactionDetailsService.saveData(uid, "出租车-感谢费", money, 2, 1, 1, 2, orderId); |
| | | userInfoService.updateById(userInfo); |
| | | |
| | | |
| | | orderTaxi.setThankYouFee(money); |
| | | this.updateById(orderTaxi); |
| | | |