コード例 #1
0
 @Transactional
 public PageResult addMakeBabysitterOrder(
     String date,
     String address,
     String name,
     String mobile,
     String checkCode,
     String openid,
     String countyGuid,
     String babysitterGuid,
     PageResult result) {
   Babysitter babysitter = dao.getResultByGUID(Babysitter.class, babysitterGuid);
   if (babysitter == null) {
     result.setResult(ResultInfo.BABYSITTER_NULL);
     return result;
   }
   ServiceOrder order =
       addEmployerServiceOrder(
           date,
           babysitter.getLevel().getGuid(),
           countyGuid,
           address,
           name,
           mobile,
           checkCode,
           openid);
   if (order == null) {
     result.setResult(ResultInfo.COUNTY_LEVEL_NULL);
     return result;
   }
   result = markBabysitter(babysitterGuid, order.getGuid(), result);
   return result;
 }
コード例 #2
0
 @Transactional
 public PageResult markBabysitterId(
     String babysitterId, String serviceOrderId, PageResult result) {
   long babysitterIdl = Long.valueOf(babysitterId);
   long serviceOrderIdl = Long.valueOf(serviceOrderId);
   Babysitter babysitter = dao.getResultById(Babysitter.class, babysitterIdl);
   ServiceOrder serviceOrder = dao.getResultById(ServiceOrder.class, serviceOrderIdl);
   updateBabysitterOrder(serviceOrder.getGuid(), babysitter, serviceOrder);
   result.setResult(ResultInfo.SUCCESS);
   result.put("result", babysitter.view());
   return result;
 }
コード例 #3
0
 @Transactional
 public void addBabysitterAdvice(
     String countyGuid, ServiceOrder order, Map<String, Date> expectedDate) {
   // 添加需要通知的月嫂
   // CountyLevel countyLevel = dao.getResultByGUID(CountyLevel.class,
   // countyLevelGuid);
   String hql =
       "from Babysitter b where b.county.guid=? and b.level.level.money>=? and b.state = 1 ";
   List<Babysitter> babysitters =
       dao.getListResultByHQL(Babysitter.class, hql, countyGuid, order.getOrderPrice());
   // 添加可以抢单月嫂策略,SQL已经判断了所属城市、级别、审核状态三个条件
   // 1.排除最低薪水不符合条件的
   List<Babysitter> removeBabysitters = new ArrayList<Babysitter>();
   if (babysitters.size() == 0) return;
   BigDecimal salary = new BigDecimal(order.getOrderPrice());
   salary = salary.add(new BigDecimal(-1000));
   double rate = 1;
   if (order.getRate() != 0) rate = order.getRate();
   salary = salary.multiply(new BigDecimal(rate));
   long salaryLong = salary.longValue();
   for (Babysitter babysitter : babysitters) {
     if (babysitter.getLowerSalary() > salaryLong) removeBabysitters.add(babysitter);
   }
   babysitters.removeAll(removeBabysitters);
   // 2.排除档期不符合条件
   if (babysitters.size() == 0) return;
   if (removeBabysitters.size() != 0) removeBabysitters.clear();
   for (Babysitter babysitter : babysitters) {
     if (!ExpectedDateCreate.checkBabysitterOrder(babysitter, expectedDate)) {
       removeBabysitters.add(babysitter);
     }
   }
   babysitters.removeAll(removeBabysitters);
   // 添加月嫂通知
   if (babysitters.size() == 0) return;
   for (Babysitter babysitter : babysitters) {
     PanicBuyingBabysitterAdvice advice = PanicBuyingBabysitterAdvice.getInstance();
     advice.setBabysitter(babysitter);
     advice.setServiceOrder(order);
     advice.setIsAdvice(false);
     advice.setIsOver(false);
     dao.add(advice);
   }
 }
コード例 #4
0
  @Transactional
  public ResultInfo addBabysitterOrderEvaluate(String orderGuid, String msg, String score) {
    BabysitterOrder order = dao.getResultByGUID(BabysitterOrder.class, orderGuid);
    if (order == null) return ResultInfo.BABYSITTER_ORDER_NULL;
    Babysitter babysitter = dao.getResultByGUID(Babysitter.class, order.getBabysitter().getGuid());
    if (babysitter == null) return ResultInfo.BABYSITTER_NULL;
    order.setScore(Integer.valueOf(score));
    order.setEvaluation(msg);
    order.setState(Constants.ORDER_OVER);
    dao.update(order);
    BabysitterOrderRecordInfo info = BabysitterOrderRecordInfo.getInstance();
    info.setBabysitterOrder(order);
    info.setState(order.getState());
    dao.add(info);

    // BabysitterEvaluate evaluate = BabysitterEvaluate.getInstance();
    // evaluate.setBabysitter(babysitter);
    // evaluate.setEmployer(employer);
    // evaluate.setOrder(order);
    // evaluate.setMsg(msg);
    // evaluate.setScore(Integer.valueOf(score));
    // dao.add(evaluate);
    int sumSocre = 0;
    int count = 0;
    List<BabysitterOrder> orders = babysitter.getOrders();

    for (BabysitterOrder o : orders) {
      if (o.getState() == Constants.ORDER_OVER) {
        sumSocre += o.getScore();
        count += 1;
      }
    }
    int avg = 0;
    if (count != 0) {
      avg = sumSocre / count;
    }
    babysitter.setScore(avg);
    dao.update(babysitter);
    return ResultInfo.SUCCESS;
  }