コード例 #1
0
  private void btnSave(Long[] ids, Long[] sortIds) {
    if (null == ids || null == sortIds || ids.length < 1 || sortIds.length < 1) {
      return;
    }

    for (int i = 0; i < ids.length; i++) {
      Long id = ids[i];

      TdCoupon e = tdCouponService.findOne(id);

      if (null != e) {
        if (sortIds.length > i) {
          e.setSortId(sortIds[i]);
          tdCouponService.save(e);
        }
      }
    }
  }
コード例 #2
0
  @RequestMapping(value = "/save")
  public String orderEdit(
      TdCoupon tdCoupon,
      String __VIEWSTATE,
      Long[] leftNumbers,
      Long typeId,
      ModelMap map,
      HttpServletRequest req) {
    String username = (String) req.getSession().getAttribute("manager");
    if (null == username) {
      return "redirect:/Verwalter/login";
    }

    map.addAttribute("__VIEWSTATE", __VIEWSTATE);

    if (null == tdCoupon.getId()) {
      tdManagerLogService.addLog("add", "用户修改优惠券", req);

      List<TdDiySite> tdDiySiteList = tdDiySiteService.findByIsEnableTrue();

      if (null != tdDiySiteList
          && tdDiySiteList.size() > 0
          && null != leftNumbers
          && leftNumbers.length > 0
          && null != typeId) {
        /** @author lc @注释:如果不是免费洗车券和免费打蜡券就不存在同盟店 */
        TdCouponType tdCouponType = tdCouponTypeService.findOne(typeId);

        if (tdCouponType.getTitle().equals("免费打蜡券") || tdCouponType.getTitle().equals("免费洗车券")) {
          for (int i = 0; i < tdDiySiteList.size(); i++) {
            TdDiySite tds = tdDiySiteList.get(i);

            if (null != tds && leftNumbers.length > i) {
              TdCoupon coupon =
                  tdCouponService.findTopByTypeIdAndDiySiteIdAndIsDistributtedFalse(
                      typeId, tds.getId());

              if (null == coupon) {
                coupon = new TdCoupon();
                coupon.setDiySiteId(tds.getId());
                coupon.setLeftNumber(leftNumbers[i]);
                coupon.setTypeId(typeId);
                coupon.setSortId(99L);
                coupon.setPrice(tdCouponType.getPrice());
              } else {
                coupon.setLeftNumber(coupon.getLeftNumber() + leftNumbers[i]);
              }

              tdCouponService.save(coupon);
            }
          }
        } else {
          TdCoupon coupon = tdCouponService.findByTypeId(typeId);

          if (null == coupon) {
            coupon = new TdCoupon();
            coupon.setLeftNumber(leftNumbers[0]);
            coupon.setTypeId(typeId);
            coupon.setSortId(99L);
            coupon.setPrice(tdCouponType.getPrice());
          } else {
            coupon.setLeftNumber(coupon.getLeftNumber() + leftNumbers[0]);
          }

          tdCouponService.save(coupon);
        }
      }

    } else {
      tdManagerLogService.addLog("edit", "用户修改优惠券", req);
      tdCouponService.save(tdCoupon);
    }

    return "redirect:/Verwalter/coupon/list";
  }