⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 auctionorderdb.java~6~

📁 源码/软件简介: 云网论坛1.1RC国际版是采用JSP开发的集论坛、CMS(网站内容管理系统)、博客、聊天室、商城、交友、语音灌水等于一体的门户式社区。拥有CWBBS ( Cloud Web BBS
💻 JAVA~6~
📖 第 1 页 / 共 2 页
字号:
                if (str != null) {
                    deliverTime = DateUtil.parse(rs.getString(14));
                }
                commodityName = rs.getString(15);
                loaded = true;
            }
        } catch (SQLException e) {
            logger.error("load:" + e.getMessage());
        }
        finally {
            if (conn!=null) {
                conn.close();
                conn = null;
            }
        }
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public void setId(int id) {
        this.id = id;
    }

    public void setAuctionId(int auctionId) {
        this.auctionId = auctionId;
    }

    public void setAuctionSellType(int auctionSellType) {
        this.auctionSellType = auctionSellType;
    }

    public void setSeller(String seller) {
        this.seller = seller;
    }

    public void setBuyer(String buyer) {
        this.buyer = buyer;
    }

    public void setMoneyCode(String moneyCode) {
        this.moneyCode = moneyCode;
    }

    public void setTotalPrice(double totalPrice) {
        this.totalPrice = totalPrice;
    }

    public void setAmount(int amount) {
        this.amount = amount;
    }

    public void setSellerScore(int sellerScore) {
        this.sellerScore = sellerScore;
    }

    public void setBuyerScore(int buyerScore) {
        this.buyerScore = buyerScore;
    }

    public void setState(int state) {
        this.state = state;
    }

    public void setOrderDate(java.util.Date orderDate) {
        this.orderDate = orderDate;
    }

    public void setPayTime(java.util.Date payTime) {
        this.payTime = payTime;
    }

    public void setDeliverTime(java.util.Date deliverTime) {
        this.deliverTime = deliverTime;
    }

    public void setCommodityName(String commodityName) {
        this.commodityName = commodityName;
    }

    public double getPrice() {
        return price;
    }

    public int getId() {
        return id;
    }

    public long getAuctionId() {
        return auctionId;
    }

    public int getAuctionSellType() {
        return auctionSellType;
    }

    public String getSeller() {
        return seller;
    }

    public String getBuyer() {
        return buyer;
    }

    public String getMoneyCode() {
        return moneyCode;
    }

    public double getTotalPrice() {
        return totalPrice;
    }

    public int getAmount() {
        return amount;
    }

    public int getSellerScore() {
        return sellerScore;
    }

    public int getBuyerScore() {
        return buyerScore;
    }

    public int getState() {
        return state;
    }

    public java.util.Date getOrderDate() {
        return orderDate;
    }

    public java.util.Date getPayTime() {
        return payTime;
    }

    public java.util.Date getDeliverTime() {
        return deliverTime;
    }

    public String getCommodityName() {
        return commodityName;
    }

    public AuctionOrderDb getAuctionOrderDb(int id) {
        return (AuctionOrderDb)getObjectDb(new Integer(id));
    }

    /**
     * 查看对应于商品的所有订单
     * @param auctionId int
     * @return Vector
     */
    public Vector list(int auctionId) {
        Vector v = new Vector();
        Conn conn = new Conn(connname);
        ResultSet rs = null;
        String sql = "select id from " + tableName + " where auctionId=? order by price desc";
        try {
            PreparedStatement ps = conn.prepareStatement(sql);
            ps.setInt(1, auctionId);
            rs = conn.executePreQuery();
            if (rs!=null) {
                while (rs.next()) {
                    int id = rs.getInt(1);
                    v.addElement(getAuctionOrderDb(id));
                }
            }
        }
        catch (SQLException e) {
            logger.error("list: " + e.getMessage());
        }
        finally {
            if (conn!=null) {
                conn.close();
                conn = null;
            }
        }
        return v;
    }

    public boolean makeOrderForAuction(AuctionDb ad) throws ErrMsgException, ResKeyException {
        auctionId = ad.getMsgRootId();
        if (ad.getCurBidPrice()==0)
            return false;

        auctionSellType = ad.getSellType();
        seller = ad.getUserName();
        AuctionBidDb ab = new AuctionBidDb();
        ab = ab.getLastBid(auctionId);

        buyer = ab.getName();
        price = ab.getPrice();
        AuctionWorthDb aw = new AuctionWorthDb();
        long[] aids = aw.getWorthOfAuction(auctionId);
        aw = aw.getAuctionWorthDb((int)aids[0]);
        moneyCode = aw.getMoneyCode();
        totalPrice = price*ad.getCount();
        amount = ad.getCount();
        state = 0;

        ScoreMgr sm = new ScoreMgr();
        ScoreUnit su = sm.getScoreUnit(moneyCode);
        // 如果是虚拟币,则直接将其支付
        if (!su.isReal()) {
            if (su.getScore().pay(buyer, seller, totalPrice)) {
                state = STATE_PAY;
                payTime = new java.util.Date();
                payTime.setTime(System.currentTimeMillis());
            }
        }
        commodityName = ad.getName();
        boolean re = create();
        // logger.info("makeOrderForAuction re=" + re);
        if (re) {
            // 更改商品的状态为已售完
            ad.setState(ad.STATE_SELLOUT);
            ad.save();
            logger.info("state=" + ad.getState());
        }
        return re;
    }

    // 为一口价出售方式生成订单
    public boolean makeOrderForSell(AuctionWorthDb aw, String buyer, int count) throws ErrMsgException, ResKeyException {
        AuctionDb ad = new AuctionDb();
        ad = ad.getAuctionDb(aw.getMsgRootId());

        auctionId = ad.getMsgRootId();
        commodityName = ad.getName();
        auctionSellType = ad.getSellType();
        seller = ad.getUserName();
        this.buyer = buyer;
        price = aw.getPrice();
        moneyCode = aw.getMoneyCode();
        totalPrice = price*count;
        amount = count;
        state = 0;

        ScoreMgr sm = new ScoreMgr();
        ScoreUnit su = sm.getScoreUnit(moneyCode);
        // 如果是虚拟币,则直接将其支付
        if (!su.isReal()) {
            if (su.getScore().pay(buyer, seller, totalPrice)) {
                state = STATE_PAY;
                payTime = new java.util.Date();
                payTime.setTime(System.currentTimeMillis());
            }
        }
        boolean re = create();
        if (re) {
            // 将商品数量减去购买的数量,如果数量为0则置为已售完
            ad.setCount(ad.getCount() - count);
            if (ad.getCount()<=0)
                ad.setState(ad.STATE_SELLOUT);
            ad.save();
        }
        return re;
    }

    private double price;
    private int id;
    private long auctionId;
    private int auctionSellType;
    private String seller;
    private String buyer;
    private String moneyCode;
    private double totalPrice;
    private int amount;
    private int sellerScore = SCORE_NONE;
    private int state;
    private java.util.Date orderDate;
    private java.util.Date payTime;
    private java.util.Date deliverTime;
    private String commodityName;

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -