Commit ae54a12e authored by luhongguang's avatar luhongguang

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

parents 4ea17d0c 78615580
......@@ -21,5 +21,10 @@ class MarketingException extends BaseException
7 => '更新失败',
8 => '开始时间不能为空',
9 => '结束时间不能为空',
10 => '活动时间开始不能小于等于当天日期',
11 => '活动时间结束不能小于等于当天日期',
12 => '勾选商品不能为空',
13 => '商品在其他互动已勾选',
14 => '开始时间不能大于等于结束时间',
];
}
\ No newline at end of file
......@@ -19,7 +19,7 @@ class MarketingController extends Base
}
/**
* 添加团长
* 创建活动
* 后台管理
*
*/
......@@ -31,6 +31,22 @@ class MarketingController extends Base
$this->success();
}
}
/**
* op后台获取创建活动
* 需要勾选的商品
*
* @param $params
* @return array|mixed
*/
public function marketing_goods_listAction()
{
$params = $this->params;
$goodsList = MarketingService::marketingGooodsList($params);
if (!empty($goodsList)) {
$this->success($goodsList);
}
}
......
......@@ -5,16 +5,62 @@ namespace App\Services\marketing;
use App\Models\marketing\mysql\Marketing;
use App\Models\marketing\mysql\MarketingGoods;
use App\Models\goods\mysql\GoodsSku;
use Api\PhpUtils\Validate\Validate;
use Api\PhpServices\Idgen\Idgen;
use App\Exception\custom\MarketingException;
use Api\PhpServices\Sensitive\Sensitive;
class MarketingService
{
{
/**
* 查询
* op 后台获取活动需要参加的商品
*
* @param $params
* @return array|mixed
*/
public static function marketingGooodsList($params='')
{
$startTime = !empty($params['start_time']) ? $params['start_time'] : '';
$endTime = !empty($params['end_time']) ? $params['end_time'] : '';
$goodsData = [
"OR" => [
"start_time[>=]" => $startTime,
"end_time[>=]" => $startTime,
],
];
$tmpMarketingList = Marketing::getMarketingList($goodsData);
if (!empty($tmpMarketingList)) {
$tmpMarketingId = array_column($tmpMarketingList, 'marketing_id');
}
$marketingGoodsList = MarketingGoods::marketingGoodsList(['marketing_id' => $tmpMarketingId]);
if (!empty($marketingGoodsList)) {
$tmpGoodsSkuId = array_column($marketingGoodsList, 'goods_sku_id');
}
$where = [
'online_status' => 1,
];
// $goodsSkuList = GoodsSku::select('*', $where);
//$goodsSkuList =GoodsSku::getRecordMaster($where);
$goodsSkuList =GoodsSku::getRecord($where);
print_r($goodsSkuList);
}
/**
* op 后台列表查询
*
* @param $params
* @return array|mixed
*/
public static function marketingList($params)
{
......@@ -34,6 +80,16 @@ class MarketingService
$where['online_status'] = $params['online_status'];
}
if (!empty($params['goods_sku_id'])) {
$goodsSkuId = $params['goods_sku_id'];
$marketingGoodsList = MarketingGoods::marketingGoodsList(['goods_sku_id' => $goodsSkuId]);
$marketingId = array_column($marketingGoodsList, 'marketing_id');
if (!empty($where['marketing_id'])) {
array_push($marketingId,$where['marketing_id']);
}
$where['marketing_id'] = $marketingId;
}
$where['ORDER'] = ["create_time" => "DESC"];
$where['LIMIT'] = [$page, $limit];
$list = Marketing::getRecords($where);
......@@ -44,7 +100,12 @@ class MarketingService
return $data;
}
/**
* 创建互动
*
* @param $params
* @return array|mixed
*/
public static function addMarketing($params){
$marketingName = !empty($params['marketing_name']) ? $params['marketing_name'] : '';
......@@ -53,23 +114,27 @@ class MarketingService
$createUserEmail = !empty($params['op_cur_user']) ? $params['op_cur_user'] : '';
$startTime = !empty($params['start_time']) ? $params['start_time'] : '';
$endTime = !empty($params['end_time']) ? $params['end_time'] : '';
$type = !empty($params['type']) ? $params['type'] : 1;
$type = !empty($params['marketing_type']) ? $params['marketing_type'] : 1;
$goodsSkuId = !empty($params['goods_sku_id']) ? explode(",", $params['goods_sku_id']) : [];
if (empty($goodsSkuId)) {
throw new MarketingException(['cus'=>12]);
}
if (empty($marketingName)) {
throw new MarketingException(['cus'=>0]);
}
// if (empty($firstCommissionRate)) {
// throw new MarketingException(['cus'=>3]);
// }
if (empty($firstCommissionRate)) {
throw new MarketingException(['cus'=>3]);
}
// if (empty($secondCommissionRate)) {
// throw new MarketingException(['cus'=>4]);
// }
if (empty($secondCommissionRate)) {
throw new MarketingException(['cus'=>4]);
}
if (self::utf8Strlen($marketingName) > 40) {
if (self::utf8Strlen($marketingName) > 50) {
throw new MarketingException(['cus'=>1]);
}
......@@ -78,8 +143,47 @@ class MarketingService
}
if (empty($endTime)) {
throw new MarketingException(['cus'=>9]);
throw new MarketingException(['cus'=>9]);
}
if ($startTime <= date("Y-m-d")) {
throw new MarketingException(['cus'=>10]);
}
if ($endTime <= date("Y-m-d")) {
throw new MarketingException(['cus'=>11]);
}
if ($startTime >= $endTime) {
throw new MarketingException(['cus'=>14]);
}
$tmpMarketingId = [];
$tmpGoodsSkuId = [];
$goodsData = [
"OR" => [
"start_time[>=]" => $startTime,
"end_time[>=]" => $startTime,
],
];
$tmpMarketingList = Marketing::getMarketingList($goodsData);
if (!empty($tmpMarketingList)) {
$tmpMarketingId = array_column($tmpMarketingList, 'marketing_id');
}
$marketingGoodsList = MarketingGoods::marketingGoodsList(['marketing_id' => $tmpMarketingId]);
if (!empty($marketingGoodsList)) {
$tmpGoodsSkuId = array_column($marketingGoodsList, 'goods_sku_id');
}
if (!empty($tmpGoodsSkuId)) {
if (array_intersect($goodsSkuId, $tmpGoodsSkuId)) {
throw new MarketingException(['cus'=>13]);
}
}
$detectParams = [
'businessId' => 1,
......@@ -109,7 +213,7 @@ class MarketingService
'start_time' => $startTime,
'end_time' => $endTime,
'online_status' => 1,
'type' => $type,
'marketing_type' => $type,
'update_user_email' => $createUserEmail,
'update_time' => date("Y-m-d H:i:s"),
'create_time' => date("Y-m-d H:i:s"),
......@@ -124,8 +228,8 @@ class MarketingService
foreach ($goodsSkuId as $key => $value) {
$colums[$key]['marketing_id'] = $marketingId;
$colums[$key]['goods_spu_id'] = $value;
$colums[$key]['goods_sku_id'] = '';
$colums[$key]['goods_spu_id'] = '';
$colums[$key]['goods_sku_id'] = $value;
$colums[$key]['update_time'] = date("Y-m-d H:i:s");
$colums[$key]['create_time'] = date("Y-m-d H:i:s");
}
......
......@@ -129,7 +129,7 @@ abstract class MysqlBase
if (in_array($method, self::$writeFuncitonList)) {
// 写操作
$type = static::WRITE;
self::$dbConnect[$type] = self::getConnection($type);
self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
if (strpos($method, 'Master') !== false) {
$method = substr_replace($method, '', -6);
}
......@@ -137,7 +137,7 @@ abstract class MysqlBase
} elseif (in_array($method, self::$readFunctionList)) {
// 读操作
$type = static::READ;
self::$dbConnect[$type] = self::getConnection($type);
self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
array_unshift($arguments, static::TABLE_NAME);
} elseif (strpos($method, 'query') !== false) {
// Medoo原生SQL操作
......@@ -146,17 +146,17 @@ abstract class MysqlBase
$type = static::WRITE;
}
$method = 'query';
self::$dbConnect[$type] = self::getConnection($type);
self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
} else {
throw new \Exception("use undefined Medoo function:" . $method . "-" . json_encode($arguments));
}
self::$dbCurrentConnect = self::$dbConnect[$type];
self::$sqlResut = call_user_func_array([self::$dbConnect[$type], $method], $arguments);
self::$dbCurrentConnect = self::$dbConnect[static::CONFIG_INDEX.':'.$type];
self::$sqlResut = call_user_func_array([self::$dbConnect[static::CONFIG_INDEX.':'.$type], $method], $arguments);
if (!self::catchError($method, $arguments)) {
// 如果失败重试一次
self::$dbCurrentConnect = self::$dbConnect[$type] = self::getConnection($type);
self::$sqlResut = call_user_func_array([self::$dbConnect[$type], $method], $arguments);
self::$dbCurrentConnect = self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
self::$sqlResut = call_user_func_array([self::$dbConnect[static::CONFIG_INDEX.':'.$type], $method], $arguments);
if (!self::catchError($method, $arguments)) {
return false;
}
......@@ -173,11 +173,11 @@ abstract class MysqlBase
*/
public static function getConnection($type, $flush = false)
{
if (!isset(self::$dbConnect[$type]) || $flush) {
self::$dbConnect[$type] = new Medoo(self::getDbConf($type));
if (!isset(self::$dbConnect[static::CONFIG_INDEX.':'.$type]) || $flush) {
self::$dbConnect[static::CONFIG_INDEX.':'.$type] = new Medoo(self::getDbConf($type));
}
return self::$dbConnect[$type];
return self::$dbConnect[static::CONFIG_INDEX.':'.$type];
}
/**
......@@ -402,13 +402,13 @@ abstract class MysqlBase
public static function debug()
{
$type = static::WRITE;
self::$dbConnect[$type] = self::getConnection($type);
self::$dbConnect[$type]->debug();
self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
self::$dbConnect[static::CONFIG_INDEX.':'.$type]->debug();
$type = static::READ;
self::$dbConnect[$type] = self::getConnection($type);
self::$dbConnect[$type]->debug();
self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
self::$dbConnect[static::CONFIG_INDEX.':'.$type]->debug();
return [static::WRITE => self::$dbConnect[static::WRITE], static::READ => self::$dbConnect[static::READ]];
return [static::CONFIG_INDEX.':'.static::WRITE => self::$dbConnect[static::CONFIG_INDEX.':'.static::WRITE], static::CONFIG_INDEX.':'.static::READ => self::$dbConnect[static::CONFIG_INDEX.':'.static::READ]];
}
/**
......@@ -420,11 +420,11 @@ abstract class MysqlBase
{
$ret = [];
$type = static::WRITE;
self::$dbConnect[$type] = self::getConnection($type);
$ret[$type] = self::$dbConnect[$type]->log();
self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
$ret[$type] = self::$dbConnect[static::CONFIG_INDEX.':'.$type]->log();
$type = static::READ;
self::$dbConnect[$type] = self::getConnection($type);
$ret[$type] = self::$dbConnect[$type]->log();
self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
$ret[$type] = self::$dbConnect[static::CONFIG_INDEX.':'.$type]->log();
return $ret;
}
......@@ -447,9 +447,9 @@ abstract class MysqlBase
public static function beginTransaction()
{
$type = static::WRITE;
self::$dbConnect[$type] = self::getConnection($type);
if(!self::$dbConnect[$type]->pdo->inTransaction()) {
return self::$dbConnect[$type]->pdo->beginTransaction();
self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
if(!self::$dbConnect[static::CONFIG_INDEX.':'.$type]->pdo->inTransaction()) {
return self::$dbConnect[static::CONFIG_INDEX.':'.$type]->pdo->beginTransaction();
}
return false;
}
......@@ -462,9 +462,9 @@ abstract class MysqlBase
public static function commit()
{
$type = static::WRITE;
self::$dbConnect[$type] = self::getConnection($type);
if(self::$dbConnect[$type]->pdo->inTransaction()) {
return self::$dbConnect[$type]->pdo->commit();
self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
if(self::$dbConnect[static::CONFIG_INDEX.':'.$type]->pdo->inTransaction()) {
return self::$dbConnect[static::CONFIG_INDEX.':'.$type]->pdo->commit();
}
return false;
}
......@@ -477,9 +477,9 @@ abstract class MysqlBase
public static function rollback()
{
$type = static::WRITE;
self::$dbConnect[$type] = self::getConnection($type);
if(self::$dbConnect[$type]->pdo->inTransaction()) {
return self::$dbConnect[$type]->pdo->rollback();
self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
if(self::$dbConnect[static::CONFIG_INDEX.':'.$type]->pdo->inTransaction()) {
return self::$dbConnect[static::CONFIG_INDEX.':'.$type]->pdo->rollback();
}
return false;
}
......@@ -492,7 +492,7 @@ abstract class MysqlBase
public static function action(callable $actions)
{
$type = static::WRITE;
self::$dbConnect[$type] = self::getConnection($type);
return self::$dbConnect[$type]->action($actions);
self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
return self::$dbConnect[static::CONFIG_INDEX.':'.$type]->action($actions);
}
}
......@@ -198,7 +198,7 @@ abstract class MysqlClusterBase
}
}
$end_time = microtime(true);
MonUtil::dbMon(self::dbCurrentConnect['server'].'_'.self::dbCurrentConnect['port'] ?? 'unknow_mysql',$method,'mysql',$end_time-$start_time);
MonUtil::dbMon(self::$dbCurrentConnect['server'].'_'.self::$dbCurrentConnect['port'] ?? 'unknow_mysql', $method, 'mysql', $end_time-$start_time);
return self::formatResult($method, $arguments);
}
......
......@@ -32,7 +32,7 @@ private static $installed = array (
'aliases' =>
array (
),
'reference' => '7111c7a581d9d2216005db71482bf7ecdb031a49',
'reference' => '48662ee0ac551270f90d09cda3f0a1ab5d45c556',
'name' => 'yidian/yaf_demo',
),
'versions' =>
......@@ -45,7 +45,7 @@ private static $installed = array (
array (
0 => '9999999-dev',
),
'reference' => '8db8da38dc52e83358dfcb59aa7dcc259b4a80f6',
'reference' => '3a118172e1f4bb413ccbef92c037f4f3255b388a',
),
'api/php_utils' =>
array (
......@@ -55,7 +55,7 @@ private static $installed = array (
array (
0 => '9999999-dev',
),
'reference' => '68a14dcde67b6d838b4933550a9356e5c78060b3',
'reference' => '16949fb782de0488cf192e3cd9d4e1268377294d',
),
'bacon/bacon-qr-code' =>
array (
......@@ -335,7 +335,7 @@ private static $installed = array (
'aliases' =>
array (
),
'reference' => '7111c7a581d9d2216005db71482bf7ecdb031a49',
'reference' => '48662ee0ac551270f90d09cda3f0a1ab5d45c556',
),
),
);
......
......@@ -97,6 +97,7 @@ return array(
'App\\Models\\goods\\mysql\\GoodsSnapshot' => $baseDir . '/application/models/goods/mysql/GoodsSnapshot.php',
'App\\Models\\goods\\mysql\\GoodsSpu' => $baseDir . '/application/models/goods/mysql/GoodsSpu.php',
'App\\Models\\goods\\mysql\\InventoryOperationRecord' => $baseDir . '/application/models/goods/mysql/InventoryOperationRecord.php',
'App\\Models\\goods\\mysql\\PaySuccessGoodsCallbackRecord' => $baseDir . '/application/models/goods/mysql/PaySuccessGoodsCallbackRecord.php',
'App\\Models\\goods\\mysql\\Shop' => $baseDir . '/application/models/goods/mysql/Shop.php',
'App\\Models\\goods\\mysql\\Tcc' => $baseDir . '/application/models/goods/mysql/Tcc.php',
'App\\Models\\marketing\\mysql\\Distributor' => $baseDir . '/application/models/marketing/mysql/Distributor.php',
......
......@@ -326,6 +326,7 @@ class ComposerStaticInit48fd9e88279ffd9162a19bdedd5d5a0a
'App\\Models\\goods\\mysql\\GoodsSnapshot' => __DIR__ . '/../..' . '/application/models/goods/mysql/GoodsSnapshot.php',
'App\\Models\\goods\\mysql\\GoodsSpu' => __DIR__ . '/../..' . '/application/models/goods/mysql/GoodsSpu.php',
'App\\Models\\goods\\mysql\\InventoryOperationRecord' => __DIR__ . '/../..' . '/application/models/goods/mysql/InventoryOperationRecord.php',
'App\\Models\\goods\\mysql\\PaySuccessGoodsCallbackRecord' => __DIR__ . '/../..' . '/application/models/goods/mysql/PaySuccessGoodsCallbackRecord.php',
'App\\Models\\goods\\mysql\\Shop' => __DIR__ . '/../..' . '/application/models/goods/mysql/Shop.php',
'App\\Models\\goods\\mysql\\Tcc' => __DIR__ . '/../..' . '/application/models/goods/mysql/Tcc.php',
'App\\Models\\marketing\\mysql\\Distributor' => __DIR__ . '/../..' . '/application/models/marketing/mysql/Distributor.php',
......
......@@ -7,7 +7,7 @@
"source": {
"type": "git",
"url": "https://git.yidian-inc.com:8021/bp/php_services.git",
"reference": "8db8da38dc52e83358dfcb59aa7dcc259b4a80f6"
"reference": "3a118172e1f4bb413ccbef92c037f4f3255b388a"
},
"require": {
"api/php_utils": "dev-master",
......@@ -15,7 +15,7 @@
"perftools/php-profiler": "^0.18.0",
"php": "7.2.*"
},
"time": "2021-06-25T11:08:53+00:00",
"time": "2021-06-25T11:16:31+00:00",
"default-branch": true,
"type": "library",
"installation-source": "source",
......@@ -34,7 +34,7 @@
"source": {
"type": "git",
"url": "https://git.yidian-inc.com:8021/bp/php_utils.git",
"reference": "68a14dcde67b6d838b4933550a9356e5c78060b3"
"reference": "16949fb782de0488cf192e3cd9d4e1268377294d"
},
"require": {
"elasticsearch/elasticsearch": "~7.0",
......@@ -46,7 +46,7 @@
"mongodb/mongodb": "1.4.3",
"php": "7.2.*"
},
"time": "2021-06-25T07:16:28+00:00",
"time": "2021-06-26T06:31:48+00:00",
"default-branch": true,
"type": "library",
"installation-source": "source",
......
......@@ -6,7 +6,7 @@
'aliases' =>
array (
),
'reference' => '7111c7a581d9d2216005db71482bf7ecdb031a49',
'reference' => '48662ee0ac551270f90d09cda3f0a1ab5d45c556',
'name' => 'yidian/yaf_demo',
),
'versions' =>
......@@ -19,7 +19,7 @@
array (
0 => '9999999-dev',
),
'reference' => '8db8da38dc52e83358dfcb59aa7dcc259b4a80f6',
'reference' => '3a118172e1f4bb413ccbef92c037f4f3255b388a',
),
'api/php_utils' =>
array (
......@@ -29,7 +29,7 @@
array (
0 => '9999999-dev',
),
'reference' => '68a14dcde67b6d838b4933550a9356e5c78060b3',
'reference' => '16949fb782de0488cf192e3cd9d4e1268377294d',
),
'bacon/bacon-qr-code' =>
array (
......@@ -309,7 +309,7 @@
'aliases' =>
array (
),
'reference' => '7111c7a581d9d2216005db71482bf7ecdb031a49',
'reference' => '48662ee0ac551270f90d09cda3f0a1ab5d45c556',
),
),
);
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