jh-admin/addon/saas/model/ManageStat.php

89 lines
2.5 KiB
PHP

<?php
/**
* SaaSMall商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 成都SAAS云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.gobuysaas.com
* =========================================================
*/
namespace addon\saas\model;
use app\model\BaseModel;
use app\model\system\Stat;
/**
* 会员卡订单统计
*/
class ManageStat extends BaseModel
{
/**
* 写入新增分销商统计数据
* @param $params
*/
public function addManageMemberStat($params)
{
$site_id = $params['site_id'] ?? 0;
$stat_data = array(
'site_id' => $site_id,
'add_Manage_member_count' => 1
);
$stat_model = new Stat();
$result = $stat_model->addShopStat($stat_data);
return $result;
}
/**
* 分销订单总额统计
*/
public function addManageOrderStat($params)
{
$order_id = $params['order_id'];
$site_id = $params['site_id'] ?? 0;
$order_condition = array(
['order_id', '=', $order_id],
['site_id', '=', $site_id]
);
$order_info = model('order')->getInfo($order_condition);
if (empty($order_info))
return $this->error();
$order_money = $order_info['order_money'];
$refund_money = $order_info['refund_money'];
$stat_data = array(
'site_id' => $site_id,
'Manage_order_count' => 1,
'Manage_order_total_money' => $order_money - $refund_money,
);
$stat_model = new Stat();
$result = $stat_model->addShopStat($stat_data);
return $result;
}
/**
* 分销佣金账户
* @return multitype:
*/
public function getManageAccountSum($site_id = 0)
{
$field = ' sum(account) as account,sum(account_withdraw_apply) as account_withdraw_apply,sum(account_withdraw) as account_withdraw';
$info = model("manage_user")->getInfo([['site_id', '=', $site_id]], $field);
if ($info['account'] == null) {
$info['account'] = '0.00';
}
if ($info['account_withdraw_apply'] == null) {
$info['account_withdraw_apply'] = '0.00';
}
if ($info['account_withdraw'] == null) {
$info['account_withdraw'] = '0.00';
}
return $this->success($info);
}
}