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
711a6bf6
Commit
711a6bf6
authored
Aug 26, 2021
by
jianghaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of
https://gitlab.yidian-inc.com/bp/goods
into develop
parents
3a6ff5ae
83f8942b
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
248 additions
and
53 deletions
+248
-53
ColonelAddPointValidate.php
application/library/Validate/ColonelAddPointValidate.php
+1
-1
MarketingOnlineStatusValidate.php
...cation/library/Validate/MarketingOnlineStatusValidate.php
+5
-0
ColonelDistributorColonel.php
...tion/models/marketing/mysql/ColonelDistributorColonel.php
+1
-1
ColonelDistributorPayInfo.php
...tion/models/marketing/mysql/ColonelDistributorPayInfo.php
+8
-0
Marketing.php
application/models/marketing/mysql/Marketing.php
+6
-0
Colonel.php
application/modules/Marketing/controllers/Colonel.php
+28
-4
Marketing.php
application/modules/Marketing/controllers/Marketing.php
+21
-0
ColonelService.php
application/services/marketing/ColonelService.php
+7
-5
MarketingService.php
application/services/marketing/MarketingService.php
+60
-42
PindanActivityInviteOrderService.php
...n/services/marketing/PindanActivityInviteOrderService.php
+111
-0
No files found.
application/library/Validate/ColonelAddPoint.php
→
application/library/Validate/ColonelAddPoint
Validate
.php
View file @
711a6bf6
...
...
@@ -7,7 +7,7 @@
namespace
Validate
;
class
ColonelAddPoint
extends
BaseValidate
class
ColonelAddPoint
Validate
extends
BaseValidate
{
protected
$rule
=
[
'colonel_apply_id'
=>
'require'
,
...
...
application/library/Validate/MarketingOnlineStatusValidate.php
View file @
711a6bf6
...
...
@@ -22,4 +22,9 @@ class MarketingOnlineStatusValidate extends BaseValidate
"marketing_type"
=>
"marketing_type 不能为空"
,
"online_status"
=>
"online_status 不能为空"
,
];
public
function
sceneYingxiao
()
{
return
$this
->
only
([
'marketing_id'
,
'online_status'
]);
}
}
\ No newline at end of file
application/models/marketing/mysql/ColonelDistributorColonel.php
View file @
711a6bf6
...
...
@@ -17,7 +17,7 @@ class ColonelDistributorColonel extends MysqlBase
const
COLONEL_SOURCE_APPLY
=
1
;
//用户申请
const
COLONEL_SOURCE_ADMIN
=
2
;
//运营添加
const
DEFAULT_COLUMN
=
[
'colonel_id'
,
'user_id'
,
'take_place_id'
,
'phone'
,
'contact_name'
,
'colonel_
distributor_code'
,
'colonel_
source'
];
const
DEFAULT_COLUMN
=
[
'colonel_id'
,
'user_id'
,
'take_place_id'
,
'phone'
,
'contact_name'
,
'colonel_source'
];
public
static
function
getRecord
(
array
$where
,
$column
=
'*'
)
...
...
application/models/marketing/mysql/ColonelDistributorPayInfo.php
View file @
711a6bf6
...
...
@@ -10,6 +10,14 @@ class ColonelDistributorPayInfo extends MysqlBase
const
CONFIG_INDEX
=
'marketing'
;
const
PRIMARY_KEY
=
'colonel_distributor_pay_info_id'
;
const
TYPE_NEW_USER
=
1
;
const
TYPE_FINISH_TARGET
=
2
;
public
static
$typeDesc
=
[
self
::
TYPE_NEW_USER
=>
"邀请新用户"
,
self
::
TYPE_FINISH_TARGET
=>
"完成目标单数"
,
];
public
static
function
getRecord
(
$where
,
$columns
=
[],
$options
=
[])
{
if
(
empty
(
$columns
))
{
...
...
application/models/marketing/mysql/Marketing.php
View file @
711a6bf6
...
...
@@ -14,6 +14,8 @@ class Marketing extends MysqlBase
const
MARKETING_TYPE_TUANGOU
=
2
;
const
MARKETING_TYPE_MIAOSHA
=
3
;
const
MARKETING_TYPE_PINDAN
=
4
;
const
MARKETING_TYPE_LIEBIAN
=
5
;
const
MARKETING_TYPE_TUANZHANG
=
6
;
const
ONLINE_STATUS_QIDONG
=
1
;
const
ONLINE_STATUS_GUANBI
=
2
;
...
...
@@ -125,6 +127,10 @@ class Marketing extends MysqlBase
$data
[
'online_status'
]
=
$where
[
'online_status'
];
}
if
(
!
empty
(
$where
[
'marketing_type'
]))
{
$data
[
'marketing_type'
]
=
$where
[
'marketing_type'
];
}
return
$data
;
}
}
application/modules/Marketing/controllers/Colonel.php
View file @
711a6bf6
...
...
@@ -11,7 +11,7 @@ use \Validate\ColonelApplyValidate;
use
\Validate\ColonelConfigValidate
;
use
\Validate\ColonelAuditValidate
;
use
\Validate\ColonelCenterValidate
;
use
\Validate\ColonelAddPoint
;
use
\Validate\ColonelAddPoint
Validate
;
use
\App\Services\marketing\PindanActivityColonelConfigService
;
use
\App\Services\marketing\PindanActivityInviteOrderService
;
use
\App\Services\user\UserService
;
...
...
@@ -44,8 +44,8 @@ class ColonelController extends Base
{
$params
=
$this
->
params
;
(
new
ColonelCenterValidate
())
->
validate
();
$
isApply
=
ColonelService
::
isApply
(
$params
[
'user_id'
]);
return
$this
->
success
([
'result'
=>
[
'is_apply'
=>
$isApply
]
]);
$
applyInfo
=
ColonelService
::
isApply
(
$params
[
'user_id'
]);
return
$this
->
success
([
'result'
=>
$applyInfo
]);
}
/**
...
...
@@ -135,7 +135,7 @@ class ColonelController extends Base
public
function
manage_add_apply_pointAction
()
{
$params
=
$this
->
params
;
(
new
ColonelAddPoint
())
->
validate
();
(
new
ColonelAddPoint
Validate
())
->
validate
();
$takePlaceId
=
ColonelService
::
handleAddTaskPlace
(
$params
);
return
$this
->
success
([
'result'
=>
[
'take_place_id'
=>
$takePlaceId
]]);
}
...
...
@@ -203,4 +203,28 @@ class ColonelController extends Base
return
$this
->
success
([
"result"
=>
[]]);
}
/**
* 团长分销,账单详情
* @throws Exception
*/
public
function
bill_infoAction
()
{
(
new
ColonelCenterValidate
())
->
validate
();
$params
=
$this
->
params
;
$data
=
PindanActivityInviteOrderService
::
getPayInfoList
(
$params
);
return
$this
->
success
([
"result"
=>
$data
]);
}
/**
* 团长分销,下单记录
* @throws \App\Exception\custom\ParamException
*/
public
function
invite_order_recordAction
()
{
(
new
ColonelCenterValidate
())
->
validate
();
$params
=
$this
->
params
;
$data
=
PindanActivityInviteOrderService
::
getInviteOrderRecord
(
$params
);
return
$this
->
success
([
"result"
=>
$data
]);
}
}
application/modules/Marketing/controllers/Marketing.php
View file @
711a6bf6
...
...
@@ -155,4 +155,25 @@ class MarketingController extends Base
$this
->
success
();
}
/**
* 切换活动状态
* @throws \App\Exception\custom\ParamException
*/
public
function
toogle_yingxiao_online_statusAction
()
{
(
new
MarketingOnlineStatusValidate
())
->
scene
(
'yingxiao'
)
->
validate
();
$res
=
MarketingService
::
toogleOnlineStatus
(
$this
->
params
[
'marketing_id'
],
$this
->
params
[
'online_status'
]);
$this
->
success
([
'result'
=>
$res
]);
}
/**
* 营销中心-活动列表
* @throws Exception
*/
public
function
yingxiao_listAction
()
{
$lists
=
MarketingService
::
yingxiaoList
(
$this
->
params
);
$this
->
success
([
'result'
=>
$lists
]);
}
}
\ No newline at end of file
application/services/marketing/ColonelService.php
View file @
711a6bf6
...
...
@@ -62,12 +62,15 @@ class ColonelService
* User: pengfei@yidian-inc.com
* Date: 2021/8/25 11:42 上午
* @param int $userId
* @return
int
* @return
array
*/
public
static
function
isApply
(
int
$userId
)
:
int
public
static
function
isApply
(
int
$userId
)
:
array
{
$isApply
=
ColonelDistributorColonelApply
::
existUser
(
$userId
);
return
intval
(
$isApply
);
$applyInfo
=
ColonelDistributorColonelApply
::
getRecord
([
'user_id'
=>
$userId
],
[
'colonel_apply_id'
,
'audit_status'
]);
return
[
// -1.未申请 0.未审核 1.审核通过 2.审核未通过
'apply_status'
=>
isset
(
$applyInfo
[
'audit_status'
])
?
intval
(
$applyInfo
[
'audit_status'
])
:
-
1
];
}
...
...
@@ -248,7 +251,6 @@ class ColonelService
'life_account_id'
=>
$applyInfo
[
'life_account_id'
],
'phone'
=>
$applyInfo
[
'phone'
],
'contact_name'
=>
$applyInfo
[
'contact_name'
],
'colonel_distributor_code'
=>
''
,
//TODO 生成活动码
'colonel_source'
=>
ColonelDistributorColonel
::
COLONEL_SOURCE_APPLY
];
return
ColonelDistributorColonel
::
insertRecord
(
$colonelData
);
...
...
application/services/marketing/MarketingService.php
View file @
711a6bf6
...
...
@@ -4,8 +4,7 @@
namespace
App\Services\marketing
;
use
Api\PhpServices\Ksy\Ks3Api
;
use
Api\PhpUtils\Http\HttpUtil
;
use
App\Exception\custom\InterfaceException
;
use
Api\PhpUtils\Http\Request
;
use
App\Models\goods\mysql\Ota
;
use
App\Models\goods\mysql\PindanGoodsSku
;
use
App\Models\marketing\mysql\Marketing
;
...
...
@@ -147,6 +146,47 @@ class MarketingService
}
}
/**
* 营销中心-活动列表
* @param $params
* @return array
*/
public
static
function
yingxiaoList
(
$params
)
{
$where
[
"marketing_type"
]
=
[
Marketing
::
MARKETING_TYPE_LIEBIAN
,
Marketing
::
MARKETING_TYPE_TUANZHANG
];
$where
[
'ORDER'
]
=
[
"create_time"
=>
"DESC"
];
$lists
=
Marketing
::
getRecords
(
$where
);
if
(
$lists
&&
is_array
(
$lists
))
{
$capitalPoolIds
=
array_column
(
$lists
,
'capital_pool_id'
);
//获取资金池列表信息
$url
=
config
(
'interface'
,
'coupon.capitalpool.fetch_map_capitalpool'
);
$capitalPoolList
=
(
new
Request
())
->
get
(
$url
,
[
"capital_pool_ids"
=>
$capitalPoolIds
]);
$capitalPoolList
=
$capitalPoolList
[
'response'
][
'result'
]
?:
[];
$poolTotal
=
$poolUsed
=
$poolLock
=
0
;
foreach
(
$lists
as
&
$val
)
{
if
(
$capitalPoolList
[
$val
[
'capital_pool_id'
]])
{
$val
[
'capital_pool'
]
=
$capitalPoolList
[
$val
[
'capital_pool_id'
]];
$poolTotal
+=
$val
[
'capital_pool'
][
'capital_pool_total'
];
$poolUsed
+=
$val
[
'capital_pool'
][
'capital_pool_used'
];
$poolLock
+=
$val
[
'capital_pool'
][
'capital_pool_lock'
];
}
else
{
$val
[
'capital_pool'
]
=
[];
}
$val
[
'online_status_desc'
]
=
Marketing
::
$onlineStatusDesc
[
$val
[
'online_status'
]];
}
unset
(
$val
);
}
$poolbalance
=
$poolTotal
-
$poolUsed
-
$poolLock
;
$poolAnalysis
=
[
'total'
=>
$poolTotal
,
'used'
=>
$poolUsed
,
'lock'
=>
$poolLock
,
'balance'
=>
$poolbalance
];
return
[
'anlysis'
=>
$poolAnalysis
,
'list'
=>
$lists
];
}
/**
* 分销活动列表
* @param $params
...
...
@@ -504,25 +544,7 @@ class MarketingService
throw
new
GoodsException
([
'cus'
=>
48
]);
}
}
}
else
{
//比例计算
if
(
$commissionMode
==
Marketing
::
COMMISSION_MODE_RATE
)
{
$commissionTotal
=
(
$firstCommissionRate
+
$secondCommissionRate
)
/
10000
*
$price
;
if
(
$price
<
(
$commissionTotal
+
$chargeFee
))
{
throw
new
MarketingException
([
'cus'
=>
23
]);
}
}
//固定金额
if
(
$commissionMode
==
Marketing
::
COMMISSION_MODE_FIXED
)
{
$commissionTotal
=
(
$firstCommissionRate
+
$secondCommissionRate
);
if
(
$price
<
(
$commissionTotal
+
$chargeFee
))
{
throw
new
MarketingException
([
'cus'
=>
23
]);
}
}
}
$colums
[
$key
][
'marketing_id'
]
=
$marketingId
;
$colums
[
$key
][
'goods_spu_id'
]
=
$value
[
'goods_spu_id'
];
...
...
@@ -850,6 +872,24 @@ class MarketingService
Marketing
::
updateRecord
(
$marketingParams
,
[
"marketing_id"
=>
$marketingId
,
"marketing_type"
=>
$marketingType
]);
}
/**
* 切换活动状态
* @param $marketingId
* @param $onlineStatus
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
static
function
toogleOnlineStatus
(
$marketingId
,
$onlineStatus
)
{
if
(
!
in_array
(
$onlineStatus
,
array_keys
(
Marketing
::
$onlineStatusDesc
)))
{
return
0
;
}
$data
=
[
'online_status'
=>
$onlineStatus
,
];
return
Marketing
::
updateRecord
(
$data
,
[
"marketing_id"
=>
$marketingId
]);
}
/**
* 分销活动详情
* @param $params
...
...
@@ -965,15 +1005,6 @@ class MarketingService
$info
[
'marketing_info'
]
=
$marketingData
;
//有用户登录时候,当前用户购买的商品数量信息
$haveBuyGoodsStatistics
=
[];
if
(
!
empty
(
$params
[
"user_id"
]))
{
$haveBuyGoodsStatistics
=
self
::
getHaveBuyGoodsStatistics
([
"user_id"
=>
$params
[
"user_id"
],
"marketing_id"
=>
$marketingData
[
"id"
]]);
}
//活动中所有购买的商品数量信息
$allHaveBuyGoodsStatistics
=
self
::
getHaveBuyGoodsStatistics
([
"marketing_id"
=>
$marketingData
[
"id"
]]);
if
(
!
empty
(
$goodsSkuList
))
{
$otaIds
=
array_unique
(
array_column
(
$goodsSkuList
,
"ota_id"
));
$otas
=
Ota
::
select
([
"ota_id"
,
"ota_name"
],
[
"ota_id"
=>
$otaIds
]);
...
...
@@ -986,19 +1017,6 @@ class MarketingService
$goodsSkuList
[
$key
][
"ota_name"
]
=
empty
(
$otasData
[
$item
[
"ota_id"
]][
"ota_name"
])
?
""
:
$otasData
[
$item
[
"ota_id"
]][
"ota_name"
];
$goodsSkuList
[
$key
][
"original_price"
]
=
empty
(
$item
[
"original_price"
])
?
''
:
sprintf
(
"%.2f"
,
(
int
)
$item
[
"original_price"
]
/
100
);
$goodsSkuList
[
$key
][
"price"
]
=
sprintf
(
"%.2f"
,
$item
[
"price"
]
/
100
);
$goodsSkuList
[
$key
][
"have_buy_goods_count"
]
=
0
;
//前端当前登录人的数据
$haveBuyGoodsSkuIds
=
array_keys
(
$haveBuyGoodsStatistics
);
if
(
in_array
(
$item
[
"goods_sku_id"
],
$haveBuyGoodsSkuIds
))
{
$goodsSkuList
[
$key
][
"have_buy_goods_count"
]
=
$haveBuyGoodsStatistics
[
$item
[
"goods_sku_id"
]];
}
//后台展示所有购买的数量
$goodsSkuList
[
$key
][
"all_have_buy_goods_count"
]
=
0
;
$allHaveBuyGoodsSkuIds
=
array_keys
(
$allHaveBuyGoodsStatistics
);
if
(
in_array
(
$item
[
"goods_sku_id"
],
$allHaveBuyGoodsSkuIds
))
{
$goodsSkuList
[
$key
][
"all_have_buy_goods_count"
]
=
$allHaveBuyGoodsStatistics
[
$item
[
"goods_sku_id"
]];
}
}
}
...
...
application/services/marketing/PindanActivityInviteOrderService.php
View file @
711a6bf6
...
...
@@ -7,6 +7,7 @@ use App\Models\marketing\mysql\ColonelDistributorColonel;
use
App\Models\marketing\mysql\ColonelDistributorInviteOrder
;
use
App\Models\marketing\mysql\ColonelDistributorInviteOrderNum
;
use
App\Models\marketing\mysql\ColonelDistributorPayInfo
;
use
App\Services\user\UserService
;
class
PindanActivityInviteOrderService
{
...
...
@@ -164,4 +165,114 @@ class PindanActivityInviteOrderService
}
return
$data
;
}
/**
* 团长分销,账单详情
* @param array $params
* @return array
*/
public
static
function
getPayInfoList
(
$params
=
[])
{
$weekDay
=
date
(
"Y-m-d"
,
strtotime
(
"-7 day"
));
$userId
=
$params
[
"user_id"
];
if
(
empty
(
$userId
))
{
return
[];
}
$payList
=
ColonelDistributorPayInfo
::
select
(
"*"
,
[
"colonel_user_id"
=>
$userId
,
"date[>=]"
=>
$weekDay
,
"ORDER"
=>
[
"date"
=>
"DESC"
]
],
[]);
$data
=
$res
=
[];
if
(
!
empty
(
$payList
))
{
foreach
(
$payList
as
$item
)
{
$tempItem
=
[];
$tempItem
[
"type"
]
=
$item
[
"type"
];
$tempItem
[
"type_desc"
]
=
ColonelDistributorPayInfo
::
$typeDesc
[
$item
[
"type"
]];
$tempItem
[
"invite_user_id"
]
=
$item
[
"invite_user_id"
];
$tempItem
[
"invite_user_nick"
]
=
$item
[
"invite_user_nick"
];
$tempItem
[
"reward"
]
=
$item
[
"reward"
];
$tempItem
[
"finish_num"
]
=
$item
[
"finish_num"
];
$tempItem
[
"status"
]
=
$item
[
"status"
];
$data
[
$item
[
"date"
]][]
=
$tempItem
;
}
foreach
(
$data
as
$key
=>
$item
)
{
$rewards
=
array_column
(
$item
,
"reward"
);
$total
=
array_sum
(
$rewards
);
$res
[
$key
][
"total"
]
=
$total
/
100
;
$res
[
$key
][
"date"
]
=
$key
;
$res
[
$key
][
"data"
]
=
$item
;
foreach
(
$item
as
$k
=>
$v
)
{
$res
[
$key
][
"data"
][
$k
][
"reward"
]
=
$v
[
"reward"
]
/
100
;
}
}
}
return
array_values
(
$res
);
}
/**
* 团长分销,下单记录
* @param array $params
* @return array
*/
public
static
function
getInviteOrderRecord
(
$params
=
[])
{
$userId
=
$params
[
"user_id"
];
$lastId
=
empty
(
$params
[
"last_id"
])
?
""
:
$params
[
"last_id"
];
$limit
=
empty
(
$params
[
"page_size"
])
?
10
:
$params
[
"page_size"
];
$hour
=
date
(
"H"
);
if
(
$hour
<
10
&&
$hour
>
0
)
{
$date
=
date
(
"Y-m-d"
,
strtotime
(
"-1 day"
));
}
elseif
(
$hour
>
16
)
{
$date
=
date
(
"Y-m-d"
);
}
else
{
$date
=
date
(
"Y-m-d"
);
}
$secondDay
=
date
(
"Y-m-d"
,
strtotime
(
"
$date
+1 day"
));
$startTime
=
$date
.
" 16:00:00"
;
$endTime
=
$secondDay
.
" 10:00:00"
;
$where
=
[];
$where
[
"colonel_user_id"
]
=
$userId
;
$where
[
"create_time[>]"
]
=
$startTime
;
$where
[
"create_time[<]"
]
=
$endTime
;
$where
[
"LIMIT"
]
=
$limit
;
$where
[
"ORDER"
]
=
[
"invite_order_id"
=>
"DESC"
];
if
(
!
empty
(
$lastId
))
{
$where
[
"invite_order_id[<]"
]
=
$lastId
;
}
$list
=
ColonelDistributorInviteOrder
::
select
([
"invite_order_id"
,
"user_id"
,
"is_refund"
],
$where
,
[]);
if
(
!
empty
(
$list
))
{
$userIds
=
array_unique
(
array_column
(
$list
,
"user_id"
));
$userList
=
UserService
::
userWechatBind
([
"user_id"
=>
$userIds
]);
if
(
!
empty
(
$userList
))
{
$userList
=
array_column
(
$userList
,
null
,
"user_id"
);
}
$count
=
count
(
$list
);
foreach
(
$list
as
$key
=>
$item
)
{
if
(
!
empty
(
$userList
[
$item
[
"user_id"
]]))
{
$list
[
$key
][
"user_nick"
]
=
$userList
[
$item
[
"user_id"
]][
"user_nick"
];
$list
[
$key
][
"user_avatar"
]
=
$userList
[
$item
[
"user_id"
]][
"user_avatar"
];
}
else
{
$list
[
$key
][
"user_nick"
]
=
""
;
$list
[
$key
][
"user_avatar"
]
=
""
;
}
$lastId
=
$item
[
"invite_order_id"
];
}
if
(
$count
<
$limit
)
{
$lastId
=
"-1"
;
}
}
else
{
$lastId
=
"-1"
;
}
return
[
"list"
=>
$list
,
"last_id"
=>
$lastId
];
}
}
\ No newline at end of file
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