// 设置单元格的值 @Override public void setValueAt(Object aValue, int rowIndex, int columnIndex) { TShopCharge tShopCharge = tShopChargeList.get(rowIndex); if (tShopCharge != null && aValue != null) { switch (columnIndex) { case 0: break; case 1: tShopCharge.setSelect(!tShopCharge.isSelect()); return; case 2: if (aValue != null && !aValue.toString().equals("") && MatcherFormatUtil.MatcherPriceScheme(aValue.toString()) && aValue.toString().length() < 10) { tShopCharge.setAMount(Double.parseDouble(aValue.toString())); } break; case 3: if (aValue != null && !aValue.toString().equals("") && MatcherFormatUtil.MatcherPriceScheme(aValue.toString()) && aValue.toString().length() < 10) { tShopCharge.setGiftAmount(Double.parseDouble(aValue.toString())); } break; case 4: tShopCharge.setType(aValue.toString()); break; case 5: return; case 6: tShopCharge.setStartTimeStr(aValue.toString()); try { tShopCharge.setStartTime(DateUtil.getDate(aValue.toString(), DateUtil.TYPE_DATE)); } catch (ParseException e) { e.printStackTrace(); } break; case 7: tShopCharge.setEndTimeStr(aValue.toString()); try { tShopCharge.setEndTime(DateUtil.getDate(aValue.toString(), DateUtil.TYPE_DATE)); } catch (ParseException e) { e.printStackTrace(); } break; case 9: tShopCharge.setIsValid(!tShopCharge.isIsValid()); break; } tShopCharge.setSelect(true); fireTableCellUpdated(rowIndex, 1); } }
@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(); } }