Changeset f4821b73541f00e6b06ff89c4b0cb271059bf977
- Timestamp:
- 11/10/07 12:53:17
(1 year ago)
- Author:
- Christopher Jung <bktheg@web.de>
- git-committer:
- Christopher Jung <bktheg@web.de> 1194695597 +0100
- git-parent:
[c00337cf38193e3ac844b5cdf57344b18d85fe0a]
- git-author:
- Christopher Jung <bktheg@web.de> 1194695597 +0100
- Message:
Fraktionen: Teile des Shops auf Hibernate umgestellt
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rd9e8da0 |
rf4821b7 |
|
| 20 | 20 | |
|---|
| 21 | 21 | import java.math.BigDecimal; |
|---|
| | 22 | import java.math.BigInteger; |
|---|
| 22 | 23 | import java.util.ArrayList; |
|---|
| 23 | 24 | import java.util.HashMap; |
|---|
| … | … | |
| 39 | 40 | import net.driftingsouls.ds2.server.config.Systems; |
|---|
| 40 | 41 | import net.driftingsouls.ds2.server.entities.FactionOffer; |
|---|
| | 42 | import net.driftingsouls.ds2.server.entities.FactionShopEntry; |
|---|
| | 43 | import net.driftingsouls.ds2.server.entities.FactionShopOrder; |
|---|
| | 44 | import net.driftingsouls.ds2.server.entities.GtuWarenKurse; |
|---|
| 41 | 45 | import net.driftingsouls.ds2.server.entities.GtuZwischenlager; |
|---|
| 42 | 46 | import net.driftingsouls.ds2.server.entities.PaketVersteigerung; |
|---|
| 43 | 47 | import net.driftingsouls.ds2.server.entities.User; |
|---|
| | 48 | import net.driftingsouls.ds2.server.entities.UserMoneyTransfer; |
|---|
| 44 | 49 | import net.driftingsouls.ds2.server.entities.Versteigerung; |
|---|
| 45 | 50 | import net.driftingsouls.ds2.server.framework.Common; |
|---|
| … | … | |
| 88 | 93 | * @param data Die SQL-Ergebniszeile zum Eintrag |
|---|
| 89 | 94 | */ |
|---|
| 90 | | public ShopEntry(SQLResultRow data) { |
|---|
| 91 | | this.id = data.getInt("id"); |
|---|
| 92 | | this.factionID = data.getInt("faction_id"); |
|---|
| 93 | | this.type = data.getInt("type"); |
|---|
| 94 | | this.resource = data.getString("resource"); |
|---|
| 95 | | this.price = data.getLong("price"); |
|---|
| 96 | | this.availability = data.getInt("availability"); |
|---|
| | 95 | public ShopEntry(FactionShopEntry data) { |
|---|
| | 96 | this.id = data.getId(); |
|---|
| | 97 | this.factionID = data.getFaction(); |
|---|
| | 98 | this.type = data.getType(); |
|---|
| | 99 | this.resource = data.getResource(); |
|---|
| | 100 | this.price = data.getPrice(); |
|---|
| | 101 | this.availability = data.getAvailability(); |
|---|
| 97 | 102 | } |
|---|
| 98 | 103 | |
|---|
| … | … | |
| 223 | 228 | * @param data Die SQL-Ergebniszeile des Shopeintrags |
|---|
| 224 | 229 | */ |
|---|
| 225 | | public ShopShipEntry( SQLResultRow data ) { |
|---|
| | 230 | public ShopShipEntry( FactionShopEntry data ) { |
|---|
| 226 | 231 | super(data); |
|---|
| 227 | 232 | |
|---|
| … | … | |
| 257 | 262 | * @param data Die SQL-Ergebniszeile des Shopeintrags |
|---|
| 258 | 263 | */ |
|---|
| 259 | | public ShopResourceEntry( SQLResultRow data ) { |
|---|
| | 264 | public ShopResourceEntry( FactionShopEntry data ) { |
|---|
| 260 | 265 | super(data); |
|---|
| 261 | 266 | |
|---|
| … | … | |
| 314 | 319 | * @param data Die SQL-Ergebniszeile des Shopeintrags |
|---|
| 315 | 320 | */ |
|---|
| 316 | | public ShopGanyTransportEntry( SQLResultRow[] data ) { |
|---|
| | 321 | public ShopGanyTransportEntry( FactionShopEntry[] data ) { |
|---|
| 317 | 322 | super(data[0]); |
|---|
| 318 | 323 | |
|---|
| 319 | 324 | for( int i=0; i < data.length; i++ ) { |
|---|
| 320 | | if( data[i].getLong("price") < this.minprice ) { |
|---|
| 321 | | this.minprice = data[i].getLong("price"); |
|---|
| | 325 | if( data[i].getPrice() < this.minprice ) { |
|---|
| | 326 | this.minprice = data[i].getPrice(); |
|---|
| 322 | 327 | } |
|---|
| 323 | | if( data[i].getLong("price") > this.maxprice ) { |
|---|
| 324 | | this.maxprice = data[i].getLong("price"); |
|---|
| | 328 | if( data[i].getPrice() > this.maxprice ) { |
|---|
| | 329 | this.maxprice = data[i].getPrice(); |
|---|
| 325 | 330 | } |
|---|
| 326 | | this.ganytransid = data[0].getInt("id"); |
|---|
| | 331 | this.ganytransid = data[0].getId(); |
|---|
| 327 | 332 | } |
|---|
| 328 | 333 | } |
|---|
| … | … | |
| 790 | 795 | |
|---|
| 791 | 796 | TemplateEngine t = this.getTemplateEngine(); |
|---|
| 792 | | Database db = getDatabase(); |
|---|
| | 797 | org.hibernate.Session db = getDB(); |
|---|
| 793 | 798 | User user = (User)this.getUser(); |
|---|
| 794 | 799 | |
|---|
| … | … | |
| 830 | 835 | t.setBlock("_UEBER", "moneytransfer.listitem", "moneytransfer.list"); |
|---|
| 831 | 836 | |
|---|
| 832 | | SQLQuery entry = db.query("SELECT * FROM user_moneytransfer WHERE `type`<=",transtype," AND ((`from`=",user.getID(),") OR (`to`=",user.getID(),")) ORDER BY `time` DESC LIMIT 40"); |
|---|
| 833 | | while( entry.next() ) { |
|---|
| | 837 | List transferList = db.createQuery("from UserMoneyTransfer umt " + |
|---|
| | 838 | "where umt.type<= :transtype and (umt.from= :user or umt.to= :user) order by umt.time desc") |
|---|
| | 839 | .setInteger("transtype", transtype) |
|---|
| | 840 | .setEntity("user", user) |
|---|
| | 841 | .setMaxResults(40) |
|---|
| | 842 | .list(); |
|---|
| | 843 | for( Iterator iter=transferList.iterator(); iter.hasNext(); ) { |
|---|
| | 844 | UserMoneyTransfer entry = (UserMoneyTransfer)iter.next(); |
|---|
| | 845 | |
|---|
| 834 | 846 | User player = null; |
|---|
| 835 | 847 | |
|---|
| 836 | | if( entry.getInt("from") == user.getID() ) { |
|---|
| 837 | | player = (User)getDB().get(User.class, entry.getInt("to")); |
|---|
| | 848 | if( user.equals(entry.getFrom()) ) { |
|---|
| | 849 | player = entry.getTo(); |
|---|
| 838 | 850 | } |
|---|
| 839 | 851 | else { |
|---|
| 840 | | player = (User)getDB().get(User.class, entry.getInt("from")); |
|---|
| 841 | | } |
|---|
| 842 | | |
|---|
| 843 | | //Negative Ueberweiszungen (die GTU wollte z.B. Geld von uns) beruecksichtigen |
|---|
| | 852 | player = entry.getFrom(); |
|---|
| | 853 | } |
|---|
| | 854 | |
|---|
| | 855 | // Negative Ueberweiszungen (die GTU wollte z.B. Geld von uns) beruecksichtigen |
|---|
| 844 | 856 | int from = 0; |
|---|
| 845 | | long count = entry.getLong("count"); |
|---|
| 846 | | if(entry.getInt("from") == user.getID() || (count < 0 && entry.getInt("from") != user.getID())) |
|---|
| 847 | | { |
|---|
| | 857 | BigInteger count = entry.getCount(); |
|---|
| | 858 | if( user.equals(entry.getFrom()) || (count.compareTo(BigInteger.ZERO) < 0 && !user.equals(entry.getFrom()))) { |
|---|
| 848 | 859 | from = 1; |
|---|
| 849 | 860 | } |
|---|
| 850 | 861 | |
|---|
| 851 | 862 | //Ueberweiszungen an andere durch - kennzeichnen |
|---|
| 852 | | if(from == 1) |
|---|
| 853 | | { |
|---|
| 854 | | if(count > 0) |
|---|
| 855 | | { |
|---|
| 856 | | count = -1 * count; |
|---|
| | 863 | if(from == 1) { |
|---|
| | 864 | if(count.compareTo(BigInteger.ZERO) > 0) { |
|---|
| | 865 | count = count.negate(); |
|---|
| 857 | 866 | } |
|---|
| 858 | 867 | } |
|---|
| 859 | | else |
|---|
| 860 | | { |
|---|
| 861 | | count = Math.abs(count); |
|---|
| 862 | | } |
|---|
| 863 | | |
|---|
| 864 | | t.setVar( "moneytransfer.time", Common.date("j.n.Y H:i",entry.getLong("time")), |
|---|
| | 868 | else { |
|---|
| | 869 | count = count.abs(); |
|---|
| | 870 | } |
|---|
| | 871 | |
|---|
| | 872 | t.setVar( "moneytransfer.time", Common.date("j.n.Y H:i",entry.getTime()), |
|---|
| 865 | 873 | "moneytransfer.from", from, |
|---|
| 866 | 874 | "moneytransfer.player", Common._title(player.getName()), |
|---|
| 867 | 875 | "moneytransfer.player.id", player.getID(), |
|---|
| 868 | 876 | "moneytransfer.count", Common.ln(count), |
|---|
| 869 | | "moneytransfer.reason", entry.getString("text") ); |
|---|
| | 877 | "moneytransfer.reason", entry.getText() ); |
|---|
| 870 | 878 | |
|---|
| 871 | 879 | t.parse("moneytransfer.list", "moneytransfer.listitem", true); |
|---|
| 872 | 880 | } |
|---|
| 873 | | entry.free(); |
|---|
| 874 | 881 | |
|---|
| 875 | 882 | // GTU-Preise |
|---|
| … | … | |
| 877 | 884 | t.setBlock("kurse.listitem","kurse.waren.listitem","kurse.waren.list"); |
|---|
| 878 | 885 | |
|---|
| 879 | | SQLQuery kurse = db.query("SELECT * FROM gtu_warenkurse"); |
|---|
| 880 | | while( kurse.next() ) { |
|---|
| 881 | | Cargo kurseCargo = new Cargo( Cargo.Type.STRING, kurse.getString("kurse") ); |
|---|
| | 886 | List kurseList = db.createQuery("from GtuWarenKurse").list(); |
|---|
| | 887 | for( Iterator iter=kurseList.iterator(); iter.hasNext(); ) { |
|---|
| | 888 | GtuWarenKurse kurse = (GtuWarenKurse)iter.next(); |
|---|
| | 889 | |
|---|
| | 890 | Cargo kurseCargo = new Cargo(kurse.getKurse()); |
|---|
| 882 | 891 | kurseCargo.setOption( Cargo.Option.SHOWMASS, false ); |
|---|
| 883 | 892 | |
|---|
| 884 | | t.setVar( "posten.name", kurse.getString("name"), |
|---|
| | 893 | t.setVar( "posten.name", kurse.getName(), |
|---|
| 885 | 894 | "kurse.waren.list", "" ); |
|---|
| 886 | 895 | |
|---|
| … | … | |
| 894 | 903 | t.parse("kurse.list","kurse.listitem",true); |
|---|
| 895 | 904 | } |
|---|
| 896 | | kurse.free(); |
|---|
| 897 | 905 | } |
|---|
| 898 | 906 | |
|---|
| … | … | |
| 1516 | 1524 | public void shopOrderAction() { |
|---|
| 1517 | 1525 | TemplateEngine t = getTemplateEngine(); |
|---|
| 1518 | | Database db = getDatabase(); |
|---|
| | 1526 | org.hibernate.Session db = getDB(); |
|---|
| 1519 | 1527 | User user = (User)getUser(); |
|---|
| 1520 | 1528 | |
|---|
| … | … | |
| 1530 | 1538 | int ordercount = getInteger("ordercount"); |
|---|
| 1531 | 1539 | |
|---|
| 1532 | | SQLResultRow shopentry = db.first("SELECT * FROM factions_shop_entries WHERE id=",shopentryID); |
|---|
| 1533 | | if( shopentry.isEmpty() ) { |
|---|
| | 1540 | FactionShopEntry shopentry = (FactionShopEntry)db.get(FactionShopEntry.class, shopentryID); |
|---|
| | 1541 | if( shopentry == null ) { |
|---|
| 1534 | 1542 | t.setVar("show.message", "<span style=\"color:red\">Es existiert kein passendes Angebot</span>"); |
|---|
| 1535 | 1543 | redirect("shop"); |
|---|
| … | … | |
| 1538 | 1546 | |
|---|
| 1539 | 1547 | // Ganymed-Transporte verarbeiten |
|---|
| 1540 | | if( shopentry.getInt("type") == 2 ) { |
|---|
| | 1548 | if( shopentry.getType() == 2 ) { |
|---|
| 1541 | 1549 | redirect("shopOrderGanymede"); |
|---|
| 1542 | 1550 | |
|---|
| … | … | |
| 1559 | 1567 | ShopEntry entry = null; |
|---|
| 1560 | 1568 | |
|---|
| 1561 | | if( shopentry.getInt("type") == 1 ) { //Schiff |
|---|
| | 1569 | if( shopentry.getType() == 1 ) { //Schiff |
|---|
| 1562 | 1570 | entry = new ShopShipEntry(shopentry); |
|---|
| 1563 | 1571 | } |
|---|
| 1564 | | else if( shopentry.getInt("type") == 0 ) { // Cargo |
|---|
| | 1572 | else if( shopentry.getType() == 0 ) { // Cargo |
|---|
| 1565 | 1573 | entry = new ShopResourceEntry(shopentry); |
|---|
| 1566 | 1574 | } |
|---|
| 1567 | 1575 | else { |
|---|
| 1568 | | throw new RuntimeException("Unbekannter Versteigerungstyp '"+shopentry.getInt("type")+"'"); |
|---|
| | 1576 | throw new RuntimeException("Unbekannter Versteigerungstyp '"+shopentry.getType()+"'"); |
|---|
| 1569 | 1577 | } |
|---|
| 1570 | 1578 | |
|---|
| … | … | |
| 1581 | 1589 | "order.entry", entry.getID() ); |
|---|
| 1582 | 1590 | } |
|---|
| 1583 | | else { |
|---|
| 1584 | | db.tBegin(); |
|---|
| 1585 | | db.update("INSERT INTO factions_shop_orders " , |
|---|
| 1586 | | "(shopentry_id,user_id,count,price,date,adddata) VALUES " , |
|---|
| 1587 | | "(",entry.getID(),",",user.getID(),",",ordercount,",",(ordercount*entry.getPrice()),",",Common.time(),",'",ordersys+":"+orderx+"/"+ordery+"')"); |
|---|
| | 1591 | else { |
|---|
| | 1592 | FactionShopOrder order = new FactionShopOrder(shopentry, user); |
|---|
| | 1593 | order.setCount(ordercount); |
|---|
| | 1594 | order.setPrice(ordercount*entry.getPrice()); |
|---|
| | 1595 | order.setAddData(ordersys+":"+orderx+"/"+ordery); |
|---|
| | 1596 | |
|---|
| | 1597 | db.persist(order); |
|---|
| 1588 | 1598 | |
|---|
| 1589 | 1599 | User faction = (User)getDB().get(User.class, this.faction); |
|---|
| … | … | |
| 1591 | 1601 | |
|---|
| 1592 | 1602 | PM.send(user, this.faction, "[auto] Shop-Bestellung", "Besteller: [userprofile="+user.getID()+"]"+user.getName()+" ("+user.getID()+")[/userprofile]\nObjekt: "+entry.getName()+"\nMenge:Â "+ordercount+"\nLieferkoordinaten: "+ordersys+":"+orderx+"/"+ordery+"\nZeitpunkt: "+Common.date("d.m.Y H:i:s")); |
|---|
| 1593 | | if( !db.tCommit() ) { |
|---|
| 1594 | | addError("Die Bestellung konnte nicht korrekt verarbeitet werden. Bitte versuchen sie es erneut."); |
|---|
| 1595 | | redirect("shop"); |
|---|
| 1596 | | return; |
|---|
| 1597 | | } |
|---|
| 1598 | 1603 | |
|---|
| 1599 | 1604 | t.setVar("show.message", "Bestellung über "+ordercount+"x "+entry.getName()+" für "+Common.ln(entry.getPrice()*ordercount)+" erhalten und vom System bestätigt.<br />Sollten noch Rückfragen bestehend so wird sich ein Sachbearbeiter bei ihnen melden.<br />Einen angenehmen Tag noch!"); |
|---|
| … | … | |
| 1612 | 1617 | public void shopChangeAvailabilityAction() { |
|---|
| 1613 | 1618 | TemplateEngine t = getTemplateEngine(); |
|---|
| 1614 | | Database db = getDatabase(); |
|---|
| | 1619 | org.hibernate.Session db = getDB(); |
|---|
| 1615 | 1620 | User user = (User)getUser(); |
|---|
| 1616 | 1621 | |
|---|
| … | … | |
| 1627 | 1632 | int availability = getInteger("availability"); |
|---|
| 1628 | 1633 | |
|---|
| 1629 | | SQLResultRow shopentry = db.first("SELECT * FROM factions_shop_entries WHERE faction_id=",this.faction," AND id=",shopentryID); |
|---|
| 1630 | | if( shopentry.isEmpty() ) { |
|---|
| | 1634 | FactionShopEntry entry = (FactionShopEntry)db.get(FactionShopEntry.class, shopentryID); |
|---|
| | 1635 | if( (entry == null) || (entry.getFaction() != this.faction) ) { |
|---|
| 1631 | 1636 | addError("Es konnte kein passender Shopeintrag gefunden werden"); |
|---|
| 1632 | 1637 | redirect("shop"); |
|---|
| … | … | |
| 1640 | 1645 | } |
|---|
| 1641 | 1646 | |
|---|
| 1642 | | db.update("UPDATE factions_shop_entries SET availability=",availability," WHERE id=",shopentry.getInt("id")); |
|---|
| | 1647 | entry.setAvailability(availability); |
|---|
| 1643 | 1648 | |
|---|
| 1644 | 1649 | t.setVar("show.message", "Neuer Status erfolgreich zugewiesen"); |
|---|
| … | … | |
| 1656 | 1661 | public void changeShopOrderStatusAction() { |
|---|
| 1657 | 1662 | TemplateEngine t = getTemplateEngine(); |
|---|
| 1658 | | Database db = getDatabase(); |
|---|
| | 1663 | org.hibernate.Session db = getDB(); |
|---|
| 1659 | 1664 | User user = (User)getUser(); |
|---|
| 1660 | 1665 | |
|---|
| … | … | |
| 1671 | 1676 | int orderentryID = getInteger("orderentry"); |
|---|
| 1672 | 1677 | |
|---|
| 1673 | | SQLResultRow orderentry = db.first("SELECT t1.* FROM factions_shop_orders t1 JOIN factions_shop_entries t2 ON t1.shopentry_id=t2.id WHERE t2.faction_id=",this.faction," AND t1.status<4 AND t1.id=",orderentryID); |
|---|
| 1674 | | if( orderentry.isEmpty() ) { |
|---|
| | 1678 | FactionShopOrder order = (FactionShopOrder)db.get(FactionShopOrder.class, orderentryID); |
|---|
| | 1679 | |
|---|
| | 1680 | if( (order == null) || (order.getStatus() > 3) || (order.getShopEntry().getFaction() != this.faction) ) { |
|---|
| 1675 | 1681 | addError("Es konnte kein passender Ordereintrag gefunden werden"); |
|---|
| 1676 | 1682 | redirect("shop"); |
|---|
| … | … | |
| 1684 | 1690 | } |
|---|
| 1685 | 1691 | |
|---|
| 1686 | | db.update("UPDATE factions_shop_orders SET status=",orderstatus," WHERE id=",orderentry.getInt("id")); |
|---|
| | 1692 | order.setStatus(orderstatus); |
|---|
| 1687 | 1693 | |
|---|
| 1688 | 1694 | t.setVar("show.message", "Neuer Status erfolgreich zugewiesen"); |
|---|
| … | … | |
| 1726 | 1732 | public void shopAction() { |
|---|
| 1727 | 1733 | TemplateEngine t = getTemplateEngine(); |
|---|
| 1728 | | Database db = getDatabase(); |
|---|
| | 1734 | org.hibernate.Session db = getDB(); |
|---|
| 1729 | 1735 | User user = (User)getUser(); |
|---|
| 1730 | 1736 | |
|---|
| … | … | |
| 1741 | 1747 | |
|---|
| 1742 | 1748 | if( this.faction != user.getID() ) { |
|---|
| 1743 | | SQLQuery orderentry = db.query("SELECT t1.* FROM factions_shop_orders t1 JOIN factions_shop_entries t2 ON t1.shopentry_id=t2.id WHERE t2.faction_id=",this.faction," AND t1.user_id=",user.getID()," AND t1.status<4"); |
|---|
| 1744 | | while( orderentry.next() ) { |
|---|
| 1745 | | // Keine so geschickte loesung, es reicht aber fuer den moment: |
|---|
| 1746 | | SQLResultRow shopentry = db.first("SELECT * FROM factions_shop_entries WHERE id=",orderentry.getInt("shopentry_id")); |
|---|
| | 1749 | List orderentryList = db.createQuery("from FactionShopOrder as fso " + |
|---|
| | 1750 | "where fso.shopEntry.faction= :faction and fso.user= :user and fso.status<4") |
|---|
| | 1751 | .setInteger("faction", faction) |
|---|
| | 1752 | .setEntity("user", user) |
|---|
| | 1753 | .list(); |
|---|
| | 1754 | for( Iterator iter=orderentryList.iterator(); iter.hasNext(); ) { |
|---|
| | 1755 | FactionShopOrder order = (FactionShopOrder)iter.next(); |
|---|
| | 1756 | |
|---|
| | 1757 | FactionShopEntry shopentry = order.getShopEntry(); |
|---|
| 1747 | 1758 | ShopEntry shopEntryObj = null; |
|---|
| 1748 | 1759 | |
|---|
| 1749 | 1760 | String entryadddata = ""; |
|---|
| 1750 | | if( shopentry.getInt("type") == 1 ) { //Schiff |
|---|
| | 1761 | if( shopentry.getType() == 1 ) { //Schiff |
|---|
| 1751 | 1762 | shopEntryObj = new ShopShipEntry(shopentry); |
|---|
| 1752 | 1763 | } |
|---|
| 1753 | | else if( shopentry.getInt("type") == 0 ) { // Cargo |
|---|
| | 1764 | else if( shopentry.getType() == 0 ) { // Cargo |
|---|
| 1754 | 1765 | shopEntryObj = new ShopResourceEntry(shopentry); |
|---|
| 1755 | 1766 | } |
|---|
| 1756 | | else if( shopentry.getInt("type") == 2 ) { //Ganytransport |
|---|
| 1757 | | shopEntryObj = new ShopGanyTransportEntry(new SQLResultRow[] {shopentry}); |
|---|
| | 1767 | else if( shopentry.getType() == 2 ) { //Ganytransport |
|---|
| | 1768 | shopEntryObj = new ShopGanyTransportEntry(new FactionShopEntry[] {shopentry}); |
|---|
| 1758 | 1769 | |
|---|
| 1759 | | String[] tmp = StringUtils.split(orderentry.getString("adddata"), "@"); |
|---|
| 1760 | | int ganyid = Integer.parseInt(tmp[0]); |
|---|
| 1761 | | |
|---|
| 1762 | | String ganyname = Common._plaintitle(db.first("SELECT name FROM ships WHERE id=",ganyid).getString("name")); |
|---|
| 1763 | | |
|---|
| 1764 | | String[] coords = StringUtils.split(tmp[1], "->"); |
|---|
| 1765 | | entryadddata = ganyname+" ("+ganyid+")<br />nach "+coords[1]; |
|---|
| | 1770 | String[] tmp = StringUtils.split(order.getAddData(), "@"); |
|---|
| | 1771 | |
|---|
| | 1772 | Ship gany = (Ship)db.get(Ship.class, Integer.parseInt(tmp[0])); |
|---|
| | 1773 | if( gany != null ) { |
|---|
| | 1774 | String ganyname = Common._plaintitle(gany.getName()); |
|---|
| | 1775 | |
|---|
| | 1776 | String[] coords = StringUtils.split(tmp[1], "->"); |
|---|
| | 1777 | entryadddata = ganyname+" ("+gany.getId()+")<br />nach "+coords[1]; |
|---|
| | 1778 | } |
|---|
| 1766 | 1779 | } |
|---|
| 1767 | 1780 | else { |
|---|
| 1768 | | throw new RuntimeException("Unbekannter Shopeintrag-Typ '"+shopentry.getInt("type")+"'"); |
|---|
| | 1781 | throw new RuntimeException("Unbekannter Shopeintrag-Typ '"+shopentry.getType()+"'"); |
|---|
| 1769 | 1782 | } |
|---|
| 1770 | 1783 | |
|---|
| … | … | |
| 1773 | 1786 | "orderentry.type.image", shopEntryObj.getImage(), |
|---|
| 1774 | 1787 | "orderentry.link", shopEntryObj.getLink(), |
|---|
| 1775 | | "orderentry.id", orderentry.getInt("id"), |
|---|
| 1776 | | "orderentry.price", Common.ln(orderentry.getLong("price")), |
|---|
| 1777 | | "orderentry.count", Common.ln(orderentry.getInt("count")), |
|---|
| 1778 | | "orderentry.status", getStatusName(orderentry.getInt("status")), |
|---|
| 1779 | | "orderentry.bgcolor", getStatusColor(orderentry.getInt("status")) ); |
|---|
| | 1788 | "orderentry.id", order.getId(), |
|---|
| | 1789 | "orderentry.price", Common.ln(order.getPrice()), |
|---|
| | 1790 | "orderentry.count", Common.ln(order.getCount()), |
|---|
| | 1791 | "orderentry.status", getStatusName(order.getStatus()), |
|---|
| | 1792 | "orderentry.bgcolor", getStatusColor(order.getStatus()) ); |
|---|
| 1780 | 1793 | |
|---|
| 1781 | 1794 | t.parse("shop.orderlist.list", "shop.orderlist.listitem", true); |
|---|
| 1782 | 1795 | } |
|---|
| 1783 | | orderentry.free(); |
|---|
| 1784 | 1796 | } |
|---|
| 1785 | 1797 | else { |
|---|
| 1786 | 1798 | t.setVar("shop.owner", 1); |
|---|
| 1787 | 1799 | |
|---|
| 1788 | | SQLQuery orderentry = db.query("SELECT t1.*,IF(!t1.status,t1.status,t1.date) as orderprio FROM factions_shop_orders t1 JOIN factions_shop_entries t2 ON t1.shopentry_id=t2.id WHERE t2.faction_id=",this.faction," AND t1.status<4 ORDER BY orderprio ASC"); |
|---|
| 1789 | | while( orderentry.next() ) { |
|---|
| 1790 | | // Keine so geschickte loesung, es reicht aber fuer den moment: |
|---|
| 1791 | | SQLResultRow shopentry = db.first("SELECT * FROM factions_shop_entries WHERE id=",orderentry.getInt("shopentry_id")); |
|---|
| | 1800 | List orderentryList = db.createQuery("from FactionShopOrder as fso " + |
|---|
| | 1801 | "where fso.shopEntry.faction = :faction and fso.status < 4 " + |
|---|
| | 1802 | "order by case when fso.status=0 then fso.status else fso.date end asc") |
|---|
| | 1803 | .setInteger("faction", faction) |
|---|
| | 1804 | .list(); |
|---|
| | 1805 | for( Iterator iter=orderentryList.iterator(); iter.hasNext(); ) { |
|---|
| | 1806 | FactionShopOrder order = (FactionShopOrder)iter.next(); |
|---|
| | 1807 | |
|---|
| | 1808 | FactionShopEntry shopentry = order.getShopEntry(); |
|---|
| 1792 | 1809 | ShopEntry shopEntryObj = null; |
|---|
| 1793 | 1810 | |
|---|
| 1794 | 1811 | String entryadddata = ""; |
|---|
| 1795 | | if( shopentry.getInt("type") == 1 ) { //Schiff |
|---|
| | 1812 | if( shopentry.getType() == 1 ) { //Schiff |
|---|
| 1796 | 1813 | shopEntryObj = new ShopShipEntry(shopentry); |
|---|
| 1797 | 1814 | |
|---|
| 1798 | | entryadddata = "LK: "+orderentry.getString("adddata"); |
|---|
| | 1815 | entryadddata = "LK: "+order.getAddData(); |
|---|
| 1799 | 1816 | } |
|---|
| 1800 | | else if( shopentry.getInt("type") == 0 ) { // Cargo |
|---|
| | 1817 | else if( shopentry.getType() == 0 ) { // Cargo |
|---|
| 1801 | 1818 | shopEntryObj = new ShopResourceEntry(shopentry); |
|---|
| 1802 | | entryadddata = "LK: "+orderentry.getString("adddata"); |
|---|
| | 1819 | entryadddata = "LK: "+order.getAddData(); |
|---|
| 1803 | 1820 | } |
|---|
| 1804 | | else if( shopentry.getInt("type") == 2 ) { //Ganytransport |
|---|
| 1805 | | String[] tmp = StringUtils.split(orderentry.getString("adddata"), "@"); |
|---|
| | 1821 | else if( shopentry.getType() == 2 ) { //Ganytransport |
|---|
| | 1822 | String[] tmp = StringUtils.split(order.getAddData(), "@"); |
|---|
| 1806 | 1823 | int ganyid = Integer.parseInt(tmp[0]); |
|---|
| 1807 | 1824 | |
|---|
| … | … | |
| 1809 | 1826 | |
|---|
| 1810 | 1827 | entryadddata = ganyid+"<br />"+coords[0]+" - "+coords[1]; |
|---|
| 1811 | | shopEntryObj = new ShopGanyTransportEntry(new SQLResultRow[] {shopentry}); |
|---|
| | 1828 | shopEntryObj = new ShopGanyTransportEntry(new FactionShopEntry[] {shopentry}); |
|---|
| 1812 | 1829 | } |
|---|
| 1813 | 1830 | |
|---|
| 1814 | | User ownerobj = (User)getDB().get(User.class, orderentry.getInt("user_id")); |
|---|
| | 1831 | User ownerobj = order.getUser(); |
|---|
| 1815 | 1832 | |
|---|
| 1816 | 1833 | t.setVar( "orderentry.name", shopEntryObj.getName(), |
|---|
| 1817 | 1834 | "orderentry.adddata", entryadddata, |
|---|
| 1818 | | "orderentry.owner", orderentry.getInt("user_id"), |
|---|
| | 1835 | "orderentry.owner", order.getUser().getID(), |
|---|
| 1819 | 1836 | "orderentry.owner.name", Common._title(ownerobj.getName()), |
|---|
| 1820 | 1837 | "orderentry.link", shopEntryObj.getLink(), |
|---|
| 1821 | | "orderentry.id", orderentry.getInt("id"), |
|---|
| 1822 | | "orderentry.price", Common.ln(orderentry.getLong("price")), |
|---|
| 1823 | | "orderentry.count", Common.ln(orderentry.getInt("count")), |
|---|
| 1824 | | "orderentry.status", orderentry.getInt("status"), |
|---|
| 1825 | | "orderentry.status.name", getStatusName(orderentry.getInt("status")), |
|---|
| 1826 | | "orderentry.bgcolor", getStatusColor(orderentry.getInt("status")) ); |
|---|
| | 1838 | "orderentry.id", order.getId(), |
|---|
| | 1839 | "orderentry.price", Common.ln(order.getPrice()), |
|---|
| | 1840 | "orderentry.count", Common.ln(order.getCount()), |
|---|
| | 1841 | "orderentry.status", order.getStatus(), |
|---|
| | 1842 | "orderentry.status.name", getStatusName(order.getStatus()), |
|---|
| | 1843 | "orderentry.bgcolor", getStatusColor(order.getStatus()) ); |
|---|
| 1827 | 1844 | |
|---|
| 1828 | 1845 | t.parse("shop.shopownerlist.list", "shop.shopownerlist.listitem", true); |
|---|
| 1829 | 1846 | } |
|---|
| 1830 | | orderentry.free(); |
|---|
| 1831 | 1847 | } |
|---|
| 1832 | 1848 | |
|---|
| 1833 | 1849 | // Zuerst alle Ganymed-Transportdaten auslesen |
|---|
| 1834 | 1850 | |
|---|
| 1835 | | SQLQuery shopentry = db.query("SELECT * FROM factions_shop_entries WHERE faction_id=",this.faction," AND type=2"); |
|---|
| 1836 | | |
|---|
| 1837 | | SQLResultRow[] ganytransport = new SQLResultRow[shopentry.numRows()]; |
|---|
| | 1851 | List ganyEntryList = db.createQuery("from FactionShopEntry where faction= :faction and type=2") |
|---|
| | 1852 | .setInteger("faction", faction) |
|---|
| | 1853 | .list(); |
|---|
| | 1854 | |
|---|
| | 1855 | FactionShopEntry[] ganytransport = new FactionShopEntry[ganyEntryList.size()]; |
|---|
| 1838 | 1856 | int i=0; |
|---|
| 1839 | 1857 | |
|---|
| 1840 | | while( shopentry.next() ) { |
|---|
| 1841 | | ganytransport[i++] = shopentry.getRow(); |
|---|
| 1842 | | } |
|---|
| 1843 | | shopentry.free(); |
|---|
| | 1858 | for( Iterator iter=ganyEntryList.iterator(); iter.hasNext(); ) { |
|---|
| | 1859 | ganytransport[i++] = (FactionShopEntry)iter.next(); |
|---|
| | 1860 | } |
|---|
| 1844 | 1861 | |
|---|
| 1845 | 1862 | // Falls vorhanden jetzt eine Ganymed-Infozeile ausgeben |
|---|
| … | … | |
| 1861 | 1878 | |
|---|
| 1862 | 1879 | // Nun den normalen Shop ausgeben |
|---|
| 1863 | | shopentry = db.query("SELECT * FROM factions_shop_entries WHERE faction_id=",this.faction," AND type!=2"); |
|---|
| 1864 | | while( shopentry.next() ) { |
|---|
| | 1880 | List shopentryList = db.createQuery("from FactionShopEntry where faction = :faction and type!=2") |
|---|
| | 1881 | .setInteger("faction", faction) |
|---|
| | 1882 | .list(); |
|---|
| | 1883 | for( Iterator iter=shopentryList.iterator(); iter.hasNext(); ) { |
|---|
| | 1884 | FactionShopEntry shopentry = (FactionShopEntry)iter.next(); |
|---|
| | 1885 | |
|---|
| 1865 | 1886 | ShopEntry shopEntryObj = null; |
|---|
| 1866 | | if( shopentry.getInt("type") == 1 ) { |
|---|
| 1867 | | shopEntryObj = new ShopShipEntry(shopentry.getRow()); |
|---|
| 1868 | | } |
|---|
| 1869 | | else if( shopentry.getInt("type") == 0 ) { |
|---|
| 1870 | | shopEntryObj = new ShopResourceEntry(shopentry.getRow()); |
|---|
| | 1887 | if( shopentry.getType() == 1 ) { |
|---|
| | 1888 | shopEntryObj = new ShopShipEntry(shopentry); |
|---|
| | 1889 | } |
|---|
| | 1890 | else if( shopentry.getType() == 0 ) { |
|---|
| | 1891 | shopEntryObj = new ShopResourceEntry(shopentry); |
|---|
| 1871 | 1892 | } |
|---|
| 1872 | 1893 | |
|---|
| … | … | |
| 1883 | 1904 | t.parse("shop.list", "shop.listitem", true); |
|---|
| 1884 | 1905 | } |
|---|
| 1885 | | shopentry.free(); |
|---|
| 1886 | 1906 | } |
|---|
| 1887 | 1907 | |
|---|