UserBillStoreOrderServices.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\services\user;
  13. use app\services\BaseServices;
  14. use app\dao\user\UserBillStoreOrderDao;
  15. /**
  16. *
  17. * Class UserBillStoreOrderServices
  18. * @package app\services\user
  19. */
  20. class UserBillStoreOrderServices extends BaseServices
  21. {
  22. /**
  23. * UserBillStoreOrderServices constructor.
  24. * @param UserBillStoreOrderDao $dao
  25. */
  26. public function __construct(UserBillStoreOrderDao $dao)
  27. {
  28. $this->dao = $dao;
  29. }
  30. /**
  31. * TODO 获取用户记录 按月查找
  32. * @param $uid $uid 用户编号
  33. * @param int $page $page 分页起始值
  34. * @param int $limit $limit 查询条数
  35. * @param string $category $category 记录类型
  36. * @param string $type $type 记录分类
  37. * @return mixed
  38. */
  39. public function getRecordList($uid, $uids, $category = 'now_money', $type = 'brokerage')
  40. {
  41. $where = $whereOr1 = $whereOr2 = [];
  42. $where['b.category'] = $category;
  43. $where['o.refund_status'] = 0;
  44. $where['b.take'] = 0;
  45. $field = "FROM_UNIXTIME(b.add_time, '%Y-%m') as time";
  46. $whereOr1 = [
  47. ['b.uid', '=', $uid],
  48. ['b.type', '=', $type]
  49. ];
  50. $whereOr2 = [
  51. ['b.uid', 'IN', $uids],
  52. ['b.type', '=', 'pay_money']
  53. ];
  54. [$page, $limit] = $this->getPageValue();
  55. return $this->dao->getListByGroup($where, [$whereOr1, $whereOr2], $field, 'time', $page, $limit);
  56. }
  57. /**
  58. * 获取订单返佣记录总数
  59. * @param $uid
  60. * @param $uids
  61. * @param string $category
  62. * @param string $type
  63. * @return mixed
  64. */
  65. public function getRecordOrderCount($uid, $uids, $category = 'now_money', $type = 'brokerage')
  66. {
  67. $where = $whereOr1 = $whereOr2 = [];
  68. $where['b.category'] = $category;
  69. $where['o.refund_status'] = 0;
  70. $where['b.take'] = 0;
  71. $whereOr1 = [
  72. ['b.uid', '=', $uid],
  73. ['b.type', '=', $type]
  74. ];
  75. $whereOr2 = [
  76. ['b.uid', 'IN', $uids],
  77. ['b.type', '=', 'pay_money']
  78. ];
  79. return $this->dao->getListCount($where, [$whereOr1, $whereOr2]);
  80. }
  81. /**
  82. * TODO 获取订单返佣记录
  83. * @param $uid
  84. * @param int $addTime
  85. * @param string $category
  86. * @param string $type
  87. * @return mixed
  88. */
  89. public function getRecordOrderListDraw($uid, $uids, $addTime = [], $category = 'now_money', $type = 'brokerage')
  90. {
  91. if(!$addTime) return [];
  92. $where = $whereOr1 = $whereOr2 = [];
  93. $where['b.category'] = $category;
  94. $where['o.refund_status'] = 0;
  95. $where['b.take'] = 0;
  96. $whereOr1 = [
  97. ['b.uid', '=', $uid],
  98. ['b.type', '=', $type]
  99. ];
  100. $whereOr2 = [
  101. ['b.uid', 'IN', $uids],
  102. ['b.type', '=', 'pay_money']
  103. ];
  104. $field = "o.id,o.uid,o.order_id,FROM_UNIXTIME(b.add_time, '%Y-%m-%d %H:%i') as time,b.number,b.type,FROM_UNIXTIME(b.add_time, '%Y-%m') as time_key";
  105. return $this->dao->getList($where, [$whereOr1, $whereOr2],$addTime, $field, 0, 0);
  106. }
  107. }