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
08ec9025
Commit
08ec9025
authored
Aug 31, 2021
by
suntengda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update 拼团活动列表排序规则,时间范围修改
parent
fa30082d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
7 deletions
+85
-7
MarketingPindan.php
application/models/marketing/mysql/MarketingPindan.php
+1
-0
MarketingService.php
application/services/marketing/MarketingService.php
+84
-7
No files found.
application/models/marketing/mysql/MarketingPindan.php
View file @
08ec9025
...
@@ -13,6 +13,7 @@ class MarketingPindan extends MysqlBase
...
@@ -13,6 +13,7 @@ class MarketingPindan extends MysqlBase
const
ACTIVITY_STATUS_NO_START
=
1
;
const
ACTIVITY_STATUS_NO_START
=
1
;
const
ACTIVITY_STATUS_IN_PROGRESS
=
2
;
const
ACTIVITY_STATUS_IN_PROGRESS
=
2
;
const
ACTIVITY_STATUS_FINISHED
=
3
;
const
ACTIVITY_STATUS_FINISHED
=
3
;
const
ACTIVITY_STATUS_START_TODAY
=
4
;
//今日上新
public
static
function
getRecord
(
$where
,
$colums
=
[])
public
static
function
getRecord
(
$where
,
$colums
=
[])
{
{
...
...
application/services/marketing/MarketingService.php
View file @
08ec9025
...
@@ -231,6 +231,17 @@ class MarketingService
...
@@ -231,6 +231,17 @@ class MarketingService
$params
[
'page'
]
=
!
empty
(
$params
[
'page'
])
?
$params
[
'page'
]
:
1
;
$params
[
'page'
]
=
!
empty
(
$params
[
'page'
])
?
$params
[
'page'
]
:
1
;
$limit
=
!
empty
(
$params
[
'page_size'
])
?
$params
[
'page_size'
]
:
20
;
$limit
=
!
empty
(
$params
[
'page_size'
])
?
$params
[
'page_size'
]
:
20
;
$page
=
(
$params
[
'page'
]
-
1
)
*
$limit
;
$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
;
$where
[
"marketing_type"
]
=
Marketing
::
MARKETING_TYPE_PINDAN
;
if
(
!
empty
(
$params
[
'marketing_name'
]))
{
if
(
!
empty
(
$params
[
'marketing_name'
]))
{
...
@@ -246,18 +257,27 @@ class MarketingService
...
@@ -246,18 +257,27 @@ class MarketingService
}
elseif
(
$params
[
"activity_status"
]
==
MarketingPindan
::
ACTIVITY_STATUS_IN_PROGRESS
)
{
}
elseif
(
$params
[
"activity_status"
]
==
MarketingPindan
::
ACTIVITY_STATUS_IN_PROGRESS
)
{
$where
[
"start_time[<=]"
]
=
$now
;
$where
[
"start_time[<=]"
]
=
$now
;
$where
[
"end_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
)
{
}
elseif
(
$params
[
"activity_status"
]
==
MarketingPindan
::
ACTIVITY_STATUS_FINISHED
)
{
$where
[
"end_time[<]"
]
=
$now
;
$where
[
"end_time[<]"
]
=
$now
;
}
//七日内结束的活动
if
(
!
empty
(
$params
[
'from'
])
&&
$params
[
'from'
]
==
1
)
{
if
(
!
empty
(
$params
[
'activity_status'
])
&&
!
empty
(
$params
[
'from'
]))
{
$beforeSevenDay
=
date
(
"Y-m-d H:i:s"
,
strtotime
(
"-7 day"
));
$beforeSevenDay
=
date
(
"Y-m-d H:i:s"
,
strtotime
(
"-7 day"
));
$where
[
"end_time[>]"
]
=
$beforeSevenDay
;
$where
[
"start_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
[
'life_account_id'
]
=
self
::
getPublicLifeAccountId
();
$where
[
'ORDER'
]
=
[
"update_time"
=>
"DESC"
];
$where
[
'ORDER'
]
=
[
$sortField
=>
$sortType
];
$where
[
'LIMIT'
]
=
[
$page
,
$limit
];
$where
[
'LIMIT'
]
=
[
$page
,
$limit
];
$list
=
Marketing
::
select
([
"marketing_id"
,
"marketing_name"
,
"start_time"
,
"end_time"
,
$list
=
Marketing
::
select
([
"marketing_id"
,
"marketing_name"
,
"start_time"
,
"end_time"
,
"online_status"
,
"update_time"
,
"create_time"
]
"online_status"
,
"update_time"
,
"create_time"
]
...
@@ -1045,6 +1065,63 @@ class MarketingService
...
@@ -1045,6 +1065,63 @@ class MarketingService
return
$marketing_list
;
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