Commit bbb50b3a authored by wanjilong's avatar wanjilong

add: 增加达人中心资金统计接口

parent 5da7d7c6
...@@ -9,20 +9,20 @@ class PayOrderClearingItem extends MysqlBase ...@@ -9,20 +9,20 @@ class PayOrderClearingItem extends MysqlBase
const CONFIG_INDEX = 'pay'; const CONFIG_INDEX = 'pay';
public static function marketSaleCount($accountId, $type = 1) { public static function marketSaleCount($accountId) {
$ret = [
'transit_fund'=>0,
'history_fund'=>0,
];
if($accountId == 0) { if($accountId == 0) {
return 0; return $ret;
} }
$amount = 0; $sql = "select sum(poci.`pay_amount`) as 'pay_amount', notify_account_status from pay_order_clearing_item poci
join pay_order_item poi on poi.`order_item_id` = poci.`order_item_id`
$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 = ?"; where poci.pay_sub_type = 105 and poci.account_id = ? and poi.refund_order_status = 0 group by notify_account_status ";
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=1: 该团长历史累计分销佣金收入总和
...@@ -34,23 +34,21 @@ class PayOrderClearingItem extends MysqlBase ...@@ -34,23 +34,21 @@ class PayOrderClearingItem extends MysqlBase
$sth = $medoo->pdo->prepare($sql); $sth = $medoo->pdo->prepare($sql);
$sth->execute([$accountId]); $sth->execute([$accountId]);
$row = $sth->fetch(\PDO::FETCH_ASSOC); while ($row = $sth->fetch(\PDO::FETCH_ASSOC)) {
if(empty($row['pay_amount'])) { if($row['notify_account_status'] == 2) {
$amount = 0; $ret['history_fund'] += $row['pay_amount'];
} else { } else {
$amount = $row['pay_amount']; $ret['transit_fund'] += $row['pay_amount'];
}
} }
return $amount; return $ret;
}catch (\PDOException $e) { }catch (\PDOException $e) {
throw new BaseException(['msg'=>'数据查询错误:' . $e->getMessage(), 'code'=>'2401']); throw new BaseException(['msg'=>'数据查询错误:' . $e->getMessage(), 'code'=>'2401']);
} }
} }
......
...@@ -15,13 +15,8 @@ class AccountController extends Base ...@@ -15,13 +15,8 @@ class AccountController extends Base
{ {
$params = $this->params; $params = $this->params;
$user_id = $params['user_id']; $user_id = $params['user_id'];
$type = $params['type'] ?? 1;
$payment = PayOrderClearingItem::marketSaleCount($user_id, $type); $payment = PayOrderClearingItem::marketSaleCount($user_id);
$this->success(['result'=>[ $this->success(['result'=>$payment]);
'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