Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
goods
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
goods
Commits
bd8c9675
Commit
bd8c9675
authored
Jun 26, 2021
by
jianghaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:修改活动
parent
602d772f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
141 additions
and
16 deletions
+141
-16
MarketingException.php
application/exception/custom/MarketingException.php
+5
-0
Marketing.php
application/modules/Marketing/controllers/Marketing.php
+17
-1
MarketingService.php
application/services/marketing/MarketingService.php
+119
-15
No files found.
application/exception/custom/MarketingException.php
View file @
bd8c9675
...
...
@@ -21,5 +21,10 @@ class MarketingException extends BaseException
7
=>
'更新失败'
,
8
=>
'开始时间不能为空'
,
9
=>
'结束时间不能为空'
,
10
=>
'活动时间开始不能小于等于当天日期'
,
11
=>
'活动时间结束不能小于等于当天日期'
,
12
=>
'勾选商品不能为空'
,
13
=>
'商品在其他互动已勾选'
,
14
=>
'开始时间不能大于等于结束时间'
,
];
}
\ No newline at end of file
application/modules/Marketing/controllers/Marketing.php
View file @
bd8c9675
...
...
@@ -19,7 +19,7 @@ class MarketingController extends Base
}
/**
*
添加团长
*
创建活动
* 后台管理
*
*/
...
...
@@ -32,6 +32,22 @@ class MarketingController extends Base
}
}
/**
* op后台获取创建活动
* 需要勾选的商品
*
* @param $params
* @return array|mixed
*/
public
function
marketing_goods_listAction
()
{
$params
=
$this
->
params
;
$goodsList
=
MarketingService
::
marketingGooodsList
(
$params
);
if
(
!
empty
(
$goodsList
))
{
$this
->
success
(
$goodsList
);
}
}
/**
...
...
application/services/marketing/MarketingService.php
View file @
bd8c9675
...
...
@@ -5,6 +5,7 @@ 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
;
...
...
@@ -13,8 +14,53 @@ 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
)
>
4
0
)
{
if
(
self
::
utf8Strlen
(
$marketingName
)
>
5
0
)
{
throw
new
MarketingException
([
'cus'
=>
1
]);
}
...
...
@@ -81,6 +146,45 @@ class MarketingService
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
,
'text'
=>
!
empty
(
$marketingName
)
?
$marketingName
:
''
,
...
...
@@ -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"
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment