Commit efdd23e0 authored by pengfei's avatar pengfei

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

parents fb7d313b a971875f
......@@ -15,6 +15,8 @@ class MarketingException extends BaseException
const TAKE_PLACE_NOT_EXIST = 20;
const COLONEL_APPLY_EXIST = 23;
const COLONEL_APPLY_FAILED = 24;
const COLONEL_CONFIG_NULL = 25;
const COLONEL_LEVEL_SIX = 26;
protected $cus = [
0 => '活动名称不能为空',
......@@ -41,6 +43,8 @@ class MarketingException extends BaseException
21 => "活动开始时间不能大于或者等于结束时间",
22 => "自提点不能为空",
self::COLONEL_APPLY_EXIST => '当前用户已提交团长申请',
self::COLONEL_APPLY_FAILED => '团长申请失败'
self::COLONEL_APPLY_FAILED => '团长申请失败',
self::COLONEL_CONFIG_NULL => "团长分销配置内容不能为空",
self::COLONEL_LEVEL_SIX => "档位最多设定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' => MarketingException::COLONEL_CONFIG_NULL]);
}
if (count($configList) > 6) {
throw new MarketingException(['cus' => MarketingException::COLONEL_LEVEL_SIX]);
}
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