Пример #1
0
 @Override
 public void mouseClicked(MouseEvent e) {
   if (e.getSource() == table && e.getClickCount() == 2) {
     // 表格
     String id = table.getValueAt(table.getSelectedRow(), -1).toString();
     try {
       TUser user = tUserService.getByIdService(id);
       if (user == null) {
         JOptionPane.showMessageDialog(null, "当前会员不存在");
         return;
       }
       menberDetailDialog = new MenberDetailDialog(null, "会员详细", true);
       menberDetailDialog.showDialog(user);
     } catch (Exception e1) {
       e1.printStackTrace();
     }
   }
 }
Пример #2
0
  @Override
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == queryButton) {
      // 查询
      this.termQuery(1);
    } else if (e.getSource() == showButton) {
      // 查看详细
      if (table.getSelectedRow() != -1) {
        String userID = (String) table.getValueAt(table.getSelectedRow(), -1);
        try {
          TUser tUser = tUserService.getByIdService(userID);
          menberDetailDialog = new MenberDetailDialog(null, "会员详细信息", true);
          menberDetailDialog.showDialog(tUser);
        } catch (Exception e1) {
          e1.printStackTrace();
        }
      } else {
        JOptionPane.showMessageDialog(null, "请先选择行数据");
      }
    } else if (e.getSource() == dGiftButton) {
      // 兑换礼品
      if (table.getSelectedRow() != -1) {
        String userID = (String) table.getValueAt(table.getSelectedRow(), -1);
        try {
          TUser tUser = tUserService.getByIdService(userID);
          tUser.setUserID(userID);
          memberDGiftDialog = new MemberDGiftDialog(null, "兑换礼品", true);
          memberDGiftDialog.showDialog(tUser);
        } catch (Exception e1) {
          e1.printStackTrace();
        }
      } else {
        JOptionPane.showMessageDialog(null, "请先选择行数据");
      }
    } else if (e.getSource() == levelButton) {
      // 设置会员级别
      if (table.getSelectedRow() != -1) {
        boolean[] bools = memberQueryCardModel.getBools();
        boolean select = false; // 检查是否有选中的商品 如果没选中false 否则true
        for (int i = bools.length - 1; i >= 0; --i) {
          if (bools[i]) {
            select = true;
            break;
          }
        }
        if (!select) {
          JOptionPane.showMessageDialog(null, "请先选择用户!");
          return;
        } else {
          try {
            // TUser tUser = tUserService.getByIdService(userID);

            List<TUser> tUserList = memberQueryCardModel.getTCommodityList();
            List<TUser> tUserListOn = new ArrayList();
            for (int i = 0; i < tUserList.size(); i++) {
              if (bools[i]) {
                tUserListOn.add(tUserList.get(i));
              }
            }
            memberLevelPanel = new MemberLevelPanel(null, "设置会员级别", true);
            memberLevelPanel.showDialog(tUserListOn);
            table.updateUI();
          } catch (Exception e1) {
            e1.printStackTrace();
          }
        }
      } else {
        JOptionPane.showMessageDialog(null, "请先选择行数据");
      }
    } else if (e.getSource() == giftButton) {
      // 送礼品
      if (table.getSelectedRow() != -1) {
        boolean[] bools = memberQueryCardModel.getBools();
        boolean select = false; // 检查是否有选中的商品 如果没选中false 否则true
        for (int i = bools.length - 1; i >= 0; --i) {
          if (bools[i]) {
            select = true;
            break;
          }
        }
        if (!select) {
          JOptionPane.showMessageDialog(null, "请先选择用户!");
          return;
        } else {
          try {
            // TUser tUser = tUserService.getByIdService(userID);

            List<TUser> tUserList = memberQueryCardModel.getTCommodityList();
            List<TUser> tUserListOn = new ArrayList();
            for (int i = 0; i < tUserList.size(); i++) {
              if (bools[i]) {
                tUserListOn.add(tUserList.get(i));
              }
            }
            memberGiftSend = new MemberGiftSend(null, "会员赠送礼品", true);
            memberGiftSend.showDialog(tUserListOn);
            table.updateUI();
          } catch (Exception e1) {
            e1.printStackTrace();
          }
        }
      } else {
        JOptionPane.showMessageDialog(null, "请先选择行数据");
      }
    } else if (e.getSource() == pointButton) {
      // 送积分
      if (table.getSelectedRow() != -1) {
        boolean[] bools = memberQueryCardModel.getBools();
        boolean select = false; // 检查是否有选中的商品 如果没选中false 否则true
        for (int i = bools.length - 1; i >= 0; --i) {
          if (bools[i]) {
            select = true;
            break;
          }
        }
        if (!select) {
          JOptionPane.showMessageDialog(null, "请先选择用户!");
          return;
        } else {
          try {
            // TUser tUser = tUserService.getByIdService(userID);

            List<TUser> tUserList = memberQueryCardModel.getTCommodityList();
            List<TUser> tUserListOn = new ArrayList();
            for (int i = 0; i < tUserList.size(); i++) {
              if (bools[i]) {
                // Object obj1=tUserList.get(i);
                tUserListOn.add(tUserList.get(i));
                // TRoleRight roleRight=new TRoleRight();
                // roleRight.setTRight((TRight)obj1);
              }
            }
            memberPointSend = new MemberPointSend(null, "会员赠送积分", true);
            memberPointSend.showDialog(tUserListOn);
            table.updateUI();
          } catch (Exception e1) {
            e1.printStackTrace();
          }
        }
      } else {
        JOptionPane.showMessageDialog(null, "请先选择行数据");
      }
    } else if (e.getSource() == cashButton) {
      // 送优惠
      if (table.getSelectedRow() != -1) {
        boolean[] bools = memberQueryCardModel.getBools();
        boolean select = false; // 检查是否有选中的商品 如果没选中false 否则true
        for (int i = bools.length - 1; i >= 0; --i) {
          if (bools[i]) {
            select = true;
            break;
          }
        }
        if (!select) {
          JOptionPane.showMessageDialog(null, "请先选择用户!");
          return;
        } else {
          try {
            // TUser tUser = tUserService.getByIdService(userID);

            List<TUser> tUserList = memberQueryCardModel.getTCommodityList();
            List<TUser> tUserListOn = new ArrayList();
            for (int i = 0; i < tUserList.size(); i++) {
              if (bools[i]) {
                // Object obj1=tUserList.get(i);
                tUserListOn.add(tUserList.get(i));
                // TRoleRight roleRight=new TRoleRight();
                // roleRight.setTRight((TRight)obj1);
              }
            }
            memberCashSend = new MemberCashSend(null, "会员赠送优惠卷", true);
            memberCashSend.showDialog(tUserListOn);
            table.updateUI();
          } catch (Exception e1) {
            e1.printStackTrace();
          }
        }
      } else {
        JOptionPane.showMessageDialog(null, "请先选择行数据");
      }
    } else if (e.getSource() == chargeButton) {
      // 充值
      if (table.getSelectedRow() != -1) {
        // String userID = (String)table.getValueAt(table.getSelectedRow(), 0);
        boolean[] bools = memberQueryCardModel.getBools();
        boolean select = false; // 检查是否有选中的商品 如果没选中false 否则true
        for (int i = bools.length - 1; i >= 0; --i) {
          if (bools[i]) {
            select = true;
            break;
          }
        }
        if (!select) {
          JOptionPane.showMessageDialog(null, "请先选择用户!");
          return;
        } else {
          try {
            // TUser tUser = tUserService.getByIdService(userID);

            List<TUser> tUserList = memberQueryCardModel.getTCommodityList();
            List<TUser> tUserListOn = new ArrayList();
            for (int i = 0; i < tUserList.size(); i++) {
              if (bools[i]) {
                // Object obj1=tUserList.get(i);
                tUserListOn.add(tUserList.get(i));
                // TRoleRight roleRight=new TRoleRight();
                // roleRight.setTRight((TRight)obj1);
              }
            }
            memberChargeDetailDialog = new MemberChargeDetailDialog(null, "会员充值", true);
            memberChargeDetailDialog.showDialog(tUserListOn);
            table.updateUI();
          } catch (Exception e1) {
            e1.printStackTrace();
          }
        }
      } else {
        JOptionPane.showMessageDialog(null, "请先选择行数据");
      }
    } else if (e.getSource() == memberDetailButton) {
      // 查看会员行为
      if (table.getSelectedRow() != -1) {
        String userID = (String) table.getValueAt(table.getSelectedRow(), -1);
        try {
          TUser tUser = tUserService.getByIdService(userID);
          tUser.setUserID(userID);
          memberBehaviorDialog = new MemberBehaviorDialog(null, "会员行为", true);
          memberBehaviorDialog.showDialog(tUser);
        } catch (Exception e1) {
          e1.printStackTrace();
        }
      } else {
        JOptionPane.showMessageDialog(null, "请先选择行数据");
      }
    } else if (e.getSource() == noticeButton) {
      // 通知
      if (table.getSelectedRow() != -1) {
        boolean[] bools = memberQueryCardModel.getBools();
        boolean select = false; // 检查是否有选中的商品 如果没选中false 否则true
        for (int i = bools.length - 1; i >= 0; --i) {
          if (bools[i]) {
            select = true;
            break;
          }
        }
        if (!select) {
          JOptionPane.showMessageDialog(null, "请先选择用户!");
          return;
        } else {
          try {

            List<TUser> tUserList = memberQueryCardModel.getTCommodityList();
            List<TUser> tUserListOn = new ArrayList();
            for (int i = 0; i < tUserList.size(); i++) {
              if (bools[i]) {
                tUserListOn.add(tUserList.get(i));
              }
            }
            memberNoticeDetailDialog = new MemberNoticeDetailDialog(null, "通知会员", true);
            memberNoticeDetailDialog.showDialog(tUserListOn);
            table.updateUI();
          } catch (Exception e1) {
            e1.printStackTrace();
          }
        }
      } else {
        JOptionPane.showMessageDialog(null, "请先选择行数据");
      }
    } else if (e.getSource() == clearButton) {
      // 清空
      cardNumTF.getText().setText("");
      nameTF.getText().setText("");
      tel.getText().setText("");
      startTimeTF.setDate(null);
      timeTF.setDate(null);
    }
  }
  @Override
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == sureButton) {
      Boolean isShow = false;
      // 确定
      String fillMoneyT = fillMoneyTF.getText().getText().trim(); // 充值金额
      String giftMoneyT = giftMoneyTF.getText().getText().trim(); // 赠送金额
      if (!MatcherFormatUtil.MatcherPriceScheme(fillMoneyT)) {
        JOptionPane.showMessageDialog(null, "充值金额 不能为空,且小数点左边最多10位数字,右边最多2位数字");
        fillMoneyTF.getText().setText("");
        fillMoneyTF.getText().requestFocus();
        return;
      }
      if (!MatcherFormatUtil.MatcherPriceScheme(giftMoneyT)) {
        JOptionPane.showMessageDialog(null, "请在充值金额栏点击回车获取赠送金额!");
        giftMoneyTF.getText().setText("");
        giftMoneyTF.getText().requestFocus();
        return;
      }
      for (int i = 0; i < tUser.size(); i++) {
        if (giftMoneyTF.getText().getText().trim() != "") {
          Double totalMoney =
              Double.parseDouble(giftMoneyTF.getText().getText().trim())
                  + Double.parseDouble(fillMoneyT);
          tUser.get(i).setMoney(totalMoney + tUser.get(i).getMoney());
        } else {
          tUser.get(i).setMoney(Double.parseDouble(fillMoneyT));
        }
        try {
          Date date = new Date();
          if (tUserService.modifyRechargeService(tUser.get(i))) {
            BuildSpringApplication.getInstance()
                .getTOpLogServiceImpl()
                .addOpLogService("会员充值,卡号为:+" + tUser.get(i).getCardNum() + ",充值金额:" + fillMoneyT);

            TShopRecharge tShopRecharge = new TShopRecharge(); // 添加明细
            tShopRecharge.setRechargeID(UUID.GenUUID15());
            tShopRecharge.setUserID(userID); // 单据编号CHAR(15)
            tShopRecharge.setChargeRuleID("");
            tShopRecharge.setHappenTime(date);
            tShopRecharge.setMoney(Double.parseDouble(fillMoneyT));
            tShopRecharge.setGiftMoney(Double.parseDouble(giftMoneyTF.getText().getText().trim()));
            tShopRechargeService.saveService(tShopRecharge);
            // 添加资金出入
            ApplicationContext.addMondyInOut(
                ApplicationContext.MONEYINOUT_TYPE_IN,
                ApplicationContext.OPERATOR_ID,
                ApplicationContext.MONEYINOUT_SOURCE_TYPE5,
                tShopRecharge.getRechargeID());
            isShow = true;
          }
        } catch (Exception e1) {
          isShow = false;
          e1.printStackTrace();
        }
      }
      if (isShow) {
        JOptionPane.showMessageDialog(null, "充值成功!");
        this.dispose();
      } else {
        JOptionPane.showMessageDialog(null, "数据异常。");
      }
    } else if (e.getSource() == cancelButton) {
      this.dispose();
    }
  }