ChannelLogic.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * ChannelLogic.php UTF-8
  4. * CPS平台逻辑
  5. *
  6. * @date : 2018/7/27 14:11
  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\ChannelModel;
  15. class ChannelLogic extends CommonModel {
  16. /**
  17. * 获取CPS平台列表
  18. *
  19. * @param array $map
  20. * @param string $order
  21. * @param int $offset
  22. *
  23. * @return \think\Paginator
  24. * @throws \think\exception\DbException
  25. */
  26. public function getChannelList($map = [], $order = 'id desc', $offset = 10) {
  27. $field = 'id, channel_name, company_name, link_man, mobile, position, create_time, update_time';
  28. $_items = (new ChannelModel())->field($field)->where($map)->order($order)->paginate($offset);
  29. return $_items;
  30. }
  31. /**
  32. * 获取CP名称列表
  33. *
  34. * @return array
  35. */
  36. public static function getNamesById() {
  37. $_arr = (new ChannelModel())->where('is_delete', 2)->order('id desc')->column('channel_name name', 'id');
  38. return $_arr;
  39. }
  40. /***
  41. * 添加cp
  42. *
  43. * @param $param
  44. *
  45. * @param bool $return_id
  46. *
  47. * @return false|int
  48. */
  49. public function addChannel($param, $return_id = false) {
  50. $_model = (new ChannelModel());
  51. $_rs = $_model->allowField(true)->save($param);
  52. if (true == $return_id) {
  53. return $_model->id;
  54. }
  55. return $_rs;
  56. }
  57. /**
  58. * @param $id
  59. *
  60. * @return array|false|\PDOStatement|string|\think\Model
  61. * @throws \think\db\exception\DataNotFoundException
  62. * @throws \think\db\exception\ModelNotFoundException
  63. * @throws \think\exception\DbException
  64. */
  65. public function getChannelById($id) {
  66. $_rs = (new ChannelModel())->where('id', $id)->find();
  67. return $_rs;
  68. }
  69. public function updateChannel($id, $param) {
  70. $_rs = (new ChannelModel())->allowField(true)->save($param, ['id' => $id]);
  71. return $_rs;
  72. }
  73. }