Commit 2ea3809a authored by luhongguang's avatar luhongguang

update:临时提交

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