FenxiaoStat.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. use app\model\system\Stat;
  13. /**
  14. * 会员卡订单统计
  15. */
  16. class FenxiaoStat extends BaseModel
  17. {
  18. /**
  19. * 写入新增分销商统计数据
  20. * @param $params
  21. */
  22. public function addFenxiaoMemberStat($params){
  23. $site_id = $params['site_id'] ?? 0;
  24. $stat_data = array(
  25. 'site_id' => $site_id,
  26. 'add_fenxiao_member_count' => 1
  27. );
  28. $stat_model = new Stat();
  29. $result = $stat_model->addShopStat($stat_data);
  30. return $result;
  31. }
  32. /**
  33. * 分销订单总额统计
  34. */
  35. public function addFenxiaoOrderStat($params){
  36. $order_id = $params['order_id'];
  37. $site_id = $params['site_id'] ?? 0;
  38. $order_condition = array(
  39. ['order_id', '=', $order_id],
  40. ['site_id', '=', $site_id]
  41. );
  42. $order_info = model('order')->getInfo($order_condition);
  43. if(empty($order_info))
  44. return $this->error();
  45. $order_money = $order_info['order_money'];
  46. $refund_money = $order_info['refund_money'];
  47. $stat_data = array(
  48. 'site_id' => $site_id,
  49. 'fenxiao_order_count' => 1,
  50. 'fenxiao_order_total_money' => $order_money - $refund_money,
  51. );
  52. $stat_model = new Stat();
  53. $result = $stat_model->addShopStat($stat_data);
  54. return $result;
  55. }
  56. /**
  57. * 分销佣金账户
  58. * @return multitype:
  59. */
  60. public function getFenxiaoAccountSum($site_id = 0)
  61. {
  62. $field = '
  63. sum(account) as account,
  64. sum(account_withdraw_apply) as account_withdraw_apply,
  65. sum(account_withdraw) as account_withdraw
  66. ';
  67. $info = model("fenxiao")->getInfo([ [ 'site_id', '=', $site_id ] ], $field);
  68. if ($info[ 'account' ] == null) {
  69. $info[ 'account' ] = '0.00';
  70. }
  71. if ($info[ 'account_withdraw_apply' ] == null) {
  72. $info[ 'account_withdraw_apply' ] = '0.00';
  73. }
  74. if ($info[ 'account_withdraw' ] == null) {
  75. $info[ 'account_withdraw' ] = '0.00';
  76. }
  77. return $this->success($info);
  78. }
  79. }