| | |
| | | package com.stylefeng.guns.modular.crossCity.server.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.icbc.api.crypt.AES; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.crossCity.dao.LinePriceMapper; |
| | | import com.stylefeng.guns.modular.crossCity.dao.LineShiftDriverMapper; |
| | |
| | | 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.PhoneMapper; |
| | | import com.stylefeng.guns.modular.system.dao.RegionMapper; |
| | | import com.stylefeng.guns.modular.system.dao.SysIntegralMapper; |
| | | import com.stylefeng.guns.modular.system.dao.UserInfoMapper; |
| | | import com.stylefeng.guns.modular.system.dao.*; |
| | | 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.system.util.LiuZhouBank.PayUtil; |
| | | import com.stylefeng.guns.modular.system.warpper.BaseWarpper; |
| | | import com.stylefeng.guns.modular.system.warpper.MerchantCouponListWarpper; |
| | | import com.stylefeng.guns.modular.taxi.dao.OrderTaxiMapper; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | | import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.math.MathContext; |
| | | import java.math.RoundingMode; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | @Service |
| | |
| | | @Autowired |
| | | private PayMoneyUtil payMoneyUtil; |
| | | |
| | | @Autowired |
| | | private IOrderAdditionalFeeService orderAdditionalFeeService; |
| | | @Resource |
| | | private UserCouponRecordMapper userCouponRecordMapper; |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | @Autowired |
| | | private IMerchantActivityService merchantActivityService; |
| | | |
| | | @Autowired |
| | | private IMerchantActivitySlaveService merchantActivitySlaveService; |
| | | |
| | | @Autowired |
| | | private IUserMerchantCouponService userMerchantCouponService; |
| | | |
| | | @Autowired |
| | | private IMerchantCouponService merchantCouponService; |
| | | @Resource |
| | | private UserRedPacketRecordMapper userRedPacketRecordMapper; |
| | | |
| | | @Value("${filePath}") |
| | | private String filePath; |
| | |
| | | @Override |
| | | public ResultUtil process(Integer orderId, Integer state, Double lon, Double lat, String address) throws Exception { |
| | | OrderCrossCity orderCrossCity = this.selectById(orderId); |
| | | UserInfo userInfo = userInfoMapper.selectById(orderCrossCity.getUserId()); |
| | | switch (state){ |
| | | case 3://出发前往预约点 |
| | | orderCrossCity.setState(3); |
| | | orderCrossCity.setSetOutTime(new Date()); |
| | | systemNoticeService.addSystemNotice(1, "司机已出发,请耐心等待", orderCrossCity.getUserId(), 1); |
| | | systemNoticeService.addSystemNotice(1, "司机已出发,请耐心等待", orderCrossCity.getUserId()); |
| | | break; |
| | | case 4://到达预约点,等待客户上车 |
| | | orderCrossCity.setState(4); |
| | | orderCrossCity.setArriveTime(new Date()); |
| | | systemNoticeService.addSystemNotice(1, "司机已到达您设置的预约地点,请及时上车", orderCrossCity.getUserId(), 1); |
| | | systemNoticeService.addSystemNotice(1, "司机已到达您设置的预约地点,请及时上车", orderCrossCity.getUserId()); |
| | | break; |
| | | case 5://开始服务 |
| | | orderCrossCity.setBoardingLon(lon); |
| | |
| | | driverService.updateById(driver); |
| | | } |
| | | |
| | | //存储商家优惠券到redis {"phone":[{...}]} |
| | | //订单数要加1,因为这里是后修改订单状态 |
| | | List<OrderCrossCity> list = orderCrossCityMapper.queryByState(userInfo.getId(), 8, 9); |
| | | List<MerchantActivity> merchantActivities = merchantActivityService.selectList(new EntityWrapper<MerchantActivity>().eq("companyId", orderCrossCity.getCompanyId()).eq("activityType", 1).eq("auditStatus", 2).eq("status", 1) |
| | | .eq("state", 1).like("orderType", "3").where("((orderAmountFull is not null and orderAmountFull <= " + orderCrossCity.getOrderMoney() + ") or (orderNumber is not null and orderNumber <= " + (list.size() + 1) + "))") |
| | | .in("id", merchantActivitySlaveService.selectList(new EntityWrapper<MerchantActivitySlave>().gt("laveNumber", 0)).stream().map(MerchantActivitySlave::getMerchantActivityId).collect(Collectors.toList())) |
| | | .notIn("id", userMerchantCouponService.selectList(new EntityWrapper<UserMerchantCoupon>().eq("userType", 1).eq("userId", userInfo.getId()).eq("state", 1)).stream().map(UserMerchantCoupon::getMerchantActivityId).collect(Collectors.toList())) |
| | | ); |
| | | List<MerchantCouponListWarpper> listWarppers = new ArrayList<>(); |
| | | if(merchantActivities.size() > 0){ |
| | | for(MerchantActivity merchantActivity :merchantActivities){ |
| | | List<MerchantActivitySlave> merchantActivitySlaves = merchantActivitySlaveService.selectList(new EntityWrapper<MerchantActivitySlave>().eq("merchantActivityId", merchantActivity.getId()).gt("laveNumber", 0)); |
| | | |
| | | for(MerchantActivitySlave merchantActivitySlave : merchantActivitySlaves){ |
| | | UserMerchantCoupon userMerchantCoupon = new UserMerchantCoupon(); |
| | | try { |
| | | userMerchantCoupon.setCode(UUIDUtil.getRandomCode(16)); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | userMerchantCoupon.setUserType(1); |
| | | userMerchantCoupon.setUserId(userInfo.getId()); |
| | | userMerchantCoupon.setMerchantActivityId(merchantActivity.getId()); |
| | | userMerchantCoupon.setMerchantCouponId(merchantActivitySlave.getMerchantCouponId()); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(new Date()); |
| | | calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + merchantActivity.getEffectiveDays()); |
| | | userMerchantCoupon.setEndTime(calendar.getTime()); |
| | | userMerchantCoupon.setStatus(1); |
| | | userMerchantCoupon.setState(1); |
| | | userMerchantCoupon.setCreateTime(new Date()); |
| | | userMerchantCouponService.insert(userMerchantCoupon); |
| | | //添加已收入明细 |
| | | Line line = lineService.selectById(orderCrossCity.getLineId()); |
| | | Double speMoney = Double.valueOf(line.getRakeRate()); |
| | | BigDecimal d = new BigDecimal(orderCrossCity.getOrderMoney()).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_EVEN);//企业收入 |
| | | BigDecimal c = new BigDecimal(orderCrossCity.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);//司机收入 |
| | | incomeService.saveData(1, orderCrossCity.getCompanyId(), 2, orderCrossCity.getId(), 3, d.doubleValue()); |
| | | incomeService.saveData(2, orderCrossCity.getDriverId(), 2, orderCrossCity.getId(), 3, c.doubleValue()); |
| | | Driver driver = driverService.selectById(orderCrossCity.getDriverId()); |
| | | driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | |
| | | MerchantCoupon merchantCoupon = merchantCouponService.selectById(merchantActivitySlave.getMerchantCouponId()); |
| | | MerchantCouponListWarpper merchantCouponListWarpper = new MerchantCouponListWarpper(); |
| | | merchantCouponListWarpper.setId(merchantActivitySlave.getMerchantCouponId()); |
| | | merchantCouponListWarpper.setName(merchantCoupon.getName()); |
| | | merchantCouponListWarpper.setType(merchantCoupon.getType()); |
| | | merchantCouponListWarpper.setFullAmount(merchantCoupon.getFullAmount()); |
| | | merchantCouponListWarpper.setDiscount(merchantCoupon.getDiscount()); |
| | | listWarppers.add(merchantCouponListWarpper); |
| | | |
| | | merchantActivitySlave.setLaveNumber(merchantActivitySlave.getLaveNumber() - 1); |
| | | if(merchantActivitySlave.getLaveNumber() == 0){ |
| | | merchantActivity.setStatus(2); |
| | | } |
| | | } |
| | | if(merchantActivitySlaves.size() > 0){ |
| | | merchantActivitySlaveService.updateBatchById(merchantActivitySlaves); |
| | | } |
| | | } |
| | | merchantActivityService.updateBatchById(merchantActivities); |
| | | } |
| | | String value = redisUtil.getValue("merchantVoucher"); |
| | | JSONObject jsonObject = JSON.parseObject(value); |
| | | if(null == jsonObject){ |
| | | jsonObject = new JSONObject(); |
| | | } |
| | | jsonObject.put(userInfo.getPhone(), listWarppers); |
| | | redisUtil.setStrValue("merchantVoucher", jsonObject.toJSONString()); |
| | | |
| | | pushUtil.removeTask(orderId, 3);//删除定时任务,结束推送数据 |
| | | systemNoticeService.addSystemNotice(1, "司机已结束本次行程,谢谢使用", orderCrossCity.getUserId(), 1); |
| | | systemNoticeService.addSystemNotice(1, "司机已结束本次行程,谢谢使用", orderCrossCity.getUserId()); |
| | | break; |
| | | } |
| | | this.updateById(orderCrossCity); |
| | |
| | | return ResultUtil.error("司机处于离线状态"); |
| | | } |
| | | OrderCrossCity orderCrossCity = new OrderCrossCity(); |
| | | UserInfo userInfo = userInfoMapper.queryByPhone(orderCrossCityWarpper.getPassengersPhone()); |
| | | UserInfo userInfo = userInfoMapper.queryByPhone(AESUtil.encrypt(orderCrossCityWarpper.getPassengersPhone())); |
| | | if(userInfo == null){//添加用户信息 |
| | | userInfo = new UserInfo(); |
| | | Integer integer = userInfoMapper.selectCount(null) + 1000001; |
| | | userInfo.setNickName(ToolUtil.isNotEmpty(orderCrossCityWarpper.getPassengers()) ? orderCrossCityWarpper.getPassengers() : "OK" + String.valueOf(integer).substring(1)); |
| | | userInfo.setName(orderCrossCityWarpper.getPassengers()); |
| | | userInfo.setPhone(orderCrossCityWarpper.getPassengersPhone()); |
| | | userInfo.setPhone(AESUtil.encrypt(orderCrossCityWarpper.getPassengersPhone())); |
| | | userInfo.setState(1); |
| | | userInfo.setFlag(1); |
| | | userInfo.setInsertTime(new Date()); |
| | |
| | | orderCrossCity.setUserId(userInfo.getId()); |
| | | |
| | | /** |
| | | * 1.出租车、专车、跨城有待支付的订单不能叫车 |
| | | * 2.小件物流有未完成的订单可以下跨城、专车、出租车 |
| | | * 3.出租车、专车、跨城有预约单可以下即时单 |
| | | * 1.下了即时单就不能下预约单和即时单 |
| | | * 2.下了预约单和再下一张即时单不能再下预约单 |
| | | */ |
| | | List<OrderPrivateCar> orderPrivateCars = orderPrivateCarMapper.queryByState(uid, 1, 1, 1, 2, 3, 4, 5, 6, 7, 11, 12); |
| | | List<OrderPrivateCar> orderPrivateCars = orderPrivateCarMapper.queryByState(orderCrossCity.getUserId(), 1, 1, 1, 2, 3, 4, 5, 6, 7, 11); |
| | | if(orderPrivateCars.size() > 0){ |
| | | return ResultUtil.error("有未完成的订单"); |
| | | } |
| | | List<OrderTaxi> list = orderTaxiMapper.queryByState_(uid, 1, 1, 1, 2, 3, 4, 5, 6, 7, 11, 12); |
| | | List<OrderTaxi> list = orderTaxiMapper.queryByState_(orderCrossCity.getUserId(), 1, 1, 1, 2, 3, 4, 5, 6, 11); |
| | | if(list.size() > 0){ |
| | | return ResultUtil.error("有未完成的订单"); |
| | | } |
| | | List<OrderCrossCity> orderCrossCities1 = orderCrossCityMapper.queryByState(uid, 1, 2, 3, 4, 5, 7, 11, 12); |
| | | List<OrderCrossCity> orderCrossCities1 = orderCrossCityMapper.queryByState(orderCrossCity.getUserId(), 1, 2, 3, 4, 5, 7, 11); |
| | | if(orderCrossCities1.size() > 0){ |
| | | return ResultUtil.error("有未完成的订单"); |
| | | } |
| | |
| | | orderCrossCity.setTrackId(track); |
| | | |
| | | //调用移动的小号接口 |
| | | Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderCrossCity.getPassengersPhone(), driver.getPhone(), (System.currentTimeMillis() + 86400000)); |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(orderCrossCity.getStartLon().toString(), orderCrossCity.getStartLat().toString()); |
| | | Region region = regionMapper.query(geocode.get("districtCode")); |
| | | Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderCrossCity.getPassengersPhone(), AESUtil.decrypt(driver.getPhone()), Integer.valueOf(region.getCitycode().substring(1))); |
| | | if(String.valueOf(map.get("code")).equals("200")){ |
| | | orderCrossCity.setTelX(map.get("telX")); |
| | | orderCrossCity.setBindId(map.get("bindId")); |
| | | } |
| | | if(orderCrossCityWarpper.getTravelMode() == 2){//包车 |
| | | // orderCrossCity.setSeatNumber(lineShiftDriver.getLaveSeatNumber()); |
| | | // orderCrossCity.setPeopleNumber(lineShiftDriver.getLaveSeat()); |
| | | orderCrossCity.setSeatNumber(lineShiftDriver.getLaveSeatNumber()); |
| | | orderCrossCity.setPeopleNumber(lineShiftDriver.getLaveSeat()); |
| | | } |
| | | this.insert(orderCrossCity); |
| | | |
| | | Double t = 0D; |
| | | if(ToolUtil.isNotEmpty(orderCrossCityWarpper.getAdditionalFee())){//附加费 |
| | | JSONArray jsonArray = JSON.parseArray(orderCrossCityWarpper.getAdditionalFee()); |
| | | for(int i = 0; i < jsonArray.size(); i++){ |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | Integer id = jsonObject.getInteger("id"); |
| | | Double amount = jsonObject.getDouble("amount"); |
| | | OrderAdditionalFee orderAdditionalFee = new OrderAdditionalFee(); |
| | | orderAdditionalFee.setOrderType(3); |
| | | orderAdditionalFee.setOrderId(orderCrossCity.getId()); |
| | | orderAdditionalFee.setAdditionalFeeId(id); |
| | | orderAdditionalFee.setAmount(amount); |
| | | orderAdditionalFeeService.insert(orderAdditionalFee); |
| | | t += amount; |
| | | } |
| | | } |
| | | orderCrossCity.setOrderMoney(orderCrossCity.getOrderMoney() + t); |
| | | this.updateById(orderCrossCity); |
| | | |
| | | if(driver.getState() == 2){ |
| | | driver.setState(3); |
| | |
| | | lineShiftDriverMapper.updateById(lineShiftDriver); |
| | | |
| | | //添加消息 |
| | | systemNoticeService.addSystemNotice(1, "您的跨城订单已下单成功!", orderCrossCity.getUserId(), 1); |
| | | systemNoticeService.addSystemNotice(1, "您的跨城订单已下单成功!", orderCrossCity.getUserId()); |
| | | |
| | | BaseWarpper baseWarpper = new BaseWarpper(); |
| | | baseWarpper.setId(orderCrossCity.getId()); |
| | | |
| | | //创建定时任务,取消订单30分钟 |
| | | TimerTask timerTask = new TimerTask() { |
| | | @Override |
| | |
| | | }; |
| | | Timer timer = new Timer(); |
| | | timer.schedule(timerTask, 30 * 60 * 1000); |
| | | |
| | | return ResultUtil.success(baseWarpper); |
| | | } |
| | | |
| | |
| | | } |
| | | }).start(); |
| | | |
| | | systemNoticeService.addSystemNotice(1, "您已成功完成出行订单支付,谢谢使用!", orderCrossCity.getUserId(), 1); |
| | | systemNoticeService.addSystemNotice(1, "您已成功完成出行订单支付,谢谢使用!", orderCrossCity.getUserId()); |
| | | } |
| | | |
| | | |
| | |
| | | return ResultUtil.error("订单已被支付,不允许重复支付"); |
| | | } |
| | | Integer uid = orderCrossCity.getUserId(); |
| | | UserInfo userInfo = userInfoMapper.selectById(uid); |
| | | Double orderMoney = orderCrossCity.getOrderMoney(); |
| | | ResultUtil resultUtil = ResultUtil.success(""); |
| | | ResultUtil resultUtil = ResultUtil.success(); |
| | | orderCrossCity.setCouponMoney(0D);//初始化历史数据 |
| | | orderCrossCity.setCouponId(null); |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String out_trade_no = sdf.format(new Date()) + 3 + orderCrossCity.getId(); |
| | | |
| | | if(payType == 1){//微信支付 |
| | | |
| | | resultUtil = payMoneyUtil.weixinpay("完成订单", "", orderId + "_3_" + UUIDUtil.getRandomCode(5), orderMoney.toString(), "/base/wxPayCrossCity", "APP"); |
| | | paymentRecordService.saveData(1, orderCrossCity.getDriverId(), 2, orderId, 3, 1, orderMoney, "", 1);//添加预支付数据 |
| | | |
| | | // Map<String, String> map = icbcPayUtil.placeAnOrder(orderId + ",3", 9, 5, uid.toString(), "完成订单", orderMoney, callbackPath + "/base/wxPayCrossCity", "", type, null); |
| | | // if(map.get("code").equals("200")){ |
| | | // paymentRecordService.saveData(1, orderCrossCity.getDriverId(), 2, orderId, 3, 1, orderMoney, map.get("order_id"), 1);//添加预支付数据 |
| | | // resultUtil = ResultUtil.success(map.get("data")); |
| | | // }else{ |
| | | // resultUtil = ResultUtil.error(map.get("msg"), ""); |
| | | // } |
| | | String appletsOpenId = ""; |
| | | String tradeType = "APP"; |
| | | resultUtil = payMoneyUtil.weixinpay("完成订单", "", out_trade_no, orderMoney.toString(), callbackPath + "/base/wxPayCrossCity", tradeType, appletsOpenId, ""); |
| | | if(resultUtil.getCode() == 200){ |
| | | paymentRecordService.saveData(1, orderCrossCity.getDriverId(), 2, orderId, 3, 1, orderMoney, "", 1);//添加预支付数据 |
| | | } |
| | | } |
| | | if(payType == 2){//支付宝支付 |
| | | resultUtil = payMoneyUtil.alipay("完成订单", "完成订单", "", orderId + "_3_" + UUIDUtil.getRandomCode(5), orderMoney.toString(), "/base/aliPayCrossCity"); |
| | | paymentRecordService.saveData(1, orderCrossCity.getDriverId(), 2, orderId, 3, 2, orderMoney, "", 1);//添加预支付数据 |
| | | |
| | | |
| | | // Map<String, String> map = icbcPayUtil.placeAnOrder(orderId + ",3", 10, 5, uid.toString(), "完成订单", orderMoney, callbackPath + "/base/aliPayCrossCity", "", type, null); |
| | | // if(map.get("code").equals("200")){ |
| | | // paymentRecordService.saveData(1, orderCrossCity.getDriverId(), 2, orderId, 3, 2, orderMoney, map.get("order_id"), 1);//添加预支付数据 |
| | | // resultUtil = ResultUtil.success(map.get("data")); |
| | | // }else{ |
| | | // resultUtil = ResultUtil.error(map.get("msg"), ""); |
| | | // } |
| | | resultUtil = payMoneyUtil.alipay("订单完成支付", "支付订单", out_trade_no, orderMoney.toString(), callbackPath + "/base/aliPayCrossCity"); |
| | | if(resultUtil.getCode() == 200){ |
| | | paymentRecordService.saveData(1, orderCrossCity.getDriverId(), 2, orderId, 3, 2, orderMoney, "", 1);//添加预支付数据 |
| | | } |
| | | } |
| | | // if(payType == 3){//扫码支付,暂时屏蔽,这里需要确认需求 |
| | | // //调用支付获取收款二维码数据 |
| | | // ResultUtil<Map<String, Object>> generate = icbcPayUtil.generate(orderCrossCity.getId() + ",3", orderMoney, orderCrossCity.getInsertTime(), orderCrossCity.getOrderNum(), callbackPath + "/base/order/generatePay"); |
| | | // resultUtil = ResultUtil.success(generate.getData().get("qrcode").toString()); |
| | | // } |
| | | if(payType == 3){//扫码支付 |
| | | resultUtil = payMoneyUtil.weixinpay("完成订单", "", out_trade_no, orderMoney.toString(), callbackPath + "/base/wxPayCrossCity", "NATIVE", "", orderCrossCity.getId().toString()); |
| | | if(resultUtil.getCode() == 200){ |
| | | paymentRecordService.saveData(1, orderCrossCity.getUserId(), 1, orderId, 3, 1, orderMoney, "", 1);//添加预支付数据 |
| | | } |
| | | } |
| | | |
| | | this.updateAllColumnById(orderCrossCity); |
| | | return resultUtil; |
| | |
| | | @Override |
| | | public void payOrderCrossCityCallback(Integer id, String order_id, Integer type) throws Exception { |
| | | OrderCrossCity orderCrossCity = this.selectById(id); |
| | | if(orderCrossCity.getState() == 7){ |
| | | PaymentRecord query = paymentRecordService.query(1, orderCrossCity.getDriverId(), 2, id, 3, type, 1); |
| | | if(null == query){ |
| | | System.err.println("预支付数据异常(orderId = " + id + ")"); |
| | | } |
| | | PaymentRecord query = paymentRecordService.query(1, orderCrossCity.getUserId(), 1, Integer.valueOf(id), 3, type, 1); |
| | | if(null == query){ |
| | | query = paymentRecordService.query(1, orderCrossCity.getDriverId(), 2, Integer.valueOf(id), 3, type, 1); |
| | | } |
| | | if(null != query){ |
| | | //添加交易明细 |
| | | transactionDetailsService.saveData(orderCrossCity.getUserId(), "完成订单", query.getAmount(), 2, 1, 1, 3, query.getOrderId()); |
| | | orderCrossCity.setState(2);//先支付再服务 |
| | |
| | | userInfo.setIntegral(userInfo.getIntegral() + (query.getAmount().intValue() * query1.getIntegral()));//积分 |
| | | userInfoMapper.updateById(userInfo); |
| | | |
| | | //处理优惠券和红包 |
| | | if(null != orderCrossCity.getCouponId()){ |
| | | UserCouponRecord userCouponRecord = userCouponRecordMapper.selectById(orderCrossCity.getCouponId()); |
| | | userCouponRecord.setState(2); |
| | | userCouponRecord.setEndTime(new Date()); |
| | | userCouponRecordMapper.updateById(userCouponRecord); |
| | | } |
| | | if(null != orderCrossCity.getRedPacketId()){ |
| | | UserRedPacketRecord userRedPacketRecord = userRedPacketRecordMapper.selectById(orderCrossCity.getRedPacketId()); |
| | | userRedPacketRecord.setState(2); |
| | | userRedPacketRecord.setEndTime(new Date()); |
| | | userRedPacketRecordMapper.updateById(userRedPacketRecord); |
| | | } |
| | | |
| | | |
| | | query.setState(2); |
| | | query.setCode(order_id); |
| | | paymentRecordService.updateById(query); |
| | | |
| | | //添加已收入明细 |
| | | Line line = lineService.selectById(orderCrossCity.getLineId()); |
| | | Double speMoney = Double.valueOf(line.getRakeRate()); |
| | | BigDecimal d = new BigDecimal(orderCrossCity.getOrderMoney()).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_EVEN);//企业收入 |
| | | BigDecimal c = new BigDecimal(orderCrossCity.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);//司机收入 |
| | | incomeService.saveData(1, orderCrossCity.getCompanyId(), 2, orderCrossCity.getId(), 3, d.doubleValue()); |
| | | incomeService.saveData(2, orderCrossCity.getDriverId(), 2, orderCrossCity.getId(), 3, c.doubleValue()); |
| | | Driver driver = driverService.selectById(orderCrossCity.getDriverId()); |
| | | driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | |
| | | // TODO: 2020/5/24 这里需要给司机和用户推送订单状态 |
| | | new Thread(new Runnable() { |
| | |
| | | }).start(); |
| | | |
| | | |
| | | systemNoticeService.addSystemNotice(1, "您已使用" + (type == 1 ? "微信" : "支付宝") + "成功完成出行订单支付,谢谢使用!", orderCrossCity.getUserId(), 1); |
| | | systemNoticeService.addSystemNotice(1, "您已使用" + (type == 1 ? "微信" : "支付宝") + "成功完成出行订单支付,谢谢使用!", orderCrossCity.getUserId()); |
| | | }else{ |
| | | System.err.println("预支付数据异常(orderId = " + id + ")"); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | }else{//浮动计费 |
| | | //计算公式:实际历程 * 基础单价 * (参考费用 / (参考里程 * 基础单价)) + (实际历程 - 参考里程) * 基础单价 * 优惠系数 |
| | | double num1 = Double.valueOf(jsonObject.getString("num1")).doubleValue();//参考价格 |
| | | double num1 = Double.valueOf(jsonObject.getString("num1")).doubleValue();//参考费用 |
| | | double num2 = Double.valueOf(jsonObject.getString("num2")).doubleValue();//参考里程 |
| | | double num3 = Double.valueOf(jsonObject.getString("num3")).doubleValue();//保底价 |
| | | double num4 = Double.valueOf(jsonObject.getString("num4")).doubleValue();//超出参考里程优惠系数 |
| | | double num5 = Double.valueOf(jsonObject.getString("num5")).doubleValue();//低于参考里程优惠系数 |
| | | double num6 = Double.valueOf(jsonObject.getString("num6")).doubleValue();//包车系数 |
| | | double num7 = Double.valueOf(jsonObject.getString("num7")).doubleValue();//五座系数 |
| | | double num8 = Double.valueOf(jsonObject.getString("num8")).doubleValue();//七座系数 |
| | | |
| | | |
| | | /** |
| | | * 1、实际里程>=参考里程 |
| | | * 参考价+((实际里程-参考里程)*(参考价/参考里程)*超出参考里程优惠系数) |
| | | * |
| | | * 2、实际里程<参考里程 |
| | | * 参考价-(参考里程-实际路程)*(参考价/参考里程)*低于参考里程优惠系数 |
| | | */ |
| | | double unitPrice = 0d; |
| | | if(distance1 > num2){//1 |
| | | unitPrice = num1 + ((distance1 - num2) * (num1 / num2) * num4); |
| | | } |
| | | if(distance1 < num2){//2 |
| | | unitPrice = num1 - ((num2 - distance1) * (num1 / num2) * num5); |
| | | } |
| | | if(distance1 == num2){ |
| | | unitPrice = num1; |
| | | } |
| | | double num3 = Double.valueOf(jsonObject.getString("num3")).doubleValue();//基础单价 |
| | | double num4 = Double.valueOf(jsonObject.getString("num4")).doubleValue();//优惠系数 |
| | | double num5 = Double.valueOf(jsonObject.getString("num5")).doubleValue();//包车系数 |
| | | double num6 = Double.valueOf(jsonObject.getString("num6")).doubleValue();//五座系数 |
| | | double num7 = Double.valueOf(jsonObject.getString("num7")).doubleValue();//七座系数 |
| | | if(travelMode == 1){//拼车 |
| | | double unitPrice = (distance1 * num3 * (num1 / (num2 * num3))) + ((distance1 - num2) * num3 * num4); |
| | | String[] split = seatNumber.split(","); |
| | | boolean b = false; |
| | | for(String s : split){ |
| | |
| | | } |
| | | double price1 = 0D; |
| | | if(b){ |
| | | price1 = unitPrice * (totalSeat == 4 ? num7 : num8); |
| | | price1 = unitPrice * (totalSeat == 4 ? num6 : num7); |
| | | peopleNumber -= 1; |
| | | } |
| | | double price = (unitPrice * peopleNumber) + price1; |
| | | map.put("price", new BigDecimal(num3 > price ? num3 : price).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | map.put("price", new BigDecimal(price).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | }else{ |
| | | double price = unitPrice * totalSeat * num6; |
| | | map.put("price", new BigDecimal(num3 > price ? num3 : price).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | double unitPrice = (distance1 * num3 * (num1 / (num2 * num3))) + ((distance1 - num2) * num3 * num5); |
| | | double price = unitPrice * totalSeat; |
| | | map.put("price", new BigDecimal(price).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | } |
| | | } |
| | | return ResultUtil.success(map); |
| | | } |
| | | |
| | | @Override |
| | | public List<OrderCrossCity> taskMidAxbUnBindSend() throws Exception { |
| | | return this.baseMapper.taskMidAxbUnBindSend(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取订单编号 |