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
bcd65f3a
Commit
bcd65f3a
authored
Sep 14, 2021
by
卢洪光
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'pre_release' into 'master'
Pre release See merge request bp/goods!60
parents
f5f7e75e
392cf986
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
276 additions
and
1 deletion
+276
-1
Goods.php
application/modules/Goods/controllers/Goods.php
+10
-0
Marketing.php
application/modules/Marketing/controllers/Marketing.php
+65
-0
KafkaService.php
application/services/common/KafkaService.php
+35
-0
GoodsSnapshotsService.php
application/services/goods/GoodsSnapshotsService.php
+40
-0
MarketingService.php
application/services/marketing/MarketingService.php
+124
-0
Pindan.php
daemon/Pindan.php
+2
-1
No files found.
application/modules/Goods/controllers/Goods.php
View file @
bcd65f3a
...
...
@@ -339,4 +339,14 @@ class GoodsController extends Base
$res
=
GoodsService
::
getOtaInfoByGoodsSkuIds
(
$this
->
params
);
$this
->
success
([
"result"
=>
$res
]);
}
/**
* 拼单商品快照批量获取
* @throws Exception
*/
public
function
goods_snapshotsAction
()
{
$res
=
GoodsSnapshotsService
::
goodsSnapshots
(
$this
->
params
);
$this
->
success
([
"result"
=>
$res
]);
}
}
\ No newline at end of file
application/modules/Marketing/controllers/Marketing.php
View file @
bcd65f3a
...
...
@@ -7,6 +7,8 @@ use App\Services\marketing\MarketingGoodsService;
use
\Validate\MarketingGoodsRateValidate
;
use
\Validate\MarketingOnlineStatusValidate
;
use
\Validate\MarketingInfoValidate
;
use
App\Models\marketing\mysql\Marketing
;
use
App\Models\marketing\mysql\MarketingPindan
;
class
MarketingController
extends
Base
{
...
...
@@ -155,6 +157,69 @@ class MarketingController extends Base
$this
->
success
();
}
/**
* app内团餐活动列表
* @throws \App\Exception\custom\InterfaceException
*/
public
function
tuancan_listAction
()
{
$this
->
params
[
'marketing_type'
]
=
Marketing
::
MARKETING_TYPE_PINDAN
;
//1分销 2团购 3秒杀 4团餐
$this
->
params
[
'online_status'
]
=
Marketing
::
ONLINE_STATUS_QIDONG
;
//状态 , 1启用,2关闭,3 到期
$this
->
params
[
'from'
]
=
1
;
//1 小程序前台 默认0 后台
//正在进行中的 按结束时间正序
$this
->
params
[
'sort_field'
]
=
'end_time'
;
$this
->
params
[
'sort_type'
]
=
'asc'
;
$this
->
params
[
'need_buy_num'
]
=
false
;
$this
->
params
[
'activity_status'
]
=
MarketingPindan
::
ACTIVITY_STATUS_IN_PROGRESS
;
//1 未开始,2进行中,3已结束
$list
[
'doing'
]
=
MarketingService
::
marketingList
(
$this
->
params
)[
'result'
];
$list
[
'doing'
]
=
$list
[
'doing'
]
?
array_column
(
$list
[
'doing'
],
null
,
'marketing_id'
)
:
[];
$marketingIdsDoing
=
array_keys
(
$list
[
'doing'
]);
//当天即将开始的 按开始时间正序
$this
->
params
[
'page'
]
=
1
;
$this
->
params
[
'sort_field'
]
=
'start_time'
;
$this
->
params
[
'sort_type'
]
=
'asc'
;
$this
->
params
[
'need_buy_num'
]
=
false
;
$this
->
params
[
'activity_status'
]
=
MarketingPindan
::
ACTIVITY_STATUS_START_TODAY
;
//1 未开始,2进行中,3已结束, 4当日上新(即将开始)
$list
[
'prepare'
]
=
MarketingService
::
marketingList
(
$this
->
params
)[
'result'
];
$list
[
'prepare'
]
=
$list
[
'prepare'
]
?
array_column
((
array
)
$list
[
'prepare'
],
null
,
'marketing_id'
)
:
[];
$marketingIdsPrepare
=
array_keys
(
$list
[
'prepare'
]);
//已结束的 按结束时间倒序
$this
->
params
[
'page'
]
=
1
;
$this
->
params
[
'page_size'
]
=
10
;
$this
->
params
[
'sort_field'
]
=
'end_time'
;
$this
->
params
[
'sort_type'
]
=
'desc'
;
$this
->
params
[
'need_buy_num'
]
=
false
;
$this
->
params
[
'online_status'
]
=
[
Marketing
::
ONLINE_STATUS_QIDONG
,
Marketing
::
ONLINE_STATUS_GUANBI
,
Marketing
::
ONLINE_STATUS_DAOQI
];
//状态 , 1启用,2关闭,3 到期
$this
->
params
[
'activity_status'
]
=
MarketingPindan
::
ACTIVITY_STATUS_FINISHED
;
//1 未开始,2进行中,3已结束, 4当日上新(即将开始)
$list
[
'end'
]
=
MarketingService
::
marketingList
(
$this
->
params
)[
'result'
];
$list
[
'end'
]
=
$list
[
'end'
]
?
array_column
(
$list
[
'end'
],
null
,
'marketing_id'
)
:
[];
$marketingIdsEnd
=
array_keys
(
$list
[
'end'
]);
$marketingIds
=
array_merge
(
$marketingIdsDoing
,
$marketingIdsPrepare
,
$marketingIdsEnd
);
//获取活动的sku列表
$skuList
=
MarketingService
::
getGoodsSkuListByMarketingIds
(
$marketingIds
);
//获取活动支付用户列表
$orderUser
=
MarketingService
::
getMarketingOrderUser
([
'marketing_id'
=>
$marketingIds
]);
//获取活动支付用户数
$buyNum
=
MarketingService
::
getHaveBuyGoodsUserCount
([
'marketing_id'
=>
$marketingIds
]);
//组合sku和order信息
foreach
(
$list
as
&
$listPart
)
{
foreach
(
$listPart
as
$marketingId
=>
&
$value
)
{
$value
[
'sku_list'
]
=
$skuList
[
$marketingId
]
??
[];
$value
[
'order_user'
]
=
$orderUser
[
$marketingId
]
??
[];
$value
[
'participate_number'
]
=
$buyNum
[
$marketingId
]
??
0
;
}
unset
(
$value
);
$listPart
=
array_values
(
$listPart
);
}
unset
(
$listPart
);
$list
[
'life_account_id'
]
=
MarketingService
::
getPublicLifeAccountId
();
$this
->
success
([
'result'
=>
$list
]);
}
/**
* 切换活动状态
* @throws \App\Exception\custom\ParamException
...
...
application/services/common/KafkaService.php
0 → 100644
View file @
bcd65f3a
<?php
namespace
App\Services\common
;
use
Api\PhpUtils\Kafka\KafkaUtil
;
use
Api\PhpUtils\Log\FileLog
;
class
KafkaService
{
/**
* marketing 广播
*/
public
static
function
productMarketingUpdate
(
array
$marketingInfo
)
:
void
{
$msg
=
json_encode
([
'marketingInfo'
=>
$marketingInfo
,
'time'
=>
time
(),
],
JSON_FORCE_OBJECT
);
$serverName
=
'goods.publish'
;
$kafka
=
KafkaUtil
::
getInstance
(
$serverName
);
if
(
$kafka
->
produce
(
$msg
,
$marketingInfo
[
'activityId'
]))
{
FileLog
::
info
(
sprintf
(
'kafka produce success serverName %s msg = %s'
,
$serverName
,
$msg
));
}
else
{
FileLog
::
error
(
sprintf
(
'kafka produce failure serverName %s msg = %s'
,
$serverName
,
$msg
));
}
}
}
\ No newline at end of file
application/services/goods/GoodsSnapshotsService.php
View file @
bcd65f3a
...
...
@@ -3,6 +3,8 @@
namespace
App\Services\goods
;
use
Api\PhpUtils\Common\GoodsSkuId
;
use
App\Models\goods\mysql\GoodsSnapshot
;
use
App\Models\goods\mysql\PindanGoodsSnapshot
;
class
GoodsSnapshotsService
...
...
@@ -32,4 +34,42 @@ class GoodsSnapshotsService
}
return
$pindanGoodsSnapshot
;
}
/**
* 批量支持商品
* @param $params
* @return array
*/
public
static
function
goodsSnapshots
(
$params
)
{
$str
=
empty
(
$params
[
"snapshots_str"
])
?
""
:
$params
[
"snapshots_str"
];
$snapshot
=
[];
if
(
!
empty
(
$str
))
{
$paramsArr
=
json_decode
(
$str
,
true
);
if
(
!
empty
(
$paramsArr
))
{
foreach
(
$paramsArr
as
$param
)
{
if
(
isset
(
$param
[
"goods_sku_id"
])
||
isset
(
$param
[
"goods_version"
]))
{
$goodsSkuIdParams
=
GoodsSkuId
::
getGoodsSkuIdParams
(
$param
[
"goods_sku_id"
]);
$key
=
$param
[
"goods_sku_id"
]
.
"_"
.
$param
[
"goods_version"
];
if
(
$goodsSkuIdParams
[
"table_tag"
]
==
GoodsSkuId
::
TABLE_TAG_PINDAN
)
{
$snapshot
[
$key
]
=
PindanGoodsSnapshot
::
getRecord
([
"goods_sku_id"
=>
$param
[
"goods_sku_id"
],
"goods_version"
=>
$param
[
"goods_version"
]
]);
}
else
{
$snapshot
[
$key
]
=
GoodsSnapshot
::
getRecord
([
"goods_sku_id"
=>
$param
[
"goods_sku_id"
],
"goods_version"
=>
$param
[
"goods_version"
]
]);
}
if
(
!
empty
(
$snapshot
[
$key
][
"desc_pic_url"
]))
{
$ksyun
=
GoodsService
::
getUrlList
(
$snapshot
[
$key
][
"desc_pic_url"
]);
$snapshot
[
$key
][
"desc_pic_url_list"
]
=
$ksyun
;
}
}
}
}
}
return
$snapshot
;
}
}
\ No newline at end of file
application/services/marketing/MarketingService.php
View file @
bcd65f3a
...
...
@@ -6,6 +6,7 @@ namespace App\Services\marketing;
use
Api\PhpServices\Ksy\Ks3Api
;
use
Api\PhpUtils\Http\Request
;
use
Api\PhpUtils\Http\HttpUtil
;
use
App\Exception\BaseException
;
use
App\Exception\custom\InterfaceException
;
use
App\Models\goods\mysql\Ota
;
use
App\Models\goods\mysql\PindanGoodsSku
;
...
...
@@ -19,6 +20,7 @@ use App\Models\marketing\mysql\MarketingPindan;
use
App\Models\marketing\mysql\MarketingTakePlace
;
use
App\Models\marketing\mysql\TakePlace
;
use
App\Services\common\CommonService
;
use
App\Services\common\KafkaService
;
use
App\Services\goods\GoodsService
;
use
Daemon\Goods
;
use
App\Exception\custom\GoodsException
;
...
...
@@ -740,6 +742,19 @@ class MarketingService
throw
new
MarketingException
([
"cus"
=>
5
]);
}
$picList
=
GoodsService
::
getUrlList
(
$pindanPic
);
KafkaService
::
productMarketingUpdate
([
'activityId'
=>
$marketingId
,
'startDate'
=>
$startTime
,
'endDate'
=>
$endTime
,
'userId'
=>
$lifeAccountId
,
'activityName'
=>
$marketingName
,
'text'
=>
$pindanDesc
,
'imageId'
=>
$picList
[
0
]
??
''
,
'createTime'
=>
date
(
'Y-m-d H:i:s'
),
'onlineStatus'
=>
Marketing
::
ONLINE_STATUS_QIDONG
,
]);
return
$pindanId
;
}
...
...
@@ -895,6 +910,20 @@ class MarketingService
throw
new
MarketingException
([
"cus"
=>
5
]);
}
$picList
=
GoodsService
::
getUrlList
(
$marketingPindan
[
'pindan_pic'
]);
KafkaService
::
productMarketingUpdate
([
'activityId'
=>
$marketingId
,
'startDate'
=>
$startTime
,
'endDate'
=>
$endTime
,
'userId'
=>
config
(
'lifeaccount'
,
'life_account_id'
),
'activityName'
=>
$marketingName
,
'text'
=>
$pindanDesc
,
'imageId'
=>
$picList
[
0
]
??
''
,
'createTime'
=>
$marketing
[
'create_time'
],
'onlineStatus'
=>
Marketing
::
ONLINE_STATUS_QIDONG
,
]);
return
true
;
}
...
...
@@ -921,6 +950,26 @@ class MarketingService
'online_status'
=>
$onlineStatus
,
'end_time'
=>
$endTime
,
];
if
(
$marketingType
==
Marketing
::
MARKETING_TYPE_PINDAN
)
{
$marketing
=
Marketing
::
getRecord
([
"marketing_id"
=>
$marketingId
]);
$marketingPindan
=
MarketingPindan
::
getRecord
([
"marketing_id"
=>
$marketingId
]);
$picList
=
GoodsService
::
getUrlList
(
$marketingPindan
[
'pindan_pic'
]);
KafkaService
::
productMarketingUpdate
([
'activityId'
=>
$marketingId
,
'startDate'
=>
$marketing
[
'start_time'
],
'endDate'
=>
$endTime
,
'userId'
=>
config
(
'lifeaccount'
,
'life_account_id'
),
'activityName'
=>
$marketing
[
'marketing_name'
],
'text'
=>
$marketingPindan
[
'pindan_desc'
],
'imageId'
=>
$picList
[
0
]
??
''
,
'createTime'
=>
$marketing
[
'create_time'
],
'onlineStatus'
=>
$onlineStatus
,
]);
}
Marketing
::
updateRecord
(
$marketingParams
,
[
"marketing_id"
=>
$marketingId
,
"marketing_type"
=>
$marketingType
]);
}
...
...
@@ -1133,10 +1182,85 @@ class MarketingService
public
static
function
getMarketingList
(
$params
)
{
$where
[
'marketing_id'
]
=
!
empty
(
$params
[
'marketing_id'
])
?
$params
[
'marketing_id'
]
:
''
;
if
(
!
empty
(
$params
[
'marketing_type'
])){
$where
[
'marketing_type'
]
=
!
empty
(
$params
[
'marketing_type'
])
?
$params
[
'marketing_type'
]
:
''
;
}
$marketing_list
=
Marketing
::
getMarketingList
(
$where
);
return
$marketing_list
;
}
/**
* 获取多个活动的商品列表
* @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
;
}
/**
* 获取活动支付用户列表
* @param $params
* @return array|mixed
* @throws InterfaceException
*/
public
static
function
getMarketingOrderUser
(
$params
)
{
$url
=
config
(
'interface'
,
'order.marketing.marketing_user'
);
if
(
empty
(
$url
))
{
throw
new
InterfaceException
([
'cus'
=>
0
]);
}
$res
=
HttpUtil
::
get
(
$url
,
$params
);
$data
=
[];
if
(
$res
[
'code'
]
==
0
&&
isset
(
$res
[
'response'
][
"result"
]))
{
$data
=
$res
[
"response"
][
"result"
];
}
return
$data
;
}
/**
*判断长度
*
...
...
daemon/Pindan.php
View file @
bcd65f3a
...
...
@@ -54,7 +54,8 @@ class Pindan implements DaemonServiceInterface
$params
=
[
self
::
emojiFilter
(
$marketing
[
'marketing_name'
]),
$marketing
[
'start_time'
],
$pindan
[
'pindan_desc'
]
?:
self
::
DEFAULT_DESC
$pindan
[
'pindan_desc'
]
?:
self
::
DEFAULT_DESC
,
$marketing
[
'marketing_id'
]
];
//发送消息
...
...
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