GamePriceLogic.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * GamePriceLogic.php UTF-8
  4. * WWW
  5. *
  6. * @date : 2018/8/22 22:37
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : chenbingling <cbl@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\logic\game;
  13. use huo\model\common\CommonModel;
  14. use huo\model\game\GamePriceModel;
  15. use think\db\exception\DataNotFoundException;
  16. use think\db\exception\ModelNotFoundException;
  17. use think\exception\DbException;
  18. class GamePriceLogic extends CommonModel {
  19. /**
  20. * 获取计费点列表
  21. *
  22. * @param array $where
  23. * @param string $page
  24. * @param string $order
  25. *
  26. * @return array
  27. */
  28. public function getList($where = [], $page = '1,10', $order = '-update_time') {
  29. $_map = [];
  30. $_rdata = ['count' => 0, 'list' => []];
  31. if (!empty($where['app_id'])) {
  32. $_map['app_id'] = $where['app_id'];
  33. }
  34. if (!empty($where['product_code'])) {
  35. $_map['product_code'] = $where['product_code'];
  36. }
  37. $_gp_model = New GamePriceModel();
  38. $_count = $_gp_model->where($_map)->count('id');
  39. if (empty($_count)) {
  40. return $_rdata;
  41. }
  42. $_order = $this->orderFilter($order);
  43. try {
  44. $_list = $_gp_model->where($_map)->page($page)->order($_order)->select();
  45. if (is_object($_list)) {
  46. $_list = $_list->toArray();
  47. }
  48. $_rdata['count'] = $_count;
  49. $_rdata['list'] = $_list;
  50. return $_rdata;
  51. } catch (DataNotFoundException $e) {
  52. return $_rdata;
  53. } catch (ModelNotFoundException $e) {
  54. return $_rdata;
  55. } catch (DbException $e) {
  56. return $_rdata;
  57. }
  58. }
  59. /**
  60. * 查找记录
  61. *
  62. * @param array $map
  63. *
  64. * @return mixed
  65. */
  66. public function getId($map = []) {
  67. return (new GamePriceModel())->where($map)->value('id');
  68. }
  69. }