FenxiaoData.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\fenxiao\model;
  11. use app\model\BaseModel;
  12. /**
  13. * 分销数据
  14. */
  15. class FenxiaoData extends BaseModel
  16. {
  17. /**
  18. * 分销商账户统计
  19. * @return array|mixed
  20. */
  21. public function getFenxiaoAccountData($site_id)
  22. {
  23. $field = 'sum(account) as account,sum(account_withdraw) as account_withdraw,sum(account_withdraw_apply) as account_withdraw_apply';
  24. $res = model('fenxiao')->getInfo([ [ 'status', 'in', '1,-1' ], [ 'site_id', '=', $site_id ], [ 'is_delete', '=', 0 ] ], $field);
  25. if (empty($res) || $res[ 'account' ] == null) {
  26. $res[ 'account' ] = '0.00';
  27. }
  28. if (empty($res) || $res[ 'account_withdraw' ] == null) {
  29. $res[ 'account_withdraw' ] = '0.00';
  30. }
  31. if (empty($res) || $res[ 'account_withdraw_apply' ] == null) {
  32. $res[ 'account_withdraw_apply' ] = '0.00';
  33. }
  34. return $res;
  35. }
  36. /**
  37. * 获取分销商申请人数
  38. * @return mixed
  39. */
  40. public function getFenxiaoApplyCount($site_id)
  41. {
  42. $count = model('fenxiao_apply')->getCount([ [ 'status', '=', 1 ], [ 'site_id', '=', $site_id ] ]);
  43. return $count;
  44. }
  45. /**
  46. * 获取分销商人数
  47. * @return mixed
  48. */
  49. public function getFenxiaoCount($site_id)
  50. {
  51. $count = model('fenxiao')->getCount([ [ 'site_id', '=', $site_id ], [ 'is_delete', '=', 0 ] ]);
  52. return $count;
  53. }
  54. /**
  55. * 统计分销订单总金额
  56. * @return mixed
  57. */
  58. public function getFenxiaoOrderSum($site_id)
  59. {
  60. $field = 'sum(real_goods_money) as real_goods_money';
  61. $res = model('fenxiao_order')->getInfo([ [ 'site_id', '=', $site_id ] ], $field);
  62. if ($res[ 'real_goods_money' ] == null) {
  63. $res[ 'real_goods_money' ] = '0.00';
  64. }
  65. return $res;
  66. }
  67. }