Contract.php 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. use think\Validate;
  12. class Contract extends Common
  13. {
  14. /**
  15. * 为了数据库的整洁,同时又不影响Model和Controller的名称
  16. * 我们约定每个模块的数据表都加上相同的前缀,比如CRM模块用crm作为数据表前缀
  17. */
  18. protected $name = 'crm_contract';
  19. /**
  20. * [getDataList 合同金额]
  21. * @author Michael_xu
  22. * @return
  23. */
  24. function getWhereByMoney($whereArr)
  25. {
  26. return db('crm_contract')->where($whereArr)->sum('money');
  27. }
  28. /**
  29. * [getSortByMoney 根据合同金额排序]
  30. * @author zhi
  31. * @param
  32. * @return
  33. */
  34. function getSortByMoney($whereArr)
  35. {
  36. return $this->group('owner_user_id')->field('owner_user_id,sum(money) as money')->order('money desc')->where($whereArr)->select();
  37. }
  38. /**
  39. * [getDataList 根据合同签约数排序]
  40. * @author zhi
  41. * @param
  42. * @return
  43. */
  44. function getSortByCount($whereArr)
  45. {
  46. $money = db('crm_contract')->group('owner_user_id')->field('owner_user_id,count(contract_id) as count')->order('count desc')->where($whereArr)->select();
  47. return $money;
  48. }
  49. /**
  50. * 获取合同数量
  51. * @author zhi
  52. * @param
  53. * @return
  54. */
  55. function getDataCount($whereArr){
  56. $count = db('crm_contract')->where($whereArr)->count('contract_id');
  57. return $count;
  58. }
  59. /**
  60. * 获取合同金额
  61. * @author zhi
  62. * @param
  63. * @return
  64. */
  65. function getDataMoney($whereArr){
  66. $money = db('crm_contract')->where($whereArr)->sum('money');
  67. return $money;
  68. }
  69. }