Commit 5da7d7c6 authored by wanjilong's avatar wanjilong

add: 增加团长分销统计

parent 038229f0
...@@ -7,4 +7,51 @@ class PayOrderClearingItem extends MysqlBase ...@@ -7,4 +7,51 @@ class PayOrderClearingItem extends MysqlBase
{ {
const TABLE_NAME = 'pay_order_clearing_item'; const TABLE_NAME = 'pay_order_clearing_item';
const CONFIG_INDEX = 'pay'; const CONFIG_INDEX = 'pay';
public static function marketSaleCount($accountId, $type = 1) {
if($accountId == 0) {
return 0;
}
$amount = 0;
$sql = "select sum(poci.`pay_amount`) as 'pay_amount' from pay_order_clearing_item poci join pay_order_item poi on poi.`order_item_id` = poci.`order_item_id` where poci.pay_sub_type = 105 and poci.account_id = ?";
if($type == 1) {
$sql .= " and poi.`notify_account_status`=2";
} else {
$sql .= " and poi.`notify_account_status`= 0 and poi.refund_order_status = 0";
}
/*
type=1: 该团长历史累计分销佣金收入总和
type=2: 该团长当前未结算分销佣金总和
*/
try{
$medoo = self::getConnection(self::READ);
$medoo->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$sth = $medoo->pdo->prepare($sql);
$sth->execute([$accountId]);
$row = $sth->fetch(\PDO::FETCH_ASSOC);
if(empty($row['pay_amount'])) {
$amount = 0;
} else {
$amount = $row['pay_amount'];
}
return $amount;
}catch (\PDOException $e) {
throw new BaseException(['msg'=>'数据查询错误:' . $e->getMessage(), 'code'=>'2401']);
}
}
} }
<?php
use App\Base\Base;
use App\Models\order\mysql\PayOrderClearingItem;
class AccountController extends Base
{
/**
* @throws \App\Exception\BaseException
* @throws \App\Exception\custom\PayException
*/
public function fundAction()
{
$params = $this->params;
$user_id = $params['user_id'];
$type = $params['type'] ?? 1;
$payment = PayOrderClearingItem::marketSaleCount($user_id, $type);
$this->success(['result'=>[
'user_id'=>$user_id,
'type'=>$type,
'amount'=>$payment
]]);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment