Commit 9ee274d4 authored by luhongguang's avatar luhongguang

update: 团长分销账单详情

parent 0e6c420d
......@@ -10,6 +10,14 @@ class ColonelDistributorPayInfo extends MysqlBase
const CONFIG_INDEX = 'marketing';
const PRIMARY_KEY = 'colonel_distributor_pay_info_id';
const TYPE_NEW_USER = 1;
const TYPE_FINISH_TARGET = 2;
public static $typeDesc = [
self::TYPE_NEW_USER => "邀请新用户",
self::TYPE_FINISH_TARGET => "完成目标单数",
];
public static function getRecord($where, $columns = [], $options = [])
{
if (empty($columns)) {
......
......@@ -203,4 +203,15 @@ class ColonelController extends Base
return $this->success(["result" => []]);
}
/**
* 团长分销,账单详情
* @throws Exception
*/
public function bill_infoAction()
{
$params = $this->params;
$data = PindanActivityInviteOrderService::getPayInfoList($params);
return $this->success(["result" => $data]);
}
}
......@@ -164,4 +164,51 @@ class PindanActivityInviteOrderService
}
return $data;
}
/**
* 团长分销,账单详情
* @param array $params
* @return array
*/
public static function getPayInfoList($params = [])
{
$weekDay = date("Y-m-d", strtotime("-7 day"));
$userId = $params["user_id"];
if (empty($userId)) {
return [];
}
$payList = ColonelDistributorPayInfo::select("*", [
"colonel_user_id" => $userId,
"date[>=]" => $weekDay,
"ORDER" => ["date" => "DESC"]
], []);
$data = $res = [];
if (!empty($payList)) {
foreach ($payList as $item) {
$tempItem = [];
$tempItem["type"] = $item["type"];
$tempItem["type_desc"] = ColonelDistributorPayInfo::$typeDesc[$item["type"]];
$tempItem["invite_user_id"] = $item["invite_user_id"];
$tempItem["invite_user_nick"] = $item["invite_user_nick"];
$tempItem["reward"] = $item["reward"];
$tempItem["finish_num"] = $item["finish_num"];
$tempItem["status"] = $item["status"];
$data[$item["date"]][] = $tempItem;
}
foreach ($data as $key => $item) {
$rewards = array_column($item, "reward");
$total = array_sum($rewards);
$res[$key]["total"] = $total / 100;
$res[$key]["date"] = $key;
$res[$key]["data"] = $item;
foreach ($item as $k => $v) {
$res[$key]["data"][$k]["reward"] = $v["reward"] / 100;
}
}
}
return array_values($res);
}
}
\ No newline at end of file
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