Commit f6d90087 authored by pengfei's avatar pengfei

Merge branch 'colonel' into develop

parents 596cc88d fb0002b0
......@@ -17,7 +17,7 @@ class ColonelDistributorColonel extends MysqlBase
const COLONEL_SOURCE_APPLY = 1; //用户申请
const COLONEL_SOURCE_ADMIN = 2; //运营添加
const DEFAULT_COLUMN = ['colonel_id','user_id','take_place_id','phone','contact_name','colonel_distributor_code','colonel_source'];
const DEFAULT_COLUMN = ['colonel_id','user_id','take_place_id','phone','contact_name','colonel_source'];
public static function getRecord(array $where, $column = '*')
......
......@@ -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]);
}
}
......@@ -248,7 +248,6 @@ class ColonelService
'life_account_id' => $applyInfo['life_account_id'],
'phone' => $applyInfo['phone'],
'contact_name' => $applyInfo['contact_name'],
'colonel_distributor_code' => '', //TODO 生成活动码
'colonel_source' => ColonelDistributorColonel::COLONEL_SOURCE_APPLY
];
return ColonelDistributorColonel::insertRecord($colonelData);
......
......@@ -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