12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace Collection\Lib;
- use Dever;
- class Buy
- {
- private function getOne($info)
- {
- if (!is_array($info)) {
- $info = Dever::db('collection/buy')->one($info);
- }
- return $info;
- }
- public function getInfo($info)
- {
- $info['name'] = $this->getName($info);
- $info['price'] = $this->getPrice($info);
- return $info;
- }
- public function getName($info)
- {
- $info = $this->getOne($info);
- if ($info && $info['name']) {
- return $info['name'];
- } else {
- $collection = Dever::db('collection/info')->one($info['info_id']);
- return '购买' . $info['num'] . $collection['unit'];
- }
- }
- public function getPrice($info)
- {
- $info = $this->getOne($info);
- $collection = Dever::db('collection/info')->one($info['info_id']);
- if ($info['price'] > 0) {
- return $info['price'];
- } else {
- return $info['num'] * $collection['buy_price'];
- }
- }
- public function getPriceName($info)
- {
- $price = $this->getPrice($info);
- return $price . '元';
- }
- }
|