| | |
| | | BigDecimal multiply = new BigDecimal(w).multiply(new BigDecimal(num4)); |
| | | order.setOutWaitTime(w);//等待时长超出分钟 |
| | | order.setOutWaitTimePrice(multiply.doubleValue());//等待时长超出费用 |
| | | }else{ |
| | | |
| | | } |
| | | |
| | | //恶劣天气 |
| | |
| | | order.setLongDistancePrice(0D);//长途里程费 |
| | | order.setOverLongDistance(0D);//超出长途里程 |
| | | order.setOverLongDistancePrice(0d);//超出长途里程费 |
| | | order.setWaitTime(0);//等待时长 |
| | | // order.setWaitTime(0);//等待时长 |
| | | order.setWaitTimePrice(0D);//等待费 |
| | | order.setOutWaitTime(0);//超出等待时长 |
| | | order.setOutWaitTimePrice(0D);//超出等待时长费 |
| | |
| | | Driver driver = driverService.selectById(order.getDriverId()); |
| | | driver.setServerStatus(1); |
| | | driverService.updateById(driver); |
| | | accountChangeDetailService.deductionInsurance();//扣减保险费 |
| | | accountChangeDetailService.deductionInsurance(order.getDriverId());//扣减保险费 |
| | | saveIntegral(order); |
| | | break; |
| | | case 401: |
| | |
| | | } |
| | | pushOrderInfoWarpper.setWaitTime(order.getWaitTime() + w); |
| | | pushOrderInfoWarpper.setState(order.getState()); |
| | | pushOrderInfoWarpper.setActualMileage(Double.valueOf(order.getActualMileage() / 1000)); |
| | | pushOrderInfoWarpper.setActualMileage(new BigDecimal(order.getActualMileage() / 1000).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | pushOrderInfoWarpper.setTravelTime(0); |
| | | if(null != order.getStartTime()){ |
| | | int travelTime = Double.valueOf((System.currentTimeMillis() - order.getStartTime().getTime()) / 60000).intValue(); |
| | |
| | | order.setCouponId(coupon.getId()); |
| | | order.setDiscountAmount(coupon.getCouponPreferentialAmount()); |
| | | order.setPayMoney(order.getOrderMoney() - coupon.getCouponPreferentialAmount()); |
| | | }else{ |
| | | order.setPayMoney(order.getOrderMoney()); |
| | | } |
| | | } |
| | | |
| | |
| | | userToCoupon.setValidCount(userToCoupon.getValidCount() - 1); |
| | | userToCouponService.updateById(userToCoupon); |
| | | Coupon coupon = couponService.selectById(userToCoupon.getCouponId()); |
| | | order.setPayMoney(order.getPayMoney() - coupon.getCouponPreferentialAmount()); |
| | | order.setCouponId(coupon.getId()); |
| | | order.setDiscountedPrice(coupon.getCouponPreferentialAmount()); |
| | | |
| | | Driver driver = driverService.selectById(order.getDriverId()); |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | |
| | | SystemConfig systemConfig1 = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 2)); |
| | | if(null != systemConfig1){ |
| | | JSONObject jsonObject1 = JSON.parseObject(systemConfig1.getContent()); |
| | | //司机推荐首单收入 |
| | | List<Integer> state = Arrays.asList(108, 109); |
| | | int count = this.selectCount(new EntityWrapper<Order>().eq("userId", appUser.getId()).eq("status", 1).in("state", state)); |
| | | if(null != appUser.getInviterType() && appUser.getInviterType() == 2 && count == 1){ |
| | | Double num1 = jsonObject1.getDouble("num1"); |
| | | num1 = (num3 >= num1 ? num1 : num3); |
| | | |
| | | if(num1 > 0){ |
| | | Driver driver1 = driverService.selectById(appUser.getInviterId()); |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(driver1.getId()); |
| | | accountChangeDetail.setType(1); |
| | | accountChangeDetail.setChangeType(5); |
| | | accountChangeDetail.setOldData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission()); |
| | | accountChangeDetail.setExplain("订单分佣收入"); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | driver1.setCommission(driver1.getCommission() + num1); |
| | | accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission()); |
| | | driverService.updateById(driver1); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | |
| | | Revenue revenue = new Revenue(); |
| | | revenue.setType(2); |
| | | revenue.setUserType(2); |
| | | revenue.setUserId(driver1.getId()); |
| | | revenue.setOrderId(order.getId()); |
| | | revenue.setAmount(num1); |
| | | revenue.setCreateTime(new Date()); |
| | | revenueService.insert(revenue); |
| | | } |
| | | num3 = (num3 >= num1 ? num3 - num1 : 0); |
| | | } |
| | | |
| | | //开始处理层级抽佣 |
| | | if(null != driver.getInviterType() && driver.getInviterType() == 2){ |
| | | Driver driver1 = driverService.selectById(driver.getInviterId());//一级司机 |
| | |
| | | Driver driver2 = driverService.selectById(driver1.getInviterId());//二级司机 |
| | | if(null != driver2 && null != driver2.getInviterType() && driver2.getInviterType() == 2){ |
| | | Driver driver3 = driverService.selectById(driver2.getInviterId());//三级级司机 |
| | | Double num4 = jsonObject1.getDouble("num4"); |
| | | Double num5 = jsonObject1.getDouble("num5"); |
| | | Double num6 = jsonObject1.getDouble("num6"); |
| | | Double num7 = jsonObject1.getDouble("num7"); |
| | | num5 = (num3 >= num5 ? num5 : num3); |
| | | if(num5 > 0){ |
| | | num4 = (num3 >= num4 ? num4 : num3); |
| | | if(num4 > 0){ |
| | | Revenue revenue = new Revenue(); |
| | | revenue.setType(2); |
| | | revenue.setUserType(2); |
| | | revenue.setUserId(driver1.getId()); |
| | | revenue.setOrderId(order.getId()); |
| | | revenue.setAmount(num5); |
| | | revenue.setAmount(num4); |
| | | revenue.setCreateTime(new Date()); |
| | | revenueService.insert(revenue); |
| | | |
| | |
| | | accountChangeDetail.setOldData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission()); |
| | | accountChangeDetail.setExplain("订单分佣收入"); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | driver1.setCommission(driver1.getCommission() + num5); |
| | | driver1.setCommission(driver1.getCommission() + num4); |
| | | accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission()); |
| | | driverService.updateById(driver1); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | num3 = (num3 >= num5 ? num3 - num5 : 0); |
| | | num3 = (num3 >= num4 ? num3 - num4 : 0); |
| | | } |
| | | num6 = (num3 >= num6 ? num6 : num3); |
| | | if(num6 > 0){ |
| | | num5 = (num3 >= num5 ? num5 : num3); |
| | | if(num5 > 0){ |
| | | Revenue revenue = new Revenue(); |
| | | revenue.setType(2); |
| | | revenue.setUserType(2); |
| | | revenue.setUserId(driver2.getId()); |
| | | revenue.setOrderId(order.getId()); |
| | | revenue.setAmount(num6); |
| | | revenue.setAmount(num5); |
| | | revenue.setCreateTime(new Date()); |
| | | revenueService.insert(revenue); |
| | | |
| | |
| | | accountChangeDetail.setOldData(driver2.getBalance() + driver2.getBackgroundBalance() + driver2.getCouponBalance() + driver2.getCommission()); |
| | | accountChangeDetail.setExplain("订单分佣收入"); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | driver2.setCommission(driver2.getCommission() + num6); |
| | | driver2.setCommission(driver2.getCommission() + num5); |
| | | accountChangeDetail.setNewData(driver2.getBalance() + driver2.getBackgroundBalance() + driver2.getCouponBalance() + driver2.getCommission()); |
| | | driverService.updateById(driver2); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | num3 = (num3 >= num6 ? num3 - num6 : 0); |
| | | num3 = (num3 >= num5 ? num3 - num5 : 0); |
| | | } |
| | | num7 = (num3 >= num7 ? num7 : num3); |
| | | if(num7 > 0){ |
| | | num6 = (num3 >= num6 ? num6 : num3); |
| | | if(num6 > 0){ |
| | | Revenue revenue = new Revenue(); |
| | | revenue.setType(2); |
| | | revenue.setUserType(2); |
| | | revenue.setUserId(driver3.getId()); |
| | | revenue.setOrderId(order.getId()); |
| | | revenue.setAmount(num7); |
| | | revenue.setAmount(num6); |
| | | revenue.setCreateTime(new Date()); |
| | | revenueService.insert(revenue); |
| | | |
| | |
| | | accountChangeDetail.setOldData(driver3.getBalance() + driver3.getBackgroundBalance() + driver3.getCouponBalance() + driver3.getCommission()); |
| | | accountChangeDetail.setExplain("订单分佣收入"); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | driver3.setCommission(driver3.getCommission() + num7); |
| | | driver3.setCommission(driver3.getCommission() + num6); |
| | | accountChangeDetail.setNewData(driver3.getBalance() + driver3.getBackgroundBalance() + driver3.getCouponBalance() + driver3.getCommission()); |
| | | driverService.updateById(driver3); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | num3 = (num3 >= num7 ? num3 - num7 : 0); |
| | | num3 = (num3 >= num6 ? num3 - num6 : 0); |
| | | } |
| | | }else{ |
| | | Double num2_ = jsonObject1.getDouble("num2"); |
| | | Double num3_ = jsonObject1.getDouble("num3"); |
| | | Double num4 = jsonObject1.getDouble("num4"); |
| | | num3_ = (num3 >= num3_ ? num3_ : num3); |
| | | if(num3_ > 0){ |
| | | num2_ = (num3 >= num2_ ? num2_ : num3); |
| | | if(num2_ > 0){ |
| | | Revenue revenue = new Revenue(); |
| | | revenue.setType(2); |
| | | revenue.setUserType(2); |
| | | revenue.setUserId(driver1.getId()); |
| | | revenue.setOrderId(order.getId()); |
| | | revenue.setAmount(num3_); |
| | | revenue.setAmount(num2_); |
| | | revenue.setCreateTime(new Date()); |
| | | revenueService.insert(revenue); |
| | | |
| | |
| | | accountChangeDetail.setOldData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission()); |
| | | accountChangeDetail.setExplain("订单分佣收入"); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | driver1.setCommission(driver1.getCommission() + num3_); |
| | | driver1.setCommission(driver1.getCommission() + num2_); |
| | | accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission()); |
| | | driverService.updateById(driver1); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | num3 = (num3 >= num3_ ? num3 - num3_ : 0); |
| | | num3 = (num3 >= num2_ ? num3 - num2_ : 0); |
| | | } |
| | | num4 = (num3 >= num4 ? num4 : num3); |
| | | if(num4 > 0){ |
| | | num3_ = (num3 >= num3_ ? num3_ : num3); |
| | | if(num3_ > 0){ |
| | | Revenue revenue = new Revenue(); |
| | | revenue.setType(2); |
| | | revenue.setUserType(2); |
| | | revenue.setUserId(driver2.getId()); |
| | | revenue.setOrderId(order.getId()); |
| | | revenue.setAmount(num4); |
| | | revenue.setAmount(num3_); |
| | | revenue.setCreateTime(new Date()); |
| | | revenueService.insert(revenue); |
| | | |
| | |
| | | accountChangeDetail.setOldData(driver2.getBalance() + driver2.getBackgroundBalance() + driver2.getCouponBalance() + driver2.getCommission()); |
| | | accountChangeDetail.setExplain("订单分佣收入"); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | driver2.setCommission(driver2.getCommission() + num4); |
| | | driver2.setCommission(driver2.getCommission() + num3_); |
| | | accountChangeDetail.setNewData(driver2.getBalance() + driver2.getBackgroundBalance() + driver2.getCouponBalance() + driver2.getCommission()); |
| | | driverService.updateById(driver2); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | num3 = (num3 >= num4 ? num3 - num4 : 0); |
| | | num3 = (num3 >= num3_ ? num3 - num3_ : 0); |
| | | } |
| | | } |
| | | }else{ |
| | | Double num2_ = jsonObject1.getDouble("num2"); |
| | | num2_ = (num3 >= num2_ ? num2_ : num3); |
| | | if(num2_ > 0){ |
| | | Double num1_ = jsonObject1.getDouble("num1"); |
| | | num1_ = (num3 >= num1_ ? num1_ : num3); |
| | | if(num1_ > 0){ |
| | | Revenue revenue = new Revenue(); |
| | | revenue.setType(2); |
| | | revenue.setUserType(2); |
| | | revenue.setUserId(driver1.getId()); |
| | | revenue.setOrderId(order.getId()); |
| | | revenue.setAmount(num2_); |
| | | revenue.setAmount(num1_); |
| | | revenue.setCreateTime(new Date()); |
| | | revenueService.insert(revenue); |
| | | |
| | |
| | | accountChangeDetail.setOldData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission()); |
| | | accountChangeDetail.setExplain("订单分佣收入"); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | driver1.setCommission(driver1.getCommission() + num2_); |
| | | driver1.setCommission(driver1.getCommission() + num1_); |
| | | accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission()); |
| | | driverService.updateById(driver1); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | num3 = (num3 >= num2_ ? num3 - num2_ : 0); |
| | | num3 = (num3 >= num1_ ? num3 - num1_ : 0); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public void completeCollection() { |
| | | this.baseMapper.completeCollection(); |
| | | List<Order> orders = this.selectList(new EntityWrapper<Order>().eq("state", 107).eq("status", 1).eq("payType", 3)); |
| | | for (Order order : orders) { |
| | | order.setState(108); |
| | | order.setPayTime(new Date()); |
| | | if(null != order.getCouponId()){ |
| | | UserToCoupon userToCoupon = userToCouponService.selectById(order.getCouponId()); |
| | | if(userToCoupon.getValidCount() > 0){ |
| | | userToCoupon.setValidCount(userToCoupon.getValidCount() - 1); |
| | | userToCouponService.updateById(userToCoupon); |
| | | Coupon coupon = couponService.selectById(userToCoupon.getCouponId()); |
| | | |
| | | Driver driver = driverService.selectById(order.getDriverId()); |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(order.getDriverId()); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | accountChangeDetail.setOldData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); |
| | | accountChangeDetail.setType(1); |
| | | accountChangeDetail.setChangeType(7); |
| | | accountChangeDetail.setOrderId(order.getId()); |
| | | accountChangeDetail.setExplain("优惠券收入"); |
| | | driver.setCouponBalance(driver.getCouponBalance() + coupon.getCouponPreferentialAmount()); |
| | | accountChangeDetail.setNewData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); |
| | | driverService.updateById(driver); |
| | | accountChangeDetailService.insert(accountChangeDetail); |
| | | } |
| | | } |
| | | this.updateById(order); |
| | | |
| | | try { |
| | | saveRevenue(order); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |