stock.class.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /***
  3. * Class Stock
  4. * * @author 王刚涛
  5. * 日线数据
  6. */
  7. class Stock {
  8. public function __construct()
  9. {
  10. }
  11. static public function getInfoById($id)
  12. {
  13. $Table_stock = new Table_stock();
  14. return $Table_stock->getInfoById($id);
  15. }
  16. static public function update($stock_id,$attrs)
  17. {
  18. if (empty($attrs)) throw new Exception('参数不能为空', 102);
  19. $Table_stock = new Table_stock();
  20. $id = $Table_stock->update($stock_id,$attrs);
  21. return $id;
  22. }
  23. /***
  24. * @param $stock_code
  25. * @param $attrs
  26. * @return mixed
  27. * @throws Exception
  28. * 更新部分静态数据
  29. */
  30. static public function updateByCode($stock_code,$attrs)
  31. {
  32. if (empty($attrs)) throw new Exception('参数不能为空', 102);
  33. $Table_stock = new Table_stock();
  34. $id = $Table_stock->updateByCode($stock_code,$attrs);
  35. return $id;
  36. }
  37. static public function add($attrs)
  38. {
  39. if (empty($attrs)) throw new Exception('参数不能为空', 101);
  40. $Table_stock = new Table_stock();
  41. $id = $Table_stock->add($attrs);
  42. return $id;
  43. }
  44. static public function getList($filter = array(), $count=0, $page=0, $pageSize=0)
  45. {
  46. $Table_stock = new Table_stock();
  47. return $Table_stock->getList($filter, $count, $page, $pageSize);
  48. }
  49. /****
  50. * @param array $filter
  51. * @param int $count
  52. * @param int $page
  53. * @param int $pageSize
  54. * @return array|int
  55. * 获取股票的代码列表
  56. */
  57. static public function getStockCodeList()
  58. {
  59. $Table_stock = new Table_stock();
  60. return $Table_stock->getStockCodeList();
  61. }
  62. static public function updateCodeAndName($attrs)
  63. {
  64. if (empty($attrs)) throw new Exception('参数不能为空', 101);
  65. $Table_stock = new Table_stock();
  66. $rs = $Table_stock->getInfoByCode($attrs['code']);
  67. if (empty($rs)) {
  68. $id = $Table_stock->addCodeAndName($attrs);
  69. } else {
  70. $id = $rs['id'];
  71. $Table_stock->update($id, $attrs);
  72. }
  73. return $id;
  74. }
  75. }
  76. ?>