public function actionView() { $id = wanhunet::$app->request->get("id"); if (($invest = Invest::findOne($id)) !== null) { /** @var Invest $invest */ $orderSum = InvestList::getAlreadyBuy($invest); $invest = $invest->toArray(); $invest['orderSum'] = $orderSum; return $this->view("view", ['invest' => $invest]); } else { return $this->goBack(['info' => '标不存在'], Url::to(['invest/list'])); } }
$moneyShort = \wanhunet\helpers\Utils::moneyShortFormat($money->amount); ?> <b><?php echo $moneyShort[0]; ?> </b> <span style="padding-left:-4px;"><?php echo $moneyShort[1]; ?> </span> </div> <p class="termInves_p">融资规模</p> </li> <?php $orderSum = \modules\invest\models\InvestList::getAlreadyBuy($money); $sum = $orderSum[\modules\invest\models\InvestList::STATUS_PAYED]; ?> <?php if ($sum >= $money->amount) { ?> <li class="licBtn LiGrayOut floatRight mm" id="<?php echo $money->id; ?> ">抢光了</li> <?php } else { ?> <li class="licBtn LiOrange floatRight mm payi" id="<?php echo $money->id;
/** * 通过用户请求生成订单 * @param Order $order * @return InvestList * @throws ErrorException */ public function markOrder(Order $order) { $price = $order->getPrice(); $orderSum = InvestList::getAlreadyBuy($this); if (Config::getInstance()->getProperty('Invest.sumConfig') == 'both') { $sum = $orderSum[InvestList::STATUS_PAYED] + $orderSum[InvestList::STATUS_UNPAYED]; } else { //TODO 可能出现问题由于这个是计算的已付的金额 $sum = $orderSum[InvestList::STATUS_PAYED]; } $rest = $this->amount - $sum; $eachMax = $this->each_max == 0 ? $this->amount : $this->each_max; $eachMin = $rest < $this->each_min ? $rest : $this->each_min; if ($price > $rest || $price > $eachMax) { throw new ErrorException('您购买的金额超出最大购买量', ErrorCode::Buy_each_max); } if ($price < $eachMin) { throw new ErrorException('您购买的金额小于最少购买量', ErrorCode::Buy_each_min); } if (time() > $this->buy_time_end || time() < $this->buy_time_start) { throw new ErrorException('您购买的不在购买时间内', ErrorCode::Buy_out_time); } if ($this->type == self::TYPE_EXPERIENCE_MONEY) { if ($price > wanhunet::app()->member->getExperienceMoneyMax()) { throw new ErrorException('您购买的金额超出您个人最大体验金购买量', ErrorCode::Buy_experience_money_max); } } /*if (InvestList::hasBuy(wanhunet::app()->member->getId(), $this->id)) { throw new ErrorException('您已经买过了', ErrorCode::Buy_has_buy); }*/ //TODO 这个[[wanhunet::app()->member->getId()]] 应该动态配置 $order->setUserId(wanhunet::app()->member->getId()); $order->setProductId($this->id); $saveOrder = $order->saveOrder(); if ($saveOrder) { $this->afterMarkOrder(); } return $order; }