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
af8c0c3b
Commit
af8c0c3b
authored
Aug 05, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:活动关联自提点
parent
8c11f33f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
0 deletions
+49
-0
MarketingTakePlace.php
application/models/marketing/mysql/MarketingTakePlace.php
+16
-0
MarketingService.php
application/services/marketing/MarketingService.php
+33
-0
No files found.
application/models/marketing/mysql/MarketingTakePlace.php
View file @
af8c0c3b
...
...
@@ -14,4 +14,20 @@ class MarketingTakePlace extends MysqlBase
const
TABLE_NAME
=
'marketing_take_place'
;
const
CONFIG_INDEX
=
'marketing'
;
const
PRIMARY_KEY
=
'marketing_take_place_id'
;
public
static
function
save
(
$data
,
$where
=
[])
{
if
(
empty
(
$where
))
{
return
self
::
insert
(
$data
);
}
return
self
::
update
(
$data
,
$where
);
}
public
static
function
getRecords
(
$where
,
$columns
=
[])
{
if
(
empty
(
$columns
))
{
$columns
=
'*'
;
}
return
self
::
select
(
$columns
,
$where
);
}
}
application/services/marketing/MarketingService.php
View file @
af8c0c3b
...
...
@@ -12,6 +12,7 @@ use Api\PhpServices\Idgen\Idgen;
use
App\Exception\custom\MarketingException
;
use
Api\PhpServices\Sensitive\Sensitive
;
use
App\Models\marketing\mysql\MarketingPindan
;
use
App\Models\marketing\mysql\MarketingTakePlace
;
use
App\Services\common\CommonService
;
use
App\Services\goods\GoodsService
;
use
Daemon\Goods
;
...
...
@@ -485,6 +486,7 @@ class MarketingService
$endTime
=
!
empty
(
$params
[
'end_time'
])
?
$params
[
'end_time'
]
:
''
;
$type
=
Marketing
::
MARKETING_TYPE_PINDAN
;
$goodsSkuId
=
!
empty
(
$params
[
'goods_sku_id'
])
?
explode
(
","
,
$params
[
'goods_sku_id'
])
:
[];
$takePlaceIds
=
!
empty
(
$params
[
'take_place_ids'
])
?
explode
(
","
,
$params
[
'take_place_ids'
])
:
[];
$publicLifeAccountId
=
self
::
getPublicLifeAccountId
();
if
(
empty
(
$marketingName
))
{
...
...
@@ -564,6 +566,16 @@ class MarketingService
}
MarketingGoods
::
save
(
$marketingGoods
);
//自提点
if
(
!
empty
(
$takePlaceIds
))
{
$marketingTakePlaces
=
[];
foreach
(
$takePlaceIds
as
$key
=>
$takePlaceId
)
{
$marketingTakePlaces
[
$key
][
"take_place_id"
]
=
$takePlaceId
;
$marketingTakePlaces
[
$key
][
"marketing_id"
]
=
$marketingId
;
}
MarketingTakePlace
::
save
(
$marketingTakePlaces
);
}
if
(
!
Marketing
::
commit
())
{
Marketing
::
rollback
();
throw
new
MarketingException
([
"cus"
=>
5
]);
...
...
@@ -618,6 +630,7 @@ class MarketingService
$endTime
=
!
empty
(
$params
[
'end_time'
])
?
$params
[
'end_time'
]
:
''
;
$type
=
Marketing
::
MARKETING_TYPE_PINDAN
;
$goodsSkuId
=
!
empty
(
$params
[
'goods_sku_id'
])
?
explode
(
","
,
$params
[
'goods_sku_id'
])
:
[];
$takePlaceIds
=
!
empty
(
$params
[
'take_place_ids'
])
?
explode
(
","
,
$params
[
'take_place_ids'
])
:
[];
if
(
empty
(
$goodsSkuId
))
{
throw
new
MarketingException
([
'cus'
=>
12
]);
}
...
...
@@ -667,6 +680,7 @@ class MarketingService
];
MarketingPindan
::
updateRecord
(
$pindanParams
,
[
"marketing_id"
=>
$marketingId
]);
//活动商品
$marketingGoods
=
MarketingGoods
::
getRecords
([
"marketing_id"
=>
$marketingId
]);
if
(
!
empty
(
$marketingGoods
))
{
$ids
=
array_column
(
$marketingGoods
,
"id"
);
...
...
@@ -683,6 +697,25 @@ class MarketingService
}
MarketingGoods
::
save
(
$marketingGoods
);
//自提点
$marketingTakePlaces
=
MarketingTakePlace
::
getRecords
([
"marketing_id"
=>
$marketingId
]);
if
(
!
empty
(
$marketingTakePlaces
))
{
$ids
=
array_column
(
$marketingTakePlaces
,
"marketing_take_place_id"
);
$delRes
=
MarketingTakePlace
::
delete
([
"marketing_take_place_id"
=>
$ids
]);
if
(
$delRes
==
0
)
{
throw
new
MarketingException
([
'cus'
=>
7
]);
}
}
if
(
!
empty
(
$takePlaceIds
))
{
$marketingTakePlaces
=
[];
foreach
(
$takePlaceIds
as
$key
=>
$takePlaceId
)
{
$marketingTakePlaces
[
$key
][
"take_place_id"
]
=
$takePlaceId
;
$marketingTakePlaces
[
$key
][
"marketing_id"
]
=
$marketingId
;
}
MarketingTakePlace
::
save
(
$marketingTakePlaces
);
}
if
(
!
Marketing
::
commit
())
{
Marketing
::
rollback
();
throw
new
MarketingException
([
"cus"
=>
5
]);
...
...
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