Commit a8921578 authored by luhongguang's avatar luhongguang

update: 临时

parent 460c0b41
......@@ -38,5 +38,7 @@ class MarketingException extends BaseException
self::TAKE_PLACE_NOT_EXIST => '自提点不存在',
21 => "活动开始时间不能大于或者等于结束时间",
22 => "自提点不能为空",
23 => "团长分销配置内容不能为空",
24 => "档位最多设定6档",
];
}
\ No newline at end of file
<?php
namespace App\Models\marketing\mysql;
use Api\PhpUtils\Mysql\MysqlBase;
class PindanActivityColonelConfig extends MysqlBase
{
const TABLE_NAME = 'pindan_activity_colonel_config';
const CONFIG_INDEX = 'marketing';
const PRIMARY_KEY = 'colonel_config_id';
const TYPE_COLONEL = 1;//团长分销活动
public static function getRecord($where, $columns = [], $options = [])
{
if (empty($columns)) {
$columns = '*';
}
return self::get($columns, $where, $options);
}
public static function getRecordMaster($where, $columns = [], $options = [])
{
if (empty($columns)) {
$columns = '*';
}
return self::selectMaster($columns, $where, $options);
}
public static function insertRecord($columns, $options = [])
{
return self::insert($columns, $options);
}
public static function updateRecord($columns, $where)
{
return self::update($columns, $where);
}
public static function save($data, $where = [], $options = [])
{
if (empty($where)) {
return self::insert($data, $options);
}
return self::update($data, $where);
}
public static function deleteRecord($where)
{
return self::delete($where);
}
}
\ No newline at end of file
<?php
namespace App\Services\marketing;
use App\Exception\custom\MarketingException;
use App\Models\marketing\mysql\Marketing;
use App\Models\marketing\mysql\PindanActivityColonelConfig;
class PindanActivityColonelConfigService
{
/**
* 编辑团长分销活动配置
* @param array $params
* @return \Api\PhpUtils\Mysql\MysqlBase
* @throws MarketingException
*/
public static function editColonelConfig($params = [])
{
$date = $params["date"];
$type = empty($params["type"]) ? PindanActivityColonelConfig::TYPE_COLONEL : $params["type"];
$configList = json_decode($params["config"], true);
if (empty($configList)) {
throw new MarketingException(['cus' => 23]);
}
if (count($configList) > 6) {
throw new MarketingException(['cus' => 24]);
}
PindanActivityColonelConfig::beginTransaction();
$idsRes = PindanActivityColonelConfig::select(["colonel_config_id"], ["date" => $date, "type" => $type], []);
if (!empty($idsRes)) {
$ids = array_column($idsRes, "colonel_config_id");
PindanActivityColonelConfig::deleteRecord(["colonel_config_id" => $ids]);
}
$data = [];
foreach ($configList as $key => $item) {
$data[$key]["date"] = $date;
$data[$key]["level"] = $item["level"];
$data[$key]["assess_order_num"] = $item["assess_order_num"];
$data[$key]["reward_amount"] = $item["reward_amount"];
}
PindanActivityColonelConfig::save($data);
if (!PindanActivityColonelConfig::commit()) {
PindanActivityColonelConfig::rollback();
throw new MarketingException(["cus" => 5]);
}
return true;
}
public static function colonelConfig($params = [])
{
}
}
\ 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