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
9b49bed8
Commit
9b49bed8
authored
Jul 31, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:更新拼单活动
parent
cd2be1bc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
104 additions
and
6 deletions
+104
-6
MarketingException.php
application/exception/custom/MarketingException.php
+2
-1
Marketing.php
application/modules/Marketing/controllers/Marketing.php
+1
-1
MarketingService.php
application/services/marketing/MarketingService.php
+101
-4
No files found.
application/exception/custom/MarketingException.php
View file @
9b49bed8
...
...
@@ -33,5 +33,6 @@ class MarketingException extends BaseException
self
::
LIFE_ACCOUNT_NO_EXIST
=>
'生活号不存在'
,
self
::
RELATION_ALREADY_EXIST
=>
'该关联记录已存在'
,
18
=>
'当前填写的拼单活动名称已经存在'
,
19
=>
'当前活动不存在'
,
];
}
\ No newline at end of file
application/modules/Marketing/controllers/Marketing.php
View file @
9b49bed8
...
...
@@ -103,7 +103,7 @@ class MarketingController extends Base
$param
[
'end_time'
]
=
$params
[
'end_time'
];
}
$srt
=
MarketingService
::
updateMarketing
(
$param
,
$where
);
$srt
=
MarketingService
::
updateMarketing
(
$param
,
$where
,
$params
);
if
(
!
empty
(
$srt
))
{
$this
->
success
();
...
...
application/services/marketing/MarketingService.php
View file @
9b49bed8
...
...
@@ -447,11 +447,108 @@ class MarketingService
* 更新数据
*
*/
public
static
function
updateMarketing
(
$params
,
$where
)
public
static
function
updateMarketing
(
$params
,
$where
,
$originParams
)
{
$marketingType
=
!
empty
(
$originParams
[
'marketing_type'
])
?
$originParams
[
'marketing_type'
]
:
Marketing
::
MARKETING_TYPE_FENXIAO
;
if
(
$marketingType
==
Marketing
::
MARKETING_TYPE_FENXIAO
)
{
$where
[
'marketing_id'
]
=
!
empty
(
$where
[
'marketing_id'
])
?
$where
[
'marketing_id'
]
:
''
;
$info
=
Marketing
::
updateRecord
(
$params
,
$where
);
return
$info
;
return
Marketing
::
updateRecord
(
$params
,
$where
);
}
else
if
(
$marketingType
==
Marketing
::
MARKETING_TYPE_TUANGOU
)
{
return
[];
}
else
if
(
$marketingType
==
Marketing
::
MARKETING_TYPE_MIAOSHA
)
{
return
[];
}
else
if
(
$marketingType
==
Marketing
::
MARKETING_TYPE_PINDAN
)
{
return
self
::
updatePindanMarketing
(
$originParams
);
}
}
/**
* 增加拼单活动
* @param $params
* @return \Api\PhpUtils\Mysql\MysqlBase
* @throws MarketingException
*/
private
static
function
updatePindanMarketing
(
$params
)
{
$publishLifeAccountId
=
111
;
$marketingId
=
$params
[
"marketing_id"
];
//重复判断
$marketing
=
Marketing
::
getRecord
([
"marketing_id"
=>
$marketingId
]);
if
(
empty
(
$marketing
))
{
throw
new
MarketingException
([
'cus'
=>
19
]);
}
$marketingPindan
=
MarketingPindan
::
getRecord
([
"marketing_id"
=>
$marketingId
]);
if
(
empty
(
$marketingPindan
))
{
throw
new
MarketingException
([
'cus'
=>
19
]);
}
$marketingName
=
!
empty
(
$params
[
'marketing_name'
])
?
$params
[
'marketing_name'
]
:
''
;
$pindanPic
=
!
empty
(
$params
[
'pindan_pic'
])
?
$params
[
'pindan_pic'
]
:
''
;
$pindanDesc
=
!
empty
(
$params
[
'pindan_desc'
])
?
$params
[
'pindan_desc'
]
:
''
;
$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
=
Marketing
::
MARKETING_TYPE_PINDAN
;
$goodsSkuId
=
!
empty
(
$params
[
'goods_sku_id'
])
?
explode
(
","
,
$params
[
'goods_sku_id'
])
:
[];
if
(
empty
(
$goodsSkuId
))
{
throw
new
MarketingException
([
'cus'
=>
12
]);
}
//获取商品的最大最小值
$skuInfoList
=
PindanGoodsSku
::
getRecordMaster
([
"pindan_goods_sku_id"
=>
$goodsSkuId
]
,
[
"pindan_goods_sku_id"
,
"goods_spu_id"
,
"price"
]);
$priceList
=
[];
foreach
(
$skuInfoList
as
$skuInfo
)
{
$priceList
[]
=
$skuInfo
[
"price"
];
}
$uniquePriceList
=
array_unique
(
$priceList
);
sort
(
$uniquePriceList
);
$minPrice
=
$priceList
[
0
];
$maxPrice
=
end
(
$priceList
);
Marketing
::
beginTransaction
();
$marketingParams
=
[
'marketing_name'
=>
$marketingName
,
'start_time'
=>
$startTime
,
'end_time'
=>
$endTime
,
'online_status'
=>
1
,
'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"
),
];
Marketing
::
updateRecord
(
$marketingParams
,
[
"marketing_id"
=>
$marketingId
]);
$pindanParams
=
[
"pindan_pic"
=>
$pindanPic
,
"pindan_desc"
=>
$pindanDesc
,
"min_price"
=>
$minPrice
,
"max_price"
=>
$maxPrice
,
];
MarketingPindan
::
updateRecord
(
$pindanParams
,
[
"marketing_id"
=>
$marketingId
]);
$marketingGoods
=
MarketingGoods
::
getRecords
([
"marketing_id"
=>
$marketingId
]);
if
(
!
empty
(
$marketingGoods
))
{
$ids
=
array_column
(
$marketingGoods
,
"id"
);
$delRes
=
MarketingGoods
::
delete
([
"id"
=>
$ids
]);
if
(
$delRes
==
0
)
{
throw
new
MarketingException
([
'cus'
=>
7
]);
}
}
$marketingGoods
=
[];
foreach
(
$skuInfoList
as
$key
=>
$skuInfo
)
{
$marketingGoods
[
$key
][
"goods_spu_id"
]
=
$skuInfo
[
"goods_spu_id"
];
$marketingGoods
[
$key
][
"goods_sku_id"
]
=
$skuInfo
[
"pindan_goods_sku_id"
];
$marketingGoods
[
$key
][
"marketing_id"
]
=
$marketingId
;
}
MarketingGoods
::
save
(
$marketingGoods
);
if
(
!
Marketing
::
commit
())
{
Marketing
::
rollback
();
throw
new
MarketingException
([
"cus"
=>
5
]);
}
return
true
;
}
...
...
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