ItgLogic.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. /**
  3. * ItgLogic.php UTF-8
  4. * 积分逻辑处理
  5. *
  6. * @date : 2018/5/8 0:34
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\logic\shop;
  13. use huo\model\common\CommonModel;
  14. use huo\model\integral\MemItgLogModel;
  15. use huo\model\shop\GoodsModel;
  16. use huolib\status\ShopStatus;
  17. class ItgLogic extends CommonModel {
  18. protected $base_field
  19. = [
  20. 'id' => 'mitg_id',
  21. 'mitg_name' => 'mitg_name',
  22. 'is_real' => 'is_real',
  23. 'total_cnt' => 'total_cnt',
  24. 'remain_cnt' => 'remain_cnt',
  25. 'mem_times' => 'mem_times',
  26. 'market_price' => 'market_price',
  27. 'mitg_intro' => 'mitg_intro',
  28. 'original_img' => 'original_img',
  29. 'integral' => 'integral',
  30. 'object_type' => 'object_name',
  31. 'object_id' => 'object_id',
  32. ];
  33. /**
  34. * 获取玩家积分列表
  35. *
  36. * @param array $where
  37. * @param string $page
  38. * @param string $order
  39. *
  40. * @return int | array
  41. */
  42. public function getItgList($where = [], $page = '1,10', $order = '-create_time') {
  43. $_mil_model = new MemItgLogModel();
  44. $_count = $_mil_model->where($where)->count();
  45. if (empty($_count)) {
  46. return [
  47. 'count' => $_count,
  48. 'list' => [],
  49. ];
  50. }
  51. $_field = ['ia_name', 'integral', 'create_time'];
  52. $_order = $this->orderFilter($order);
  53. $_mitg_logs = $_mil_model
  54. ->field($_field)
  55. ->where($where)
  56. ->order($_order)
  57. ->page($page)
  58. ->select();
  59. if (is_object($_mitg_logs)) {
  60. $_mitg_logs = $_mitg_logs->toArray();
  61. }
  62. if (empty($_mitg_logs)) {
  63. $_list = null;
  64. $_rdata['count'] = $_count;
  65. $_rdata['list'] = $_list;
  66. }
  67. $_rdata['count'] = $_count;
  68. $_rdata['list'] = $_mitg_logs;
  69. return $_rdata;
  70. }
  71. /**
  72. * 通过商品ID 查询商品信息
  73. *
  74. * @param $mitg_id
  75. *
  76. * @return array|bool|false
  77. */
  78. public function getInfoByGoodsId($mitg_id) {
  79. if (empty($mitg_id)) {
  80. return false;
  81. }
  82. $_map['id'] = $mitg_id;
  83. $_field = $this->base_field;
  84. $_field['mitg_content'] = 'mitg_content';
  85. $_mitg_data = (new GoodsModel())->field($_field)->where($_map)->find();
  86. if (is_object($_mitg_data)) {
  87. $_mitg_data = $_mitg_data->toArray();
  88. }
  89. return $_mitg_data;
  90. }
  91. /**
  92. * 获得所有玩家积分记录
  93. *
  94. * @param array $where
  95. * @param array $field
  96. *
  97. * @param string $listRows
  98. * @param string $order
  99. *
  100. * @return int|\think\Paginator
  101. * @throws \think\exception\DbException
  102. */
  103. public function getAllItgList($where = [], $field=[], $order = 'create_time desc'){
  104. $_mil_model = new MemItgLogModel();
  105. $_mitg_logs = $_mil_model
  106. ->with('mem')
  107. ->field($field)
  108. ->where($where)
  109. ->order($order)
  110. ->paginate();
  111. return $_mitg_logs;
  112. }
  113. }