Esempio n. 1
0
  public static void zhongbiao(Long id) {
    Toubiao toubiao = Toubiao.findById(id);
    toubiao.status = "1";
    toubiao.save();
    Request request = toubiao.request;
    request.status = 1;
    request.zb = true;
    request.save();
    List<Toubiao> toubiaos = Toubiao.find("request.id=? and id!=?", request.id, id).fetch();
    for (Toubiao tb : toubiaos) {
      tb.status = "2";
      tb.save();
    }
    Config config = Config.find("1=1").first();
    String message = "";
    SendMessage m = new SendMessage();
    message = "您已中标" + toubiao.request.name + "项目,请按时发货";
    if (config.msg_request_invite != null && !"".equals(config.msg_request_invite)) {
      message = config.msg_request_notification.replace("{request}", toubiao.request.name);
    }
    Profile p = toubiao.profile;
    if (p.contact_phone != null && !"".equals(p.contact_phone))
      m.sendSms(p.contact_phone, message, "0000003");
    if (p.contact_email != null && !"".equals(p.contact_email))
      m.sendMail(p.contact_email, "[" + Messages.get("application.name") + "]中标通知", message);

    redirect("/admin/requests");
  }
Esempio n. 2
0
  public static void toubiao() {
    String username = session.get("username");
    if (username != null) {
      User user = User.getByUserName(username);
      Profile profile = Profile.find("user.id=?", user.id).first();

      String payStyle = params.get("payStyle");
      String invoice = params.get("invoice");
      String comments = params.get("comments");
      String requestS = params.get("request");

      Request request = Request.findById(Long.valueOf(requestS));
      Toubiao toubiao = null;
      toubiao = Toubiao.find("request.id=? and profile.id=?", request.id, profile.id).first();
      if (toubiao == null) {
        toubiao = new Toubiao();
      }
      toubiao.profile = profile;
      toubiao.user = user;
      toubiao.request = request;
      toubiao.payStyle = payStyle;
      toubiao.invoice = invoice;
      toubiao.comments = comments;
      toubiao.again = false;
      toubiao.save();

      String price = "0";
      String price2 = "0";
      String price3 = "0";
      Baojia baojia = null;
      for (Specification spec : request.specifications) {
        price = params.get("price" + spec.id);
        price2 = params.get("price" + spec.id + "-2");
        price3 = params.get("price" + spec.id + "-3");
        baojia = Baojia.find("toubiao.id=? and specification.id=?", toubiao.id, spec.id).first();
        if (baojia == null) {
          baojia = new Baojia();
          baojia.toubiao = toubiao;
          baojia.specification = spec;
        }
        if (price != null && !"".equals(price) && !"0".equals(price))
          baojia.price = Double.valueOf(price);
        if (price2 != null && !"".equals(price2) && !"0".equals(price2))
          baojia.secondPrice = Double.valueOf(price2);
        if (price3 != null && !"".equals(price3) && !"0".equals(price3))
          baojia.thirdPrice = Double.valueOf(price3);
        baojia.save();

        if (!toubiao.baojias.contains(baojia)) {

          toubiao.baojias.add(baojia);
          toubiao.save();
        }
      }
    }
    redirect("/");
  }
Esempio n. 3
0
 public static void tbList(Long id) {
   Request req = Request.findById(id);
   List<Toubiao> toubiaos = Toubiao.find("request.id", req.id).fetch();
   render(req, toubiaos);
 }