Changeset a6869d7a8be43750137d1f53771cb618c826af71
- Timestamp:
- 10/28/07 15:24:29
(1 year ago)
- Author:
- Christopher Jung <bktheg@web.de>
- git-committer:
- Christopher Jung <bktheg@web.de> 1193581469 +0100
- git-parent:
[91e50d387e12a64e064a839045ab8f220ad7165d]
- git-author:
- Christopher Jung <bktheg@web.de> 1193581469 +0100
- Message:
User.transferMoneyFrom auf Hibernate umgestellt und Wertebereich von UserMoneyTransfer?-Logs angepasst
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r7375108 |
ra6869d7 |
|
| 38 | 38 | import net.driftingsouls.ds2.server.framework.ContextMap; |
|---|
| 39 | 39 | import net.driftingsouls.ds2.server.framework.Loggable; |
|---|
| 40 | | import net.driftingsouls.ds2.server.framework.db.Database; |
|---|
| 41 | 40 | import net.driftingsouls.ds2.server.framework.db.SQLResultRow; |
|---|
| 42 | 41 | import net.driftingsouls.ds2.server.framework.templates.TemplateEngine; |
|---|
| … | … | |
| 581 | 580 | */ |
|---|
| 582 | 581 | public void transferMoneyFrom( int fromID, BigInteger count, String text, boolean faketransfer, int transfertype) { |
|---|
| 583 | | Database db = context.getDatabase(); |
|---|
| | 582 | org.hibernate.Session db = context.getDB(); |
|---|
| 584 | 583 | |
|---|
| 585 | 584 | if( !count.equals(BigInteger.ZERO) ) { |
|---|
| | 585 | User fromUser = (User)context.getDB().get(User.class, fromID); |
|---|
| 586 | 586 | if( (fromID != 0) && !faketransfer ) { |
|---|
| 587 | | User fromUser = (User)context.getDB().get(User.class, fromID); |
|---|
| 588 | 587 | fromUser.setKonto(fromUser.getKonto().subtract(count)); |
|---|
| 589 | 588 | } |
|---|
| … | … | |
| 591 | 590 | konto = konto.add(count); |
|---|
| 592 | 591 | |
|---|
| 593 | | db.update("INSERT INTO user_moneytransfer (`from`,`to`,`time`,`count`,`text`,`fake`,`type`) ", |
|---|
| 594 | | "VALUES ('",fromID,"','",this.getID(),"','",Common.time(),"','",count,"','",db.prepareString(text),"','",(faketransfer ? 1 : 0),"','",transfertype,"')"); |
|---|
| | 592 | UserMoneyTransfer log = new UserMoneyTransfer(fromUser, this, count, text); |
|---|
| | 593 | log.setFake(faketransfer); |
|---|
| | 594 | log.setType(UserMoneyTransfer.Transfer.values()[transfertype]); |
|---|
| | 595 | db.persist(log); |
|---|
| 595 | 596 | } |
|---|
| 596 | 597 | } |
|---|
| r8fa415e |
ra6869d7 |
|
| 18 | 18 | */ |
|---|
| 19 | 19 | package net.driftingsouls.ds2.server.entities; |
|---|
| | 20 | |
|---|
| | 21 | import java.math.BigInteger; |
|---|
| 20 | 22 | |
|---|
| 21 | 23 | import javax.persistence.Entity; |
|---|
| … | … | |
| 70 | 72 | private User to; |
|---|
| 71 | 73 | private long time; |
|---|
| 72 | | private long count; |
|---|
| | 74 | private BigInteger count; |
|---|
| 73 | 75 | private String text; |
|---|
| 74 | 76 | private int fake; |
|---|
| … | … | |
| 90 | 92 | * @param text Der Erlaeutungstext |
|---|
| 91 | 93 | */ |
|---|
| 92 | | public UserMoneyTransfer(User from, User to, long count, String text) { |
|---|
| | 94 | public UserMoneyTransfer(User from, User to, BigInteger count, String text) { |
|---|
| 93 | 95 | this.from = from; |
|---|
| 94 | 96 | this.to = to; |
|---|
| … | … | |
| 104 | 106 | * @return Der Geldbetrag |
|---|
| 105 | 107 | */ |
|---|
| 106 | | public long getCount() { |
|---|
| | 108 | public BigInteger getCount() { |
|---|
| 107 | 109 | return count; |
|---|
| 108 | 110 | } |
|---|
| … | … | |
| 112 | 114 | * @param count Der Geldbetrag |
|---|
| 113 | 115 | */ |
|---|
| 114 | | public void setCount(long count) { |
|---|
| | 116 | public void setCount(BigInteger count) { |
|---|
| 115 | 117 | this.count = count; |
|---|
| 116 | 118 | } |
|---|