Info.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Collection\Lib;
  3. use Dever;
  4. class Info
  5. {
  6. # 获取内容
  7. public function get($id)
  8. {
  9. $info = Dever::db('collection/info')->one($id);
  10. return $info;
  11. }
  12. public function one($data)
  13. {
  14. if (is_numeric($data)) {
  15. $data = $this->get($data);
  16. if (!$data) {
  17. return array();
  18. }
  19. }
  20. if ($data['buy'] == 1) {
  21. $data['num_buy'] = $data['num_buy'];
  22. } else {
  23. $data['num_buy'] = Dever::load('user/lib/collection')->getNum($data['id']);
  24. }
  25. if (!$data['num_buy']) {
  26. $data['num_buy'] = 0;
  27. }
  28. if (isset($data['num_add_buy']) && isset($data['num_ratio_buy'])) {
  29. $data['num_buy_total'] = round(($data['num_buy']+$data['num_add_buy'])*$data['num_ratio_buy']);
  30. }
  31. if (isset($data['num_view']) && isset($data['num_add_view'])) {
  32. $data['num_view_total'] = round(($data['num_view']+$data['num_add_view']));
  33. }
  34. return $data;
  35. }
  36. }