PaywayLogic.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /**
  3. * PaywayLogic.php UTF-8
  4. * 支付方式逻辑
  5. *
  6. * @date : 2020/3/10 10:55
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HUOOA 1.0
  11. */
  12. namespace huo\logic\conf;
  13. use huo\model\common\CommonModel;
  14. use huo\model\conf\PaywayModel;
  15. use huolib\constant\CommonConst;
  16. class PaywayLogic extends CommonModel {
  17. protected $base_field = '';
  18. /**
  19. * 获取查询条件
  20. *
  21. * @param array $param
  22. *
  23. * @return array
  24. */
  25. public function getWhere($param = array()) {
  26. $_map = [];
  27. if (!empty($param['status'])) {
  28. $_map['status'] = $param['status'];
  29. }
  30. if (!empty($param['payname'])) {
  31. $_map['payname'] = $param['payname'];
  32. }
  33. if (!empty($param['code'])) {
  34. $_map['code'] = $param['code'];
  35. }
  36. if (!empty($param['is_config'])) {
  37. $_map['is_config'] = $param['is_config'];
  38. }
  39. return $_map;
  40. }
  41. /***
  42. * 获取列表
  43. *
  44. * @param array $where
  45. * @param string $page
  46. * @param string $order
  47. * @param string $field
  48. *
  49. * @return array
  50. */
  51. public function getList($where = [], $page = '1,10', $order = '-id', $field = '') {
  52. $_rdata = [
  53. 'count' => CommonConst::CONST_ZERO,
  54. 'list' => []
  55. ];
  56. $_model = new PaywayModel();
  57. $_count = $_model->where($where)->count('id');
  58. if (empty($_count)) {
  59. return $_rdata;
  60. }
  61. $_order = $_model->orderFilter($order);
  62. $_list = $_model->where($where)
  63. ->field($field)
  64. ->order($_order)
  65. ->page($page)
  66. ->select();
  67. if (is_object($_list)) {
  68. $_list = $_list->toArray();
  69. }
  70. $_rdata['count'] = $_count;
  71. $_rdata['list'] = $_list;
  72. return $_rdata;
  73. }
  74. /****
  75. * 获取后台列表
  76. *
  77. * @param array $param
  78. * @param string $page
  79. * @param string $order
  80. *
  81. * @return array
  82. */
  83. public function getAdminList($param = [], $page = '1,10', $order = '-id') {
  84. $_map = $this->getWhere($param);
  85. $_field = $this->base_field;
  86. $_rdata = $this->getList($_map, $page, $order, $_field);
  87. return $_rdata;
  88. }
  89. }