SettleLogLogic.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * SettleLogLogic.php UTF-8
  4. * huosdk_mini_program
  5. *
  6. * @date : 2018/8/16 17:07
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : chenbingling <cbl@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huomp\logic\finance;
  13. use huo\model\user\UserModel;
  14. use huolib\constant\CommonConst;
  15. use huolib\constant\SettleConst;
  16. use huomp\model\common\CommonModel;
  17. use huomp\model\finance\SettleLogModel;
  18. class SettleLogLogic extends CommonModel {
  19. /*添加记录*/
  20. public function addPayLog($data) {
  21. return (new SettleLogModel())->addPayLog($data);
  22. }
  23. protected function getWhere($param = []) {
  24. $_map = [];
  25. if (!empty($param['start_time']) && !empty($param['start_time'])) {
  26. $_map['create_time'] = ['between', [strtotime($param['start_time']),
  27. CommonConst::CONST_DAY_SECONDS + strtotime($param['end_time'])]];
  28. } else if (!empty($param['start_time'])) {
  29. $_map['create_time'] = ['gt', strtotime($param['start_time'])];
  30. } else if (!empty($param['end_time'])) {
  31. $_map['create_time'] = ['lt', CommonConst::CONST_DAY_SECONDS + strtotime($param['end_time'])];
  32. }
  33. if (!empty($param['type'])) {
  34. $_map['type'] = $param['type'];
  35. }
  36. if (!empty($param['agent_name'])) {
  37. $_ag_ids = (new UserModel())->getIdsByNickName($param['agent_name']);
  38. $_map['agent_id'] = ['in', $_ag_ids];
  39. }
  40. return $_map;
  41. }
  42. /*获取打款记录*/
  43. public function getMemLogList($param, $page = '1,10', $order = '-create_time') {
  44. $_redata = ['count' => 0, 'list' => []];
  45. $_map = $this->getWhere($param);
  46. $_model = new SettleLogModel();
  47. $_count = $_model->where($_map)->count('id');
  48. if (empty($_count)) {
  49. return $_redata;
  50. }
  51. $_order = $_model->orderFilter($order);
  52. $_file = ['id', 'agent_id', 'order_id', 'amount', 'code', 'type', 'cardholder', 'banknum', 'msg', 'result',
  53. 'query_result',
  54. 'create_time'];
  55. $_list = $_model->with('agent')
  56. ->where($_map)
  57. ->field($_file)
  58. ->order($_order)
  59. ->page($page)
  60. ->select();
  61. if (is_object($_list)) {
  62. $_list = $_list->toArray();
  63. }
  64. if (empty($_list)) {
  65. return $_redata;
  66. }
  67. foreach ($_list as $_k => $_v) {
  68. $_list[$_k]['type'] = SettleConst::getTypesMsg($_v['type']);
  69. $_list[$_k]['agent_nickname'] = !empty($_v['agent']['user_nicename']) ? $_v['agent']['user_nicename'] : '';
  70. unset($_list[$_k]['agent']);
  71. }
  72. $_redata['count'] = $_count;
  73. $_redata['list'] = $_list;
  74. return $_redata;
  75. }
  76. /**
  77. * 获取条件下提现人数提现人数
  78. *
  79. * @param array $map
  80. *
  81. * @return int|string
  82. */
  83. public function getSettleCnt($map = []) {
  84. $_model = new SettleLogModel();
  85. $_cnt = $_model->where($map)->group('agent_id')->count();
  86. return $_cnt;
  87. }
  88. }