| | |
| | | import com.stylefeng.guns.modular.taxi.service.IPaymentRecordService; |
| | | import com.stylefeng.guns.modular.taxi.service.ITransactionDetailsService; |
| | | import com.stylefeng.guns.modular.taxi.service.impl.OrderTaxiServiceImpl; |
| | | import io.swagger.models.auth.In; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | } |
| | | |
| | | //计算折扣 |
| | | UserActivityDiscount1 query2 = userActivityDiscount1Mapper.query(orderCrossCity.getCompanyId()); |
| | | if(null != query2){ |
| | | Double special = query2.getSpecial(); |
| | | orderCrossCity.setDiscount(special); |
| | | double v = new BigDecimal(orderMoney).multiply(new BigDecimal(special / 10)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); |
| | | if(orderMoney.compareTo(v) > 0){ |
| | | orderCrossCity.setDiscountMoney(orderMoney - v); |
| | | orderCrossCity.setActivityId(query2.getId()); |
| | | orderMoney = v; |
| | | } |
| | | } |
| | | // UserActivityDiscount1 query2 = userActivityDiscount1Mapper.query(orderCrossCity.getCompanyId()); |
| | | // if(null != query2){ |
| | | // Double special = query2.getSpecial(); |
| | | // orderCrossCity.setDiscount(special); |
| | | // double v = new BigDecimal(orderMoney).multiply(new BigDecimal(special / 10)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); |
| | | // if(orderMoney.compareTo(v) > 0){ |
| | | // orderCrossCity.setDiscountMoney(orderMoney - v); |
| | | // orderCrossCity.setActivityId(query2.getId()); |
| | | // orderMoney = v; |
| | | // } |
| | | // } |
| | | |
| | | if(payType == 1){//微信支付 |
| | | String app = type == 1 ? "APP" : "JSAPI"; |
| | |
| | | if(null == distance){ |
| | | System.err.println("查询距离出错了"); |
| | | }else{ |
| | | d = new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000), new MathContext(2, RoundingMode.HALF_EVEN)).toString(); |
| | | d = new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000), new MathContext(2, RoundingMode.HALF_EVEN)).toPlainString(); |
| | | t = new BigDecimal(distance.get("duration")).divide(new BigDecimal(60), new MathContext(2, RoundingMode.HALF_EVEN)).intValue() + ""; |
| | | } |
| | | orderServerWarpper.setReservationMileage("0"); |
| | |
| | | @Override |
| | | public ResultUtil<BaseWarpper> saveOrderFerry(String serverCarModelIds, Date travelTime, String placementLon, String placementLat, String startLon, |
| | | String startLat, String startAddress, String endLon, String endLat, String endAddress, Integer crossCityOrderId, |
| | | Integer place, Integer orderSource, Integer uid) throws Exception { |
| | | Integer place, Integer orderSource, Integer uid,String name,String phone) throws Exception { |
| | | if(ToolUtil.isEmpty(serverCarModelIds)){ |
| | | return ResultUtil.error("请选择服务车型"); |
| | | } |
| | |
| | | map.put("orderType", 2); |
| | | map.put("orderId", resultUtil.getData().getId()); |
| | | }else{ |
| | | ResultUtil<BaseWarpper> resultUtil = this.orderPrivateCar(Integer.valueOf(serverModelId), travelTime, placementLon, placementLat, startLon, startLat, startAddress, endLon, endLat, endAddress, crossCityOrderId, place, orderSource, uid); |
| | | ResultUtil<BaseWarpper> resultUtil = this.orderPrivateCar(Integer.valueOf(serverModelId), travelTime, placementLon, placementLat, startLon, startLat, startAddress, endLon, endLat, endAddress, crossCityOrderId, place, orderSource, uid,name,phone); |
| | | if(resultUtil.getCode() != 200){ |
| | | return resultUtil; |
| | | } |
| | |
| | | * @throws Exception |
| | | */ |
| | | private synchronized ResultUtil<BaseWarpper> orderPrivateCar(Integer serverCarModelId, Date travelTime, String placementLon, String placementLat, String startLon, String startLat, |
| | | String startAddress, String endLon, String endLat, String endAddress, Integer crossCityOrderId, Integer place, Integer orderSource, Integer uid) throws Exception{ |
| | | String startAddress, String endLon, String endLat, String endAddress, Integer crossCityOrderId, Integer place, Integer orderSource, Integer uid,String name,String phone) throws Exception{ |
| | | //如果出行时间大于当前10分钟则默认为预约单 |
| | | Integer reservation = 1; |
| | | if(travelTime.getTime() > (System.currentTimeMillis() + 600000)){ |
| | |
| | | orderPrivateCar.setEndLat(Double.valueOf(endLat)); |
| | | orderPrivateCar.setEndAddress(endAddress); |
| | | orderPrivateCar.setSubstitute(0); |
| | | orderPrivateCar.setPassengers(name); |
| | | orderPrivateCar.setPassengersPhone(phone); |
| | | if(orderPrivateCar.getSubstitute() == 0 || ToolUtil.isEmpty(orderPrivateCar.getPassengers())){ |
| | | UserInfo userInfo = userInfoService.selectById(uid); |
| | | if(ToolUtil.isEmpty(userInfo.getPhone())){ |
| | |
| | | orderPrivateCar.setIsDelete(1); |
| | | orderPrivateCarMapper.insert(orderPrivateCar); |
| | | |
| | | //添加消息 |
| | | systemNoticeService.addSystemNotice(1, "您的专车订单已下单成功,我们正在为您指派司机,请稍后!", orderPrivateCar.getUserId(), 1); |
| | | //添加消息 systemNoticeService.addSystemNotice(1, "您的专车订单已下单成功,我们正在为您指派司机,请稍后!", orderPrivateCar.getUserId(), 1); |
| | | |
| | | BaseWarpper baseWarpper = new BaseWarpper(); |
| | | baseWarpper.setId(orderPrivateCar.getId()); |
| | | return ResultUtil.success(baseWarpper); |
| | | return ResultUtil.success(baseWarpper); |
| | | } |
| | | |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | public void pushOrder(List<Map<String, Integer>> list) throws Exception{ |
| | | System.err.println("====="+list); |
| | | for(Map<String, Integer> map : list){ |
| | | Integer orderType = map.get("orderType"); |
| | | Integer orderId = map.get("orderId"); |
| | | Integer orderId1 = map.get("orderId"); |
| | | Thread thread = new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | List<Map<String, Integer>> datas = list; |
| | | final Integer orderId = orderId1; |
| | | String vehicle = redisUtil.getValue("VEHICLE"); |
| | | List<Integer> integers = new ArrayList<>(); |
| | | if(ToolUtil.isNotEmpty(vehicle)){ |
| | |
| | | } |
| | | try { |
| | | if(orderType == 1){//专车 |
| | | Thread.sleep(1000); |
| | | System.err.println("====="+orderId); |
| | | OrderPrivateCar orderPrivateCar = orderPrivateCarMapper.selectById(orderId); |
| | | System.err.println("====="+orderPrivateCar); |
| | | OrderPrivateCarServiceImpl.orderIds.add(orderPrivateCar.getId());//添加记录,防止调用接口重复提醒无人接单 |
| | | Company query = companyCityService.query(String.valueOf(orderPrivateCar.getStartLon()), String.valueOf(orderPrivateCar.getStartLat()));//获取起点所属分公司 |
| | | List<PushOrder> querys = pushOrderService.querys(null, 1, query.getId());//获取需要推送的次数 |
| | |
| | | //删除其他无效数据 |
| | | for(Map<String, Integer> map : datas){ |
| | | Integer orderType = map.get("orderType"); |
| | | Integer orderId = map.get("orderId"); |
| | | Integer orderId1 = map.get("orderId"); |
| | | if(orderType == 1 && orderId != orderPrivateCar.getId()){ |
| | | orderPrivateCarMapper.deleteById(orderId); |
| | | orderPrivateCarMapper.deleteById(orderId1); |
| | | } |
| | | if(orderType == 2){ |
| | | orderTaxiMapper.deleteById(orderId); |
| | | orderTaxiMapper.deleteById(orderId1); |
| | | } |
| | | } |
| | | break; |
| | |
| | | //删除其他无效数据 |
| | | for(Map<String, Integer> map : datas){ |
| | | Integer orderType = map.get("orderType"); |
| | | Integer orderId = map.get("orderId"); |
| | | Integer orderId1 = map.get("orderId"); |
| | | if(orderType == 1){ |
| | | orderPrivateCarMapper.deleteById(orderId); |
| | | orderPrivateCarMapper.deleteById(orderId1); |
| | | } |
| | | if(orderType == 2 && orderId != orderTaxi.getId()){ |
| | | orderTaxiMapper.deleteById(orderId); |
| | | if(orderType == 2 && orderId1 != orderTaxi.getId()){ |
| | | orderTaxiMapper.deleteById(orderId1); |
| | | } |
| | | } |
| | | break; |
| | |
| | | } |
| | | }); |
| | | thread.start(); |
| | | threadMap.put(orderId + "_" + orderType, thread); |
| | | threadMap.put(orderId1 + "_" + orderType, thread); |
| | | } |
| | | } |
| | | |