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
7a8efce7
Commit
7a8efce7
authored
Aug 31, 2021
by
suntengda
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'tuancan' into colonel
parents
9dcdc04b
08ec9025
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
7 deletions
+89
-7
MarketingPindan.php
application/models/marketing/mysql/MarketingPindan.php
+1
-0
TakePlace.php
application/models/marketing/mysql/TakePlace.php
+4
-0
MarketingService.php
application/services/marketing/MarketingService.php
+84
-7
No files found.
application/models/marketing/mysql/MarketingPindan.php
View file @
7a8efce7
...
...
@@ -13,6 +13,7 @@ class MarketingPindan extends MysqlBase
const
ACTIVITY_STATUS_NO_START
=
1
;
const
ACTIVITY_STATUS_IN_PROGRESS
=
2
;
const
ACTIVITY_STATUS_FINISHED
=
3
;
const
ACTIVITY_STATUS_START_TODAY
=
4
;
//今日上新
public
static
function
getRecord
(
$where
,
$colums
=
[])
{
...
...
application/models/marketing/mysql/TakePlace.php
View file @
7a8efce7
...
...
@@ -29,7 +29,11 @@ class TakePlace extends MysqlBase
$keywords
=
$params
[
'keywords'
]
??
''
;
$offset
=
$params
[
'offset'
]
??
0
;
$limit
=
$params
[
'limit'
]
??
20
;
$takePlaceIds
=
$params
[
'take_place_id'
]
??
[];
if
(
!
empty
(
$takePlaceIds
))
{
$where
[
'take_place_id'
]
=
$takePlaceIds
;
}
if
(
$lifeAccountId
)
{
$where
[
'life_account_id'
]
=
$lifeAccountId
;
}
...
...
application/services/marketing/MarketingService.php
View file @
7a8efce7
...
...
@@ -273,6 +273,17 @@ class MarketingService
$params
[
'page'
]
=
!
empty
(
$params
[
'page'
])
?
$params
[
'page'
]
:
1
;
$limit
=
!
empty
(
$params
[
'page_size'
])
?
$params
[
'page_size'
]
:
20
;
$page
=
(
$params
[
'page'
]
-
1
)
*
$limit
;
//排序规则
$sortField
=
$params
[
'sort_field'
]
??
'update_time'
;
$sortType
=
isset
(
$params
[
'sort_type'
])
?
strtoupper
(
$params
[
'sort_type'
])
:
'desc'
;
//验证sort合法性
if
(
!
in_array
(
$params
[
'sort_field'
],[
'create_time'
,
'update_time'
,
'end_time'
,
'start_time'
]))
{
$sortField
=
'update_time'
;
}
if
(
!
in_array
(
$params
[
'sort_type'
],[
'asc'
,
'desc'
]))
{
$sortType
=
'DESC'
;
}
$where
[
"marketing_type"
]
=
Marketing
::
MARKETING_TYPE_PINDAN
;
if
(
!
empty
(
$params
[
'marketing_name'
]))
{
...
...
@@ -288,18 +299,27 @@ class MarketingService
}
elseif
(
$params
[
"activity_status"
]
==
MarketingPindan
::
ACTIVITY_STATUS_IN_PROGRESS
)
{
$where
[
"start_time[<=]"
]
=
$now
;
$where
[
"end_time[>=]"
]
=
$now
;
//七日内开始的活动
if
(
!
empty
(
$params
[
'from'
])
&&
$params
[
'from'
]
==
1
)
{
$beforeSevenDay
=
date
(
"Y-m-d H:i:s"
,
strtotime
(
"-7 day"
));
$where
[
"start_time[>]"
]
=
$beforeSevenDay
;
}
}
elseif
(
$params
[
"activity_status"
]
==
MarketingPindan
::
ACTIVITY_STATUS_FINISHED
)
{
$where
[
"end_time[<]"
]
=
$now
;
}
if
(
!
empty
(
$params
[
'from'
]))
{
$beforeSevenDay
=
date
(
"Y-m-d H:i:s"
,
strtotime
(
"-7 day"
));
$where
[
"start_time[>]"
]
=
$beforeSevenDay
;
//七日内结束的活动
if
(
!
empty
(
$params
[
'from'
])
&&
$params
[
'from'
]
==
1
)
{
$beforeSevenDay
=
date
(
"Y-m-d H:i:s"
,
strtotime
(
"-7 day"
));
$where
[
"end_time[>]"
]
=
$beforeSevenDay
;
}
}
elseif
(
$params
[
"activity_status"
]
==
MarketingPindan
::
ACTIVITY_STATUS_START_TODAY
)
{
//今日上新-未开始
$where
[
"start_time[>]"
]
=
$now
;
$where
[
"start_time[<=]"
]
=
date
(
"Y-m-d 00:00:00"
,
strtotime
(
'+1 days'
));
$where
[
"end_time[>=]"
]
=
$now
;
}
$where
[
'life_account_id'
]
=
self
::
getPublicLifeAccountId
();
$where
[
'ORDER'
]
=
[
"update_time"
=>
"DESC"
];
$where
[
'ORDER'
]
=
[
$sortField
=>
$sortType
];
$where
[
'LIMIT'
]
=
[
$page
,
$limit
];
$list
=
Marketing
::
select
([
"marketing_id"
,
"marketing_name"
,
"start_time"
,
"end_time"
,
"online_status"
,
"update_time"
,
"create_time"
]
...
...
@@ -1105,6 +1125,63 @@ class MarketingService
return
$marketing_list
;
}
public
static
function
tuancanList
(
$params
)
{
}
/**
* 获取多个活动的商品列表
* @param $marketingIds
* @return array
* @throws InterfaceException
*/
public
static
function
getGoodsSkuListByMarketingIds
(
$marketingIds
)
{
$marketingGoodsList
=
MarketingGoods
::
marketingGoodsList
([
'marketing_id'
=>
$marketingIds
,
"ORDER"
=>
[
"id"
=>
"ASC"
]]);
$goodsSkuList
=
[];
if
(
!
empty
(
$marketingGoodsList
))
{
$goodsSkuId
=
array_column
(
$marketingGoodsList
,
'goods_sku_id'
);
$goodsSkuList
=
PindanGoodsSku
::
select
(
'*'
,
[
'goods_sku_id'
=>
$goodsSkuId
]);
$goodsSkuList
=
array_column
((
array
)
$goodsSkuList
,
null
,
"goods_sku_id"
);
}
$list
=
[];
if
(
!
empty
(
$goodsSkuList
))
{
//活动sku购买数量
$soldNum
=
self
::
getHaveBuyGoodsStatistics
([
"marketing_id"
=>
$marketingIds
]);
//保持排序
foreach
(
$marketingGoodsList
as
$key
=>
$value
)
{
if
(
empty
(
$goodsSkuList
[
$value
[
"goods_sku_id"
]]))
{
continue
;
}
$list
[
$value
[
'marketing_id'
]][
$key
]
=
$value
;
$item
=
$goodsSkuList
[
$value
[
"goods_sku_id"
]];
$list
[
$value
[
'marketing_id'
]][
$key
][
'goods_name'
]
=
$item
[
'goods_name'
];
$list
[
$value
[
'marketing_id'
]][
$key
][
"desc_pic_url_list"
]
=
GoodsService
::
getUrlList
(
$item
[
"desc_pic_url"
]);
$list
[
$value
[
'marketing_id'
]][
$key
][
"original_price"
]
=
empty
(
$item
[
"original_price"
])
?
''
:
sprintf
(
"%.2f"
,
(
int
)
$item
[
"original_price"
]
/
100
);
$list
[
$value
[
'marketing_id'
]][
$key
][
"price"
]
=
sprintf
(
"%.2f"
,
$item
[
"price"
]
/
100
);
$list
[
$value
[
'marketing_id'
]][
$key
][
"all_have_buy_goods_count"
]
=
$soldNum
[
$value
[
"goods_sku_id"
]]
??
0
;
$list
[
$value
[
'marketing_id'
]][
$key
][
'inventory_rest'
]
=
$item
[
'inventory_rest'
];
}
//没有库存的放在最下面
foreach
(
$list
as
$marketingId
=>
$item
)
{
foreach
(
$item
as
$key
=>
$value
)
{
if
(
$value
[
"inventory_rest"
]
==
0
)
{
unset
(
$list
[
$marketingId
][
$key
]);
array_push
(
$list
[
$marketingId
],
$value
);
}
}
$list
[
$marketingId
]
=
array_values
(
$list
[
$marketingId
]);
}
}
return
$list
;
}
/**
*判断长度
*
...
...
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