Commit 2ea3809a authored by luhongguang's avatar luhongguang

update:临时提交

parent 3fb1e7bf
......@@ -13,6 +13,7 @@ class Marketing extends MysqlBase
const MARKETING_TYPE_FENXIAO = 1;
const MARKETING_TYPE_TUANGOU = 2;
const MARKETING_TYPE_MIAOSHA = 3;
const MARKETING_TYPE_JIELONG = 4;
public static function getRecord($where, $colums = [])
{
......
......@@ -14,7 +14,7 @@ use App\Services\common\CommonService;
class MarketingService
{
{
/**
* op 后台获取活动需要参加的商品
*
......@@ -173,13 +173,35 @@ class MarketingService
}
/**
* 创建互动
*
* 创建活动
* @param $params
* @return array|mixed
* @return \Api\PhpUtils\Mysql\MysqlBase|array
* @throws MarketingException
* @throws \App\Exception\custom\CodeSpecialException
*/
public static function addMarketing($params){
public static function addMarketing($params)
{
$marketingType = !empty($params['marketing_type']) ? $params['marketing_type'] : Marketing::MARKETING_TYPE_FENXIAO;
if ($marketingType == Marketing::MARKETING_TYPE_FENXIAO) {
return self::addFenxiaoMarketing($params);
} else if ($marketingType == Marketing::MARKETING_TYPE_TUANGOU) {
return [];
} else if ($marketingType == Marketing::MARKETING_TYPE_MIAOSHA) {
return [];
} else if ($marketingType == Marketing::MARKETING_TYPE_JIELONG) {
return self::addJielongMarketing($params);
}
}
/**
* 增加分销活动
* @param $params
* @return \Api\PhpUtils\Mysql\MysqlBase
* @throws MarketingException
* @throws \App\Exception\custom\CodeSpecialException
*/
private static function addFenxiaoMarketing($params)
{
$marketingName = !empty($params['marketing_name']) ? $params['marketing_name'] : '';
$firstCommissionRate = !empty($params['first_commission_value']) ? $params['first_commission_value']*100 : 0;
$secondCommissionRate = !empty($params['second_commission_value']) ? $params['second_commission_value']*100 : 0;
......@@ -192,10 +214,10 @@ class MarketingService
$rate = $firstCommissionRate + $secondCommissionRate;
if ($rate > 5000) {
throw new MarketingException(['cus'=>15]);
}
}
if (empty($goodsSkuId)) {
throw new MarketingException(['cus'=>12]);
throw new MarketingException(['cus'=>12]);
}
if (empty($marketingName)) {
......@@ -209,13 +231,13 @@ class MarketingService
if (empty($secondCommissionRate)) {
throw new MarketingException(['cus'=>4]);
}
if (self::utf8Strlen($marketingName) > 50) {
throw new MarketingException(['cus'=>1]);
}
if (empty($startTime)) {
throw new MarketingException(['cus'=>8]);
throw new MarketingException(['cus'=>8]);
}
if (empty($endTime)) {
......@@ -262,7 +284,7 @@ class MarketingService
throw new MarketingException(['cus'=>13]);
}
}
$detectParams = [
'businessId' => 1,
......@@ -273,7 +295,7 @@ class MarketingService
if (!empty($sensitive['data'])) {
throw new MarketingException(['cus'=>2]);
}
// //判断重复
// if (!self::isName($name)) {
// throw new ShopException(['cus'=>6]);
......@@ -299,7 +321,7 @@ class MarketingService
];
$marketingId = Marketing::insertRecord($colums);
if (empty($marketingId)) {
Marketing::rollback();
Marketing::rollback();
throw new MarketingException(['cus' => 5]);
}
$colums = [];
......@@ -315,7 +337,7 @@ class MarketingService
$info = MarketingGoods::insertRecord($colums);
if (empty($info)) {
Marketing::rollback();
Marketing::rollback();
throw new MarketingException(['cus' => 5]);
}
......@@ -324,11 +346,16 @@ class MarketingService
Marketing::commit();
return $srt;
}else{
Marketing::rollback();
Marketing::rollback();
throw new MarketingException(['cus' => 5]);
}
}
private static function addJielongMarketing($params)
{
return [];
}
/**
* 更新数据
*
......
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