Commit 85cb8fff authored by pengfei's avatar pengfei

Merge branch 'colonel' of https://git.yidian-inc.com:8021/bp/goods into colonel

parents 4b6d4765 40e8d864
......@@ -10,12 +10,18 @@ class ColonelConfigValidate extends BaseValidate
];
protected $message = [
'phone' => 'date 参数不能为空',
'config' => 'config 参数不能为空'
'date' => 'date 参数不能为空',
'config' => 'config 参数不能为空',
'marketing_id' => 'marketing_id 参数不能为空',
];
public function sceneDate()
{
return $this->only(["date"])->append("date", "require");
}
public function sceneAdd()
{
return $this->only(["date","config","marketing_id"])->append("marketing_id", "require");
}
}
\ No newline at end of file
......@@ -55,7 +55,7 @@ class ColonelController extends Base
*/
public function add_configAction()
{
(new ColonelConfigValidate())->validate();
(new ColonelConfigValidate())->scene('add')->validate();
$params = $this->params;
PindanActivityColonelConfigService::editColonelConfig($params);
......
......@@ -21,6 +21,7 @@ class PindanActivityColonelConfigService
$date = $params["date"];
$type = empty($params["type"]) ? ColonelDistributorConfig::TYPE_COLONEL : $params["type"];
$configList = $params["config"];
$marketingId = $params["marketing_id"];
if (empty($configList)) {
throw new MarketingException(['cus' => MarketingException::COLONEL_CONFIG_NULL]);
......@@ -29,28 +30,25 @@ class PindanActivityColonelConfigService
if (count($configList) > 6) {
throw new MarketingException(['cus' => MarketingException::COLONEL_LEVEL_SIX]);
}
ColonelDistributorConfig::beginTransaction();
$idRes = ColonelDistributorConfig::getRecord(["date" => $date, "type" => $type], ["colonel_config_id"]);
$idRes = ColonelDistributorConfig::getRecord(["date" => $date, "type" => $type, "marketing_id" => $marketingId], ["colonel_config_id"]);
if (!empty($idRes)) {
ColonelDistributorConfig::save([
"marketing_id" => $marketingId,
"date" => $date,
"type" => $type,
"data" => $configList,
], $idRes["colonel_config_id"]);
], ["colonel_config_id" => $idRes["colonel_config_id"]]);
} else {
ColonelDistributorConfig::save([
"marketing_id" => $marketingId,
"date" => $date,
"type" => $type,
"data" => $configList,
]);
}
if (!ColonelDistributorConfig::commit()) {
ColonelDistributorConfig::rollback();
throw new MarketingException(["cus" => 5]);
}
return true;
}
......
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