Commit 6350e1a5 authored by luhongguang's avatar luhongguang

update: 分销活动配置相关接口

parent a971875f
<?php
namespace Validate;
class ColonelConfigValidate extends BaseValidate
{
protected $rule = [
'date' => 'require',
'config' => 'require',
];
protected $message = [
'phone' => 'date 参数不能为空',
'config' => 'config 参数不能为空'
];
public function sceneDate()
{
return $this->only(["date"])->append("date", "require");
}
}
\ No newline at end of file
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
use App\Base\Base; use App\Base\Base;
use App\Services\marketing\ColonelService; use App\Services\marketing\ColonelService;
use \Validate\ColonelApplyValidate; use \Validate\ColonelApplyValidate;
use \Validate\ColonelConfigValidate;
use \App\Services\marketing\PindanActivityColonelConfigService;
class ColonelController extends Base class ColonelController extends Base
{ {
...@@ -27,4 +29,30 @@ class ColonelController extends Base ...@@ -27,4 +29,30 @@ class ColonelController extends Base
return $this->success(['result' => ['applyId' => $applyId]]); return $this->success(['result' => ['applyId' => $applyId]]);
} }
/**
* 编辑团长分销配置
* @throws \App\Exception\custom\MarketingException
* @throws \App\Exception\custom\ParamException
*/
public function add_configAction()
{
(new ColonelConfigValidate())->validate();
$params = $this->params;
PindanActivityColonelConfigService::editColonelConfig($params);
return $this->success();
}
/**
* 查看团长分销配置
* @throws \App\Exception\custom\ParamException
*/
public function colonel_configAction()
{
(new ColonelConfigValidate())->scene("date")->validate();
$params = $this->params;
$data = PindanActivityColonelConfigService::colonelConfig($params);
return $this->success(["result"=>$data]);
}
} }
\ No newline at end of file
...@@ -12,7 +12,7 @@ class PindanActivityColonelConfigService ...@@ -12,7 +12,7 @@ class PindanActivityColonelConfigService
/** /**
* 编辑团长分销活动配置 * 编辑团长分销活动配置
* @param array $params * @param array $params
* @return \Api\PhpUtils\Mysql\MysqlBase * @return bool
* @throws MarketingException * @throws MarketingException
*/ */
public static function editColonelConfig($params = []) public static function editColonelConfig($params = [])
...@@ -53,9 +53,30 @@ class PindanActivityColonelConfigService ...@@ -53,9 +53,30 @@ class PindanActivityColonelConfigService
return true; return true;
} }
/**
* 团长分销活动配置
* @param array $params
* @return array
*/
public static function colonelConfig($params = []) public static function colonelConfig($params = [])
{ {
$day = empty($params["date"]) ? date("Y-m-d") : $params["date"];
$type = empty($params["type"]) ? PindanActivityColonelConfig::TYPE_COLONEL : $params["type"];
$list = PindanActivityColonelConfig::select("*", ["date" => $day, "type" => $type], []);
$data = [];
if (!empty($list)) {
foreach ($list as $key => $item) {
$data[$key]["colonel_config_id"] = $item["colonel_config_id"];
$data[$key]["date"] = $item["date"];
$data[$key]["level"] = $item["level"];
$data[$key]["assess_order_num"] = $item["assess_order_num"];
$data[$key]["reward_amount"] = $item["reward_amount"];
}
$sortKeys = array_column($data, "level");
array_multisort($sortKeys, SORT_ASC, $data);
}
return $data;
} }
} }
\ 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