Contacts.php 1014B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Description: 联系人
  4. // +----------------------------------------------------------------------
  5. // | Author: Michael_xu | gengxiaoxu@5kcrm.com
  6. // +----------------------------------------------------------------------
  7. namespace app\bi\model;
  8. use think\Db;
  9. use app\admin\model\Common;
  10. use think\Request;
  11. class Contacts extends Common
  12. {
  13. /**
  14. * 为了数据库的整洁,同时又不影响Model和Controller的名称
  15. * 我们约定每个模块的数据表都加上相同的前缀,比如CRM模块用crm作为数据表前缀
  16. */
  17. protected $name = 'crm_contacts';
  18. /**
  19. * 根据新增联系人数排序
  20. * @param $whereArr
  21. * @return
  22. */
  23. function getSortByCount($whereArr)
  24. {
  25. $count = db('crm_contacts')->group('owner_user_id')->field('owner_user_id,count(contacts_id) as count')->order('count desc')->where($whereArr)->select();
  26. return $count;
  27. }
  28. }