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
dc05741f
Commit
dc05741f
authored
Aug 31, 2021
by
pengfei
Browse files
Options
Browse Files
Download
Plain Diff
merge colonel
parents
008d19fc
b9facab0
Changes
18
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
270 additions
and
470 deletions
+270
-470
MarketingException.php
application/exception/custom/MarketingException.php
+9
-4
ColonelDistributorPayInfo.php
...tion/models/marketing/mysql/ColonelDistributorPayInfo.php
+3
-0
Colonelorder.php
application/modules/Cli/controllers/Colonelorder.php
+118
-88
Colonelwallet.php
application/modules/Cli/controllers/Colonelwallet.php
+26
-18
ColonelOrder.php
application/modules/Job/controllers/ColonelOrder.php
+16
-0
ColonelWallet.php
application/modules/Job/controllers/ColonelWallet.php
+16
-0
GoodsService.php
application/services/goods/GoodsService.php
+2
-2
ColonelService.php
application/services/marketing/ColonelService.php
+14
-14
MarketingGoodsService.php
application/services/marketing/MarketingGoodsService.php
+10
-4
MarketingService.php
application/services/marketing/MarketingService.php
+29
-10
cli.ini
conf/cli.ini
+0
-1
Colonelorder.php
daemon/Colonelorder.php
+1
-214
Colonelwallet.php
daemon/Colonelwallet.php
+2
-103
Pindan.php
daemon/Pindan.php
+8
-8
run-colonel-order.job
deploy/job/run-colonel-order.job
+2
-0
run-colonel-wallet.job
deploy/job/run-colonel-wallet.job
+3
-0
run.job
deploy/job/run.job
+2
-0
start_job.sh
deploy/start_env/start_job.sh
+9
-4
No files found.
application/exception/custom/MarketingException.php
View file @
dc05741f
...
@@ -12,7 +12,6 @@ class MarketingException extends BaseException
...
@@ -12,7 +12,6 @@ class MarketingException extends BaseException
const
LIFE_ACCOUNT_NO_EXIST
=
16
;
const
LIFE_ACCOUNT_NO_EXIST
=
16
;
const
RELATION_ALREADY_EXIST
=
17
;
const
RELATION_ALREADY_EXIST
=
17
;
const
TAKE_PLACE_NOT_EXIST
=
20
;
const
TAKE_PLACE_NOT_EXIST
=
20
;
const
COLONEL_APPLY_EXIST
=
23
;
const
COLONEL_APPLY_FAILED
=
24
;
const
COLONEL_APPLY_FAILED
=
24
;
const
COLONEL_CONFIG_NULL
=
25
;
const
COLONEL_CONFIG_NULL
=
25
;
const
COLONEL_LEVEL_SIX
=
26
;
const
COLONEL_LEVEL_SIX
=
26
;
...
@@ -22,8 +21,10 @@ class MarketingException extends BaseException
...
@@ -22,8 +21,10 @@ class MarketingException extends BaseException
const
COLONEL_TAKE_PLACE_EXIST
=
30
;
const
COLONEL_TAKE_PLACE_EXIST
=
30
;
const
COLONEL_TAKE_PLACE_PARAMS
=
31
;
const
COLONEL_TAKE_PLACE_PARAMS
=
31
;
const
COLONEL_TAKE_PLACE_FAILED
=
32
;
const
COLONEL_TAKE_PLACE_FAILED
=
32
;
const
COLONEL_AUDIT_STATUS_USE
=
34
;
const
COLONEL_ADD_FAILED
=
35
;
const
COLONEL_TAKE_PLACE_EDIT_FAILED
=
36
;
const
COLONEL_APPLY_EXIST
=
37
;
protected
$cus
=
[
protected
$cus
=
[
0
=>
'活动名称不能为空'
,
0
=>
'活动名称不能为空'
,
...
@@ -49,7 +50,7 @@ class MarketingException extends BaseException
...
@@ -49,7 +50,7 @@ class MarketingException extends BaseException
self
::
TAKE_PLACE_NOT_EXIST
=>
'自提点不存在'
,
self
::
TAKE_PLACE_NOT_EXIST
=>
'自提点不存在'
,
21
=>
"活动开始时间不能大于或者等于结束时间"
,
21
=>
"活动开始时间不能大于或者等于结束时间"
,
22
=>
"自提点不能为空"
,
22
=>
"自提点不能为空"
,
self
::
COLONEL_APPLY_EXIST
=>
'当前用户已提交团长申请
'
,
23
=>
'分润金额+手续费不能大于售价金额
'
,
self
::
COLONEL_APPLY_FAILED
=>
'团长申请失败'
,
self
::
COLONEL_APPLY_FAILED
=>
'团长申请失败'
,
self
::
COLONEL_CONFIG_NULL
=>
"团长分销配置内容不能为空"
,
self
::
COLONEL_CONFIG_NULL
=>
"团长分销配置内容不能为空"
,
self
::
COLONEL_LEVEL_SIX
=>
"档位最多设定6档"
,
self
::
COLONEL_LEVEL_SIX
=>
"档位最多设定6档"
,
...
@@ -59,6 +60,10 @@ class MarketingException extends BaseException
...
@@ -59,6 +60,10 @@ class MarketingException extends BaseException
self
::
COLONEL_TAKE_PLACE_EXIST
=>
'自提点名称已存在'
,
self
::
COLONEL_TAKE_PLACE_EXIST
=>
'自提点名称已存在'
,
self
::
COLONEL_TAKE_PLACE_PARAMS
=>
'自提点信息不存在'
,
self
::
COLONEL_TAKE_PLACE_PARAMS
=>
'自提点信息不存在'
,
self
::
COLONEL_TAKE_PLACE_FAILED
=>
'自提点添加失败'
,
self
::
COLONEL_TAKE_PLACE_FAILED
=>
'自提点添加失败'
,
self
::
COLONEL_APPLY_EXIST
=>
'当前用户已提交团长申请'
,
self
::
COLONEL_AUDIT_STATUS_USE
=>
'该团长已审核'
,
self
::
COLONEL_ADD_FAILED
=>
'团长入库失败'
,
self
::
COLONEL_TAKE_PLACE_EDIT_FAILED
=>
'修改团长自提点失败'
,
33
=>
'分润金额+手续费不能大于售价金额'
,
33
=>
'分润金额+手续费不能大于售价金额'
,
];
];
}
}
application/models/marketing/mysql/ColonelDistributorPayInfo.php
View file @
dc05741f
...
@@ -12,6 +12,9 @@ class ColonelDistributorPayInfo extends MysqlBase
...
@@ -12,6 +12,9 @@ class ColonelDistributorPayInfo extends MysqlBase
const
TYPE_NEW_USER
=
1
;
const
TYPE_NEW_USER
=
1
;
const
TYPE_FINISH_TARGET
=
2
;
const
TYPE_FINISH_TARGET
=
2
;
const
STATUS_NOT_USE
=
0
;
const
STATUS_USE
=
1
;
public
static
$typeDesc
=
[
public
static
$typeDesc
=
[
self
::
TYPE_NEW_USER
=>
"邀请新用户"
,
self
::
TYPE_NEW_USER
=>
"邀请新用户"
,
...
...
application/modules/Cli/controllers/Colonelorder.php
View file @
dc05741f
...
@@ -3,96 +3,135 @@
...
@@ -3,96 +3,135 @@
use
Api\PhpServices\Idgen\Idgen
;
use
Api\PhpServices\Idgen\Idgen
;
use
Api\PhpUtils\Log\FileLog
;
use
Api\PhpUtils\Log\FileLog
;
use
App\Base\Cli
;
use
App\Base\Cli
;
use
\App\Models\marketing\mysql\ColonelDistributorColonel
;
use
App\Models\marketing\mysql\ColonelDistributorColonel
;
use
\App\Models\marketing\mysql\ColonelDistributorInviteOrder
;
use
App\Models\marketing\mysql\ColonelDistributorConfig
;
use
\App\Models\marketing\mysql\ColonelDistributorConfig
;
use
App\Models\marketing\mysql\ColonelDistributorInviteOrderNum
;
use
\App\Models\marketing\mysql\ColonelDistributorInviteOrderNum
;
use
App\Models\marketing\mysql\ColonelDistributorPayInfo
;
use
\App\Models\marketing\mysql\ColonelDistributorPayInfo
;
use
App\Exception\custom\InterfaceException
;
use
\App\Exception\custom\InterfaceException
;
use
Api\PhpUtils\Http\HttpUtil
;
use
Api\PhpUtils\Http\HttpUtil
;
use
\
App\Models\user\mysql\UserWechatBind
;
use
App\Models\user\mysql\UserWechatBind
;
/**
/**
* php public/cli.php colonelorder index
* php public/cli.php colonelorder index
*/
*/
class
ColonelorderController
extends
Cli
class
ColonelorderController
extends
Cli
{
{
const
DEFAULT_USER_BATCH_SIZE
=
100
;
public
$today
;
public
$yesterday
;
public
$colonelConfig
;
public
$colonelConfigList
;
public
function
init
()
{
parent
::
init
();
$this
->
today
=
date
(
"Y-m-d"
);
$this
->
yesterday
=
date
(
"Y-m-d"
,
strtotime
(
"-1 day"
));
$this
->
colonelConfig
=
$this
->
getColonelConfig
(
$this
->
yesterday
);
if
(
!
empty
(
$this
->
colonelConfig
))
{
$this
->
colonelConfigList
=
json_decode
(
$this
->
colonelConfig
[
'data'
],
true
);
}
}
public
function
indexAction
()
public
function
indexAction
()
{
{
$userIdList
=
$this
->
getColonelUserIds
();
$userIdList
=
$this
->
getColonelUserIds
();
if
(
empty
(
$userIdList
)
||
empty
(
$this
->
colonelConfigList
))
{
return
true
;
}
$userIdList
=
array_chunk
(
$userIdList
,
self
::
DEFAULT_USER_BATCH_SIZE
);
$colonelPayInfoData
=
[];
foreach
(
$userIdList
as
$userIds
)
{
$batchPayInfoData
=
[];
// 完成目标单数
$batchPayInfoData
[]
=
$this
->
getInviteOrderData
(
$userIds
);
// 邀请新用户奖励
$batchPayInfoData
[]
=
$this
->
getInviteNewUserData
(
$userIds
);
$colonelPayInfoData
=
array_merge
(
$colonelPayInfoData
,
$batchPayInfoData
);
}
return
$this
->
handleSavePayInfo
(
$colonelPayInfoData
);
}
/**
* 保存奖励信息
* @param $yesterday
* @return true
*/
public
function
handleSavePayInfo
(
$colonelPayInfoData
)
{
if
(
!
empty
(
$colonelPayInfoData
))
{
$data
=
$this
->
addIdgenId
(
$colonelPayInfoData
);
try
{
ColonelDistributorPayInfo
::
beginTransaction
();
ColonelDistributorPayInfo
::
beginTransaction
();
if
(
!
empty
(
$userIdList
))
{
if
(
!
$this
->
addColonelDistributorPayInfo
(
$data
))
{
$userIdCount
=
count
(
$userIdList
);
throw
new
\Exception
(
sprintf
(
"写入错误参数 %s"
,
json_encode
(
$data
)));
}
//每次100个用户
if
(
!
ColonelDistributorPayInfo
::
commit
())
{
$length
=
1
;
throw
new
\Exception
(
sprintf
(
"事务提交失败 %s"
,
json_encode
(
$data
)));
$start
=
(
int
)
ceil
(
$userIdCount
/
$length
);
}
$insertData
=
[];
}
catch
(
\Exception
$e
)
{
for
(
$i
=
0
;
$i
<
$start
;)
{
ColonelDistributorPayInfo
::
rollback
();
$userIds
=
array_slice
(
$userIdList
,
$i
,
$length
);
FileLog
::
info
(
"add_colonel_distributor_pay_info"
,
$e
->
getMessage
());
$today
=
date
(
"Y-m-d"
);
$yesterday
=
date
(
"Y-m-d"
,
strtotime
(
"-1 day"
));
$startTime
=
$yesterday
.
" 16:00:00"
;
$endTime
=
$today
.
" 10:00:00"
;
$colonelConfig
=
$this
->
getColonelConfig
(
$yesterday
);
if
(
!
empty
(
$colonelConfig
[
"data"
]))
{
$configList
=
json_decode
(
$colonelConfig
[
"data"
],
true
);
//完成目标单数
$inviteOrderNumList
=
$this
->
getInviteOrderNum
(
$userIds
,
$yesterday
,
$today
);
foreach
(
$inviteOrderNumList
as
$orderNum
)
{
foreach
(
$configList
as
$config
)
{
if
(
!
empty
(
$orderNum
[
"num"
])
&&
$orderNum
[
"num"
]
>=
$config
[
"assess_order_num"
])
{
$payInfo
=
[
"colonel_user_id"
=>
$orderNum
[
"colonel_user_id"
],
"date"
=>
$yesterday
,
"type"
=>
ColonelDistributorPayInfo
::
TYPE_FINISH_TARGET
,
"reward"
=>
$config
[
"reward_amount"
]
*
100
,
"finish_num"
=>
$config
[
"assess_order_num"
],
"invite_user_id"
=>
0
,
"invite_user_nick"
=>
""
,
];
$insertData
[]
=
$payInfo
;
}
}
}
}
return
true
;
}
}
//新用户奖励
$inviteNewUserList
=
$this
->
getInviteNewUserList
(
$userIds
,
$today
);
/**
* 获取新用户奖励
* @param $yesterday
* @return array
*/
public
function
getInviteNewUserData
(
$userIds
)
{
$inviteNewUserList
=
$this
->
getInviteNewUserList
(
$userIds
,
$this
->
today
);
$inviteOrderData
=
[];
if
(
!
empty
(
$inviteNewUserList
))
{
if
(
!
empty
(
$inviteNewUserList
))
{
$colonelUserIds
=
array_column
(
$inviteNewUserList
,
"user_id"
);
$userNickList
=
$this
->
getUserList
(
array_column
(
$inviteNewUserList
,
"user_id"
));
$userNickList
=
$this
->
getUserList
(
$colonelUserIds
);
foreach
(
$inviteNewUserList
as
$newUser
)
{
foreach
(
$inviteNewUserList
as
$newUser
)
{
$payInfo
=
[
$payInfo
=
[
"colonel_user_id"
=>
$newUser
[
"inviter_user_id"
],
"colonel_user_id"
=>
$newUser
[
"inviter_user_id"
],
"date"
=>
$
yesterday
,
"date"
=>
$this
->
yesterday
,
"type"
=>
ColonelDistributorPayInfo
::
TYPE_NEW_USER
,
"type"
=>
ColonelDistributorPayInfo
::
TYPE_NEW_USER
,
"reward"
=>
5
*
100
,
"reward"
=>
3
*
100
,
"finish_num"
=>
1
,
"finish_num"
=>
1
,
"invite_user_id"
=>
$newUser
[
"user_id"
],
"invite_user_id"
=>
$newUser
[
"user_id"
],
"invite_user_nick"
=>
empty
(
$userNickList
[
$newUser
[
"user_id"
]][
"user_nick"
])
?
""
:
$userNickList
[
$newUser
[
"user_id"
]][
"user_nick"
],
"invite_user_nick"
=>
empty
(
$userNickList
[
$newUser
[
"user_id"
]][
"user_nick"
])
?
""
:
$userNickList
[
$newUser
[
"user_id"
]][
"user_nick"
],
];
];
$insertData
[]
=
$payInfo
;
$inviteOrderData
[]
=
$payInfo
;
}
}
}
}
}
return
$inviteOrderData
;
$i
=
$i
+
$length
;
}
}
if
(
!
empty
(
$insertData
))
{
/**
$data
=
$this
->
addIdgenId
(
$insertData
);
* 获取完成目标单数奖励
$res
=
$this
->
addColonelDistributorPayInfo
(
$data
);
* @param $yesterday
if
(
$res
===
false
)
{
* @return array
ColonelDistributorPayInfo
::
rollback
();
*/
FileLog
::
info
(
"add_colonel_distributor_pay_info"
,
sprintf
(
"写入错误参数 %s"
,
json_encode
(
$data
)));
public
function
getInviteOrderData
(
$userIds
)
}
{
//完成目标单数
$inviteOrderNumList
=
$this
->
getInviteOrderNum
(
$userIds
,
$this
->
yesterday
,
$this
->
today
);
$inviteOrderData
=
[];
foreach
(
$inviteOrderNumList
as
$orderNum
)
{
foreach
(
$this
->
colonelConfigList
as
$config
)
{
if
(
!
empty
(
$orderNum
[
"num"
])
&&
$orderNum
[
"num"
]
>=
$config
[
"assess_order_num"
])
{
$payInfo
=
[
"colonel_user_id"
=>
$orderNum
[
"colonel_user_id"
],
"date"
=>
$this
->
yesterday
,
"type"
=>
ColonelDistributorPayInfo
::
TYPE_FINISH_TARGET
,
"reward"
=>
$config
[
"reward_amount"
]
*
100
,
"finish_num"
=>
$config
[
"assess_order_num"
],
"invite_user_id"
=>
0
,
"invite_user_nick"
=>
""
,
];
$inviteOrderData
[]
=
$payInfo
;
}
}
}
}
if
(
!
ColonelDistributorPayInfo
::
commit
())
{
ColonelDistributorPayInfo
::
rollback
();
}
}
return
$inviteOrderData
;
}
}
/**
/**
...
@@ -128,17 +167,6 @@ class ColonelorderController extends Cli
...
@@ -128,17 +167,6 @@ class ColonelorderController extends Cli
return
$userIds
;
return
$userIds
;
}
}
public
function
getInviteOrder
(
$colonelUserIds
,
$startTime
,
$endTime
)
{
return
ColonelDistributorInviteOrder
::
select
([
"colonel_user_id"
,
"user_id"
,
"is_refund"
,
"create_time"
],
[
"colonel_user_id"
=>
$colonelUserIds
,
"create_time[>=]"
=>
$startTime
,
"create_time[<=]"
=>
$endTime
,
"is_refund"
=>
0
,
],
[]);
}
/**
/**
* 获取order num
* 获取order num
* @param $colonelUserIds
* @param $colonelUserIds
...
@@ -148,12 +176,15 @@ class ColonelorderController extends Cli
...
@@ -148,12 +176,15 @@ class ColonelorderController extends Cli
*/
*/
public
function
getInviteOrderNum
(
$colonelUserIds
,
$startTime
,
$endTime
)
public
function
getInviteOrderNum
(
$colonelUserIds
,
$startTime
,
$endTime
)
{
{
return
ColonelDistributorInviteOrderNum
::
select
([
"colonel_user_id"
,
"num"
,
"date"
],
return
ColonelDistributorInviteOrderNum
::
select
(
[
"colonel_user_id"
,
"num"
,
"date"
],
[
[
"colonel_user_id"
=>
$colonelUserIds
,
"colonel_user_id"
=>
$colonelUserIds
,
"date[>=]"
=>
$startTime
,
"date[>=]"
=>
$startTime
,
"date[<=]"
=>
$endTime
,
"date[<=]"
=>
$endTime
,
],
[]);
],
[]
);
}
}
/**
/**
...
@@ -221,5 +252,4 @@ class ColonelorderController extends Cli
...
@@ -221,5 +252,4 @@ class ColonelorderController extends Cli
{
{
return
ColonelDistributorPayInfo
::
save
(
$data
);
return
ColonelDistributorPayInfo
::
save
(
$data
);
}
}
}
}
application/modules/Cli/controllers/Colonelwallet.php
View file @
dc05741f
<?php
<?php
use
Api\PhpServices\Idgen\Idgen
;
use
Api\PhpUtils\Log\FileLog
;
use
Api\PhpUtils\Log\FileLog
;
use
App\Base\Cli
;
use
App\Base\Cli
;
use
\App\Models\marketing\mysql\ColonelDistributorColonel
;
use
App\Models\marketing\mysql\ColonelDistributorPayInfo
;
use
\App\Models\marketing\mysql\ColonelDistributorInviteOrder
;
use
App\Exception\custom\InterfaceException
;
use
\App\Models\marketing\mysql\ColonelDistributorConfig
;
use
\App\Models\marketing\mysql\ColonelDistributorInviteOrderNum
;
use
\App\Models\marketing\mysql\ColonelDistributorPayInfo
;
use
\App\Exception\custom\InterfaceException
;
use
Api\PhpUtils\Http\HttpUtil
;
use
Api\PhpUtils\Http\HttpUtil
;
use
\App\Models\user\mysql\UserWechatBind
;
/**
/**
* php public/cli.php colonelwallet index
* php public/cli.php colonelwallet index
...
@@ -19,18 +13,15 @@ class ColonelwalletController extends Cli
...
@@ -19,18 +13,15 @@ class ColonelwalletController extends Cli
{
{
public
function
indexAction
()
public
function
indexAction
()
{
{
// $today = date("Y-m-d");
$yesterday
=
date
(
"Y-m-d"
,
strtotime
(
"-1 day"
));
$yesterday
=
date
(
"Y-m-d"
,
strtotime
(
"-1 day"
));
$payInfoList
=
$this
->
getPayInfo
(
$yesterday
);
$payInfoList
=
$this
->
getPayInfo
(
$yesterday
);
if
(
!
empty
(
$payInfoList
))
{
if
(
!
empty
(
$payInfoList
))
{
$res
=
$this
->
toWallet
(
$payInfoList
);
if
(
$this
->
toWallet
(
$payInfoList
))
{
if
(
$res
)
{
if
(
$this
->
deductingInventory
(
$payInfoList
))
{
$this
->
deductingInventory
(
$payInfoList
);
$this
->
handlePayInfoStatus
(
array_column
(
$payInfoList
,
'colonel_distributor_pay_info_id'
));
}
}
}
}
}
}
}
/**
/**
...
@@ -40,7 +31,7 @@ class ColonelwalletController extends Cli
...
@@ -40,7 +31,7 @@ class ColonelwalletController extends Cli
*/
*/
public
function
getPayInfo
(
$date
)
public
function
getPayInfo
(
$date
)
{
{
$list
=
ColonelDistributorPayInfo
::
select
(
"*"
,
[
"date"
=>
$date
],
[]);
$list
=
ColonelDistributorPayInfo
::
select
(
"*"
,
[
"date"
=>
$date
,
'status'
=>
ColonelDistributorPayInfo
::
STATUS_NOT_USE
],
[]);
$data
=
[];
$data
=
[];
if
(
!
empty
(
$list
))
{
if
(
!
empty
(
$list
))
{
foreach
(
$list
as
$item
)
{
foreach
(
$list
as
$item
)
{
...
@@ -106,13 +97,22 @@ class ColonelwalletController extends Cli
...
@@ -106,13 +97,22 @@ class ColonelwalletController extends Cli
$data
[
"capital_pool_id"
]
=
2
;
$data
[
"capital_pool_id"
]
=
2
;
foreach
(
$payInfoList
as
$payInfo
)
{
foreach
(
$payInfoList
as
$payInfo
)
{
if
(
$payInfo
[
"type"
]
==
ColonelDistributorPayInfo
::
TYPE_NEW_USER
)
{
$desc
=
"邀请新用户("
.
$payInfo
[
"invite_user_nick"
]
.
")完成下单奖励"
;
}
if
(
$payInfo
[
"type"
]
==
ColonelDistributorPayInfo
::
TYPE_FINISH_TARGET
)
{
$desc
=
"完成"
.
$payInfo
[
"finish_num"
]
.
"单用户下单奖励"
;
}
$tmp
=
[];
$tmp
=
[];
$tmp
[
"op"
]
=
200
;
//200:团长奖励
$tmp
[
"op"
]
=
200
;
//200:团长奖励
$tmp
[
"user_id"
]
=
$payInfo
[
"colonel_user_id"
];
$tmp
[
"user_id"
]
=
$payInfo
[
"colonel_user_id"
];
$tmp
[
"amount"
]
=
$payInfo
[
"reward"
];
$tmp
[
"amount"
]
=
$payInfo
[
"reward"
];
$tmp
[
"third_order_id"
]
=
$payInfo
[
"colonel_distributor_pay_info_id"
];
$tmp
[
"third_order_id_type"
]
=
$payInfo
[
"type"
];
$tmp
[
"third_order_desc"
]
=
$desc
;
$data
[
"body"
][]
=
$tmp
;
$data
[
"body"
][]
=
$tmp
;
}
}
$res
=
HttpUtil
::
post
(
$url
,
$data
);
$res
=
HttpUtil
::
post
(
$url
,
$data
,
100000
,
3
);
if
(
$res
[
'code'
]
==
0
&&
isset
(
$res
[
'response'
][
"result"
]))
{
if
(
$res
[
'code'
]
==
0
&&
isset
(
$res
[
'response'
][
"result"
]))
{
$date
=
date
(
"Y-m-d H:i:s"
);
$date
=
date
(
"Y-m-d H:i:s"
);
FileLog
::
info
(
"colonel_distributor_deducting_inventory"
,
$date
.
" 资金池授予用户奖励成功"
);
FileLog
::
info
(
"colonel_distributor_deducting_inventory"
,
$date
.
" 资金池授予用户奖励成功"
);
...
@@ -123,4 +123,12 @@ class ColonelwalletController extends Cli
...
@@ -123,4 +123,12 @@ class ColonelwalletController extends Cli
return
false
;
return
false
;
}
}
}
}
/**
* 修改状态
*/
public
function
handlePayInfoStatus
(
array
$payInfoIds
)
{
return
ColonelDistributorPayInfo
::
updateRecord
([
'status'
=>
ColonelDistributorPayInfo
::
STATUS_USE
],
[
'id'
=>
$payInfoIds
]);
}
}
}
application/modules/Job/controllers/ColonelOrder.php
0 → 100644
View file @
dc05741f
<?php
/**
* Created by PhpStorm.
* User: pengfei@yidian-inc.com
* Date: 2021/8/31 1:36 下午
*/
use
App\Base\Job
;
class
ColonelOrderController
extends
Job
{
public
function
indexAction
()
{
\Yaf\Application
::
app
()
->
bootstrap
()
->
getDispatcher
()
->
dispatch
(
new
\Yaf\Request\Simple
(
''
,
'cli'
,
'colonelorder'
,
'index'
,
[]));
}
}
\ No newline at end of file
application/modules/Job/controllers/ColonelWallet.php
0 → 100644
View file @
dc05741f
<?php
/**
* Created by PhpStorm.
* User: pengfei@yidian-inc.com
* Date: 2021/8/31 2:28 下午
*/
use
App\Base\Job
;
class
ColonelWalletController
extends
Job
{
public
function
indexAction
()
{
\Yaf\Application
::
app
()
->
bootstrap
()
->
getDispatcher
()
->
dispatch
(
new
\Yaf\Request\Simple
(
''
,
'cli'
,
'colonelwallet'
,
'index'
,
[]));
}
}
\ No newline at end of file
application/services/goods/GoodsService.php
View file @
dc05741f
...
@@ -884,7 +884,7 @@ class GoodsService
...
@@ -884,7 +884,7 @@ class GoodsService
if
(
$marketing
[
"commission_mode"
]
==
Marketing
::
COMMISSION_MODE_RATE
)
{
if
(
$marketing
[
"commission_mode"
]
==
Marketing
::
COMMISSION_MODE_RATE
)
{
$commissionTotal
=
(
$marketing
[
"first_commission_value"
]
+
$marketing
[
"second_commission_value"
])
/
10000
*
$price
;
$commissionTotal
=
(
$marketing
[
"first_commission_value"
]
+
$marketing
[
"second_commission_value"
])
/
10000
*
$price
;
if
(
$price
<
(
$commissionTotal
+
$chargeFee
))
{
if
(
$price
<
(
$commissionTotal
+
$chargeFee
))
{
throw
new
MarketingException
([
'cus'
=>
2
3
]);
throw
new
MarketingException
([
'cus'
=>
3
3
]);
}
}
}
}
...
@@ -892,7 +892,7 @@ class GoodsService
...
@@ -892,7 +892,7 @@ class GoodsService
if
(
$marketing
[
"commission_mode"
]
==
Marketing
::
COMMISSION_MODE_FIXED
)
{
if
(
$marketing
[
"commission_mode"
]
==
Marketing
::
COMMISSION_MODE_FIXED
)
{
$commissionTotal
=
(
$marketing
[
"first_commission_value"
]
+
$marketing
[
"second_commission_value"
]);
$commissionTotal
=
(
$marketing
[
"first_commission_value"
]
+
$marketing
[
"second_commission_value"
]);
if
(
$price
<
(
$commissionTotal
+
$chargeFee
))
{
if
(
$price
<
(
$commissionTotal
+
$chargeFee
))
{
throw
new
MarketingException
([
'cus'
=>
2
3
]);
throw
new
MarketingException
([
'cus'
=>
3
3
]);
}
}
}
}
}
}
...
...
application/services/marketing/ColonelService.php
View file @
dc05741f
...
@@ -61,10 +61,10 @@ class ColonelService
...
@@ -61,10 +61,10 @@ class ColonelService
* Notes: 查看用户是否已申请
* Notes: 查看用户是否已申请
* User: pengfei@yidian-inc.com
* User: pengfei@yidian-inc.com
* Date: 2021/8/25 11:42 上午
* Date: 2021/8/25 11:42 上午
* @param
int
$userId
* @param $userId
* @return array
* @return array
*/
*/
public
static
function
isApply
(
int
$userId
)
:
array
public
static
function
isApply
(
$userId
)
:
array
{
{
$applyInfo
=
ColonelDistributorColonelApply
::
getRecord
([
'user_id'
=>
$userId
],
[
'colonel_apply_id'
,
'audit_status'
]);
$applyInfo
=
ColonelDistributorColonelApply
::
getRecord
([
'user_id'
=>
$userId
],
[
'colonel_apply_id'
,
'audit_status'
]);
return
[
return
[
...
@@ -136,12 +136,12 @@ class ColonelService
...
@@ -136,12 +136,12 @@ class ColonelService
* Notes: 团长申请审核
* Notes: 团长申请审核
* User: pengfei@yidian-inc.com
* User: pengfei@yidian-inc.com
* Date: 2021/8/23 1:54 下午
* Date: 2021/8/23 1:54 下午
* @param
int
$applyId
* @param $applyId
* @param
int
$auditStatus
* @param $auditStatus
* @return bool
* @return bool
* @throws MarketingException
* @throws MarketingException
*/
*/
public
static
function
handleManageAudit
(
int
$applyId
,
int
$auditStatus
)
:
bool
public
static
function
handleManageAudit
(
$applyId
,
$auditStatus
)
:
bool
{
{
// 审核状态参数检测
// 审核状态参数检测
if
(
!
in_array
(
$auditStatus
,
[
ColonelDistributorColonelApply
::
STATUS_PASS
,
ColonelDistributorColonelApply
::
STATUS_REJECT
]))
{
if
(
!
in_array
(
$auditStatus
,
[
ColonelDistributorColonelApply
::
STATUS_PASS
,
ColonelDistributorColonelApply
::
STATUS_REJECT
]))
{
...
@@ -150,7 +150,7 @@ class ColonelService
...
@@ -150,7 +150,7 @@ class ColonelService
// 审核状态数据检测
// 审核状态数据检测
$applyInfo
=
ColonelDistributorColonelApply
::
getRecord
([
'colonel_apply_id'
=>
$applyId
]);
$applyInfo
=
ColonelDistributorColonelApply
::
getRecord
([
'colonel_apply_id'
=>
$applyId
]);
if
(
empty
(
$applyInfo
)
||
$applyInfo
[
'audit_status'
]
!=
ColonelDistributorColonelApply
::
STATUS_AUDIT
)
{
if
(
empty
(
$applyInfo
)
||
$applyInfo
[
'audit_status'
]
!=
ColonelDistributorColonelApply
::
STATUS_AUDIT
)
{
throw
new
MarketingException
(
MarketingException
::
COLONEL_AUDIT_STATUS
);
throw
new
MarketingException
(
MarketingException
::
COLONEL_AUDIT_STATUS
_USE
);
}
}
try
{
try
{
ColonelDistributorColonelApply
::
beginTransaction
();
ColonelDistributorColonelApply
::
beginTransaction
();
...
@@ -162,16 +162,16 @@ class ColonelService
...
@@ -162,16 +162,16 @@ class ColonelService
// 审核成功
// 审核成功
if
(
$auditStatus
==
ColonelDistributorColonelApply
::
STATUS_PASS
)
{
if
(
$auditStatus
==
ColonelDistributorColonelApply
::
STATUS_PASS
)
{
if
(
!
self
::
handleAuditSuccess
((
array
)
$applyInfo
))
{
if
(
!
self
::
handleAuditSuccess
((
array
)
$applyInfo
))
{
throw
new
MarketingException
(
MarketingException
::
COLONEL_A
UDIT_STATUS
_FAILED
);
throw
new
MarketingException
(
MarketingException
::
COLONEL_A
DD
_FAILED
);
}
}
}
}
if
(
!
ColonelDistributorColonelApply
::
commit
())
{
if
(
!
ColonelDistributorColonelApply
::
commit
())
{
throw
new
MarketingException
(
MarketingException
::
CO
LONEL_AUDIT_STATUS_FAILED
);
throw
new
MarketingException
(
MarketingException
::
CO
MMIT_ERROR
);
}
}
return
true
;
return
true
;
}
catch
(
MarketingException
$e
)
{
}
catch
(
MarketingException
$e
)
{
ColonelDistributorColonelApply
::
rollback
();
ColonelDistributorColonelApply
::
rollback
();
throw
new
MarketingException
(
MarketingException
::
COLONEL_AUDIT_STATUS_FAILED
);
throw
new
MarketingException
(
$e
->
getCode
()
);
}
}
}
}
...
@@ -179,10 +179,10 @@ class ColonelService
...
@@ -179,10 +179,10 @@ class ColonelService
* Notes: 获取自提点信息
* Notes: 获取自提点信息
* User: pengfei@yidian-inc.com
* User: pengfei@yidian-inc.com
* Date: 2021/8/24 2:40 下午
* Date: 2021/8/24 2:40 下午
* @param
int
$applyId
* @param $applyId
* @return array
* @return array
*/
*/
public
static
function
getTakePlaceInfo
(
int
$applyId
)
:
array
public
static
function
getTakePlaceInfo
(
$applyId
)
:
array
{
{
$where
=
[
$where
=
[
'colonel_apply_id'
=>
$applyId
'colonel_apply_id'
=>
$applyId
...
@@ -222,15 +222,15 @@ class ColonelService
...
@@ -222,15 +222,15 @@ class ColonelService
}
}
// 修改自提点id
// 修改自提点id
if
(
!
ColonelDistributorColonel
::
updateRecord
([
'take_place_id'
=>
$takePlaceId
],
$where
))
{
if
(
!
ColonelDistributorColonel
::
updateRecord
([
'take_place_id'
=>
$takePlaceId
],
$where
))
{
throw
new
MarketingException
(
MarketingException
::
COLONEL_TAKE_PLACE_FAILED
);
throw
new
MarketingException
(
MarketingException
::
COLONEL_TAKE_PLACE_
EDIT_
FAILED
);
}
}
if
(
!
ColonelDistributorColonel
::
commit
())
{
if
(
!
ColonelDistributorColonel
::
commit
())
{
throw
new
MarketingException
(
MarketingException
::
CO
LONEL_TAKE_PLACE_FAILED
);
throw
new
MarketingException
(
MarketingException
::
CO
MMIT_ERROR
);
}
}
return
(
int
)
$takePlaceId
;
return
(
int
)
$takePlaceId
;
}
catch
(
MarketingException
$e
)
{
}
catch
(
MarketingException
$e
)
{
ColonelDistributorColonel
::
rollback
();
ColonelDistributorColonel
::
rollback
();
throw
new
MarketingException
(
MarketingException
::
COLONEL_TAKE_PLACE_FAILED
);
throw
new
MarketingException
(
$e
->
getCode
()
);
}
}
}
}
...
...
application/services/marketing/MarketingGoodsService.php
View file @
dc05741f
...
@@ -82,8 +82,11 @@ class MarketingGoodsService
...
@@ -82,8 +82,11 @@ class MarketingGoodsService
$goodsSkuId
=
array_column
(
$data
,
'goods_sku_id'
);
$goodsSkuId
=
array_column
(
$data
,
'goods_sku_id'
);
}
}
$goodsSkuList
=
[];
if
(
!
empty
(
$goodsSkuId
))
{
$goodsSkuList
=
GoodsSku
::
getRecordMaster
([
'goods_sku_id'
=>
$goodsSkuId
]);
$goodsSkuList
=
GoodsSku
::
getRecordMaster
([
'goods_sku_id'
=>
$goodsSkuId
]);
$goodsSkuList
=
!
empty
(
$goodsSkuList
)
?
array_column
(
$goodsSkuList
,
null
,
'goods_sku_id'
)
:
[];
$goodsSkuList
=
!
empty
(
$goodsSkuList
)
?
array_column
(
$goodsSkuList
,
null
,
'goods_sku_id'
)
:
[];
}
$lastData
=
end
(
$data
);
$lastData
=
end
(
$data
);
$lastId
=
!
empty
(
$lastData
[
'id'
])
?
$lastData
[
'id'
]
:
''
;
$lastId
=
!
empty
(
$lastData
[
'id'
])
?
$lastData
[
'id'
]
:
''
;
...
@@ -92,8 +95,11 @@ class MarketingGoodsService
...
@@ -92,8 +95,11 @@ class MarketingGoodsService
$shopId
[
$key
]
=
!
empty
(
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'shop_id'
])
?
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'shop_id'
]
:
''
;
$shopId
[
$key
]
=
!
empty
(
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'shop_id'
])
?
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'shop_id'
]
:
''
;
}
}
$subShopList
=
[];
if
(
!
empty
(
$shopId
))
{
$subShopList
=
SubShop
::
getRecordMaster
([
'shop_id'
=>
$shopId
]);
$subShopList
=
SubShop
::
getRecordMaster
([
'shop_id'
=>
$shopId
]);
$subShopList
=
!
empty
(
$subShopList
)
?
array_column
(
$subShopList
,
null
,
'shop_id'
)
:
[];
$subShopList
=
!
empty
(
$subShopList
)
?
array_column
(
$subShopList
,
null
,
'shop_id'
)
:
[];
}
$marketingList
=
!
empty
(
$marketingList
)
?
array_column
(
$marketingList
,
null
,
'marketing_id'
)
:
[];
$marketingList
=
!
empty
(
$marketingList
)
?
array_column
(
$marketingList
,
null
,
'marketing_id'
)
:
[];
...
...
application/services/marketing/MarketingService.php
View file @
dc05741f
...
@@ -552,7 +552,7 @@ class MarketingService
...
@@ -552,7 +552,7 @@ class MarketingService
if
(
$commissionMode
==
Marketing
::
COMMISSION_MODE_RATE
)
{
if
(
$commissionMode
==
Marketing
::
COMMISSION_MODE_RATE
)
{
$commissionTotal
=
(
$firstCommissionRate
+
$secondCommissionRate
)
/
10000
*
$price
;
$commissionTotal
=
(
$firstCommissionRate
+
$secondCommissionRate
)
/
10000
*
$price
;
if
(
$price
<
(
$commissionTotal
+
$chargeFee
))
{
if
(
$price
<
(
$commissionTotal
+
$chargeFee
))
{
throw
new
MarketingException
([
'cus'
=>
2
3
]);
throw
new
MarketingException
([
'cus'
=>
3
3
]);
}
}
}
}
...
@@ -560,7 +560,7 @@ class MarketingService
...
@@ -560,7 +560,7 @@ class MarketingService
if
(
$commissionMode
==
Marketing
::
COMMISSION_MODE_FIXED
)
{
if
(
$commissionMode
==
Marketing
::
COMMISSION_MODE_FIXED
)
{
$commissionTotal
=
(
$firstCommissionRate
+
$secondCommissionRate
);
$commissionTotal
=
(
$firstCommissionRate
+
$secondCommissionRate
);
if
(
$price
<
(
$commissionTotal
+
$chargeFee
))
{
if
(
$price
<
(
$commissionTotal
+
$chargeFee
))
{
throw
new
MarketingException
([
'cus'
=>
2
3
]);
throw
new
MarketingException
([
'cus'
=>
3
3
]);
}
}
}
}
}
}
...
@@ -826,11 +826,16 @@ class MarketingService
...
@@ -826,11 +826,16 @@ class MarketingService
}
}
}
}
$marketingGoods
=
[];
$marketingGoods
=
[];
foreach
(
$skuInfoList
as
$key
=>
$skuInfo
)
{
$tempSkuInfoList
=
array_column
(
$skuInfoList
,
null
,
"goods_sku_id"
);
$marketingGoods
[
$key
][
"goods_spu_id"
]
=
$skuInfo
[
"goods_spu_id"
];
foreach
(
$goodsSkuId
as
$key
=>
$skuId
)
{
$marketingGoods
[
$key
][
"goods_sku_id"
]
=
$skuInfo
[
"goods_sku_id"
];
if
(
empty
(
$tempSkuInfoList
[
$skuId
][
"goods_spu_id"
]))
{
continue
;
}
$marketingGoods
[
$key
][
"goods_spu_id"
]
=
$tempSkuInfoList
[
$skuId
][
"goods_spu_id"
];
$marketingGoods
[
$key
][
"goods_sku_id"
]
=
$skuId
;
$marketingGoods
[
$key
][
"marketing_id"
]
=
$marketingId
;
$marketingGoods
[
$key
][
"marketing_id"
]
=
$marketingId
;
}
}
MarketingGoods
::
save
(
$marketingGoods
);
MarketingGoods
::
save
(
$marketingGoods
);
//自提点
//自提点
...
@@ -989,10 +994,9 @@ class MarketingService
...
@@ -989,10 +994,9 @@ class MarketingService
$pindanMarketing
=
MarketingPindan
::
getRecord
([
'marketing_id'
=>
$params
[
'marketing_id'
]]);
$pindanMarketing
=
MarketingPindan
::
getRecord
([
'marketing_id'
=>
$params
[
'marketing_id'
]]);
$lifeAccountList
=
CommonService
::
getlifeAccountList
([
'life_account_id'
=>
[
$pindanMarketing
[
"publish_life_account_id"
]]]);
$lifeAccountList
=
CommonService
::
getlifeAccountList
([
'life_account_id'
=>
[
$pindanMarketing
[
"publish_life_account_id"
]]]);
$goodsSkuList
=
MarketingGoods
::
marketingGoodsList
([
'marketing_id'
=>
$params
[
'marketing_id'
]]);
$marketingGoodsList
=
MarketingGoods
::
marketingGoodsList
([
'marketing_id'
=>
$params
[
'marketing_id'
],
"ORDER"
=>
[
"id"
=>
"ASC"
]]);
if
(
!
empty
(
$marketingGoodsList
))
{
if
(
!
empty
(
$goodsSkuList
))
{
$goodsSkuId
=
array_column
(
$marketingGoodsList
,
'goods_sku_id'
);
$goodsSkuId
=
array_column
(
$goodsSkuList
,
'goods_sku_id'
);
$goodsSkuList
=
PindanGoodsSku
::
select
(
'*'
,
[
'goods_sku_id'
=>
$goodsSkuId
]);
$goodsSkuList
=
PindanGoodsSku
::
select
(
'*'
,
[
'goods_sku_id'
=>
$goodsSkuId
]);
}
}
empty
(
$goodsSkuList
)
&&
$goodsSkuList
=
[];
empty
(
$goodsSkuList
)
&&
$goodsSkuList
=
[];
...
@@ -1046,7 +1050,14 @@ class MarketingService
...
@@ -1046,7 +1050,14 @@ class MarketingService
$otasData
[
$item
[
"ota_id"
]]
=
$item
;
$otasData
[
$item
[
"ota_id"
]]
=
$item
;
}
}
foreach
(
$goodsSkuList
as
$key
=>
$item
)
{
//这里是为了排序,按查 marketing_goods 出来的顺序排序
$tempGoodsSkuList
=
array_column
(
$goodsSkuList
,
null
,
"goods_sku_id"
);
foreach
(
$marketingGoodsList
as
$key
=>
$value
)
{
if
(
empty
(
$tempGoodsSkuList
[
$value
[
"goods_sku_id"
]]))
{
continue
;
}
$item
=
$tempGoodsSkuList
[
$value
[
"goods_sku_id"
]];
$goodsSkuList
[
$key
]
=
$item
;
$goodsSkuList
[
$key
][
"desc_pic_url_list"
]
=
GoodsService
::
getUrlList
(
$item
[
"desc_pic_url"
]);
$goodsSkuList
[
$key
][
"desc_pic_url_list"
]
=
GoodsService
::
getUrlList
(
$item
[
"desc_pic_url"
]);
$goodsSkuList
[
$key
][
"ota_name"
]
=
empty
(
$otasData
[
$item
[
"ota_id"
]][
"ota_name"
])
?
""
:
$otasData
[
$item
[
"ota_id"
]][
"ota_name"
];
$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
][
"original_price"
]
=
empty
(
$item
[
"original_price"
])
?
''
:
sprintf
(
"%.2f"
,
(
int
)
$item
[
"original_price"
]
/
100
);
...
@@ -1065,6 +1076,14 @@ class MarketingService
...
@@ -1065,6 +1076,14 @@ class MarketingService
$goodsSkuList
[
$key
][
"all_have_buy_goods_count"
]
=
$allHaveBuyGoodsStatistics
[
$item
[
"goods_sku_id"
]];
$goodsSkuList
[
$key
][
"all_have_buy_goods_count"
]
=
$allHaveBuyGoodsStatistics
[
$item
[
"goods_sku_id"
]];
}
}
}
}
foreach
(
$goodsSkuList
as
$key
=>
$item
)
{
if
(
$item
[
"inventory_rest"
]
==
0
)
{
unset
(
$goodsSkuList
[
$key
]);
array_push
(
$goodsSkuList
,
$item
);
}
}
$goodsSkuList
=
array_values
(
$goodsSkuList
);
}
}
$takePlaceIds
=
MarketingTakePlace
::
getRecords
([
"marketing_id"
=>
$marketingData
[
"id"
]],
[
"take_place_id"
]);
$takePlaceIds
=
MarketingTakePlace
::
getRecords
([
"marketing_id"
=>
$marketingData
[
"id"
]],
[
"take_place_id"
]);
...
...
conf/cli.ini
View file @
dc05741f
...
@@ -5,7 +5,6 @@ application.bootstrap = APPLICATION_PATH"/application/Boot
...
@@ -5,7 +5,6 @@ application.bootstrap = APPLICATION_PATH"/application/Boot
application.dispatcher.catchException
=
false
application.dispatcher.catchException
=
false
application.dispatcher.throwException
=
false
application.dispatcher.throwException
=
false
daemon.script_dir
=
"
\\
Daemon
\\
"
daemon.script_dir
=
"
\\
Daemon
\\
"
job.script_dir
=
"
\\
Job
\\
"
appid
=
"goods"
appid
=
"goods"
idgen.partner
=
"bp"
idgen.partner
=
"bp"
...
...
daemon/Colonelorder.php
View file @
dc05741f
<?php
<?php
namespace
Daemon
;
namespace
Daemon
;
use
Api\PhpServices\Daemon\DaemonServiceInterface
;
use
Api\PhpServices\Daemon\DaemonServiceInterface
;
use
Api\PhpServices\Idgen\Idgen
;
use
Api\PhpUtils\Log\FileLog
;
use
\App\Models\marketing\mysql\ColonelDistributorColonel
;
use
\App\Models\marketing\mysql\ColonelDistributorInviteOrder
;
use
\App\Models\marketing\mysql\ColonelDistributorConfig
;
use
\App\Models\marketing\mysql\ColonelDistributorInviteOrderNum
;
use
\App\Models\marketing\mysql\ColonelDistributorPayInfo
;
use
\App\Exception\custom\InterfaceException
;
use
Api\PhpUtils\Http\HttpUtil
;
use
\App\Models\user\mysql\UserWechatBind
;
class
Colonelorder
implements
DaemonServiceInterface
class
Colonelorder
implements
DaemonServiceInterface
{
{
...
@@ -25,208 +13,7 @@ class Colonelorder implements DaemonServiceInterface
...
@@ -25,208 +13,7 @@ class Colonelorder implements DaemonServiceInterface
sleep
(
5
);
sleep
(
5
);
return
false
;
return
false
;
}
}
\Yaf\Application
::
app
()
->
bootstrap
()
->
getDispatcher
()
->
dispatch
(
new
\Yaf\Request\Simple
(
''
,
'cli'
,
'colonelorder'
,
'index'
,
[]));
$userIdList
=
$this
->
getColonelUserIds
();
ColonelDistributorPayInfo
::
beginTransaction
();
if
(
!
empty
(
$userIdList
))
{
$userIdCount
=
count
(
$userIdList
);
//每次100个用户
$length
=
1
;
$start
=
(
int
)
ceil
(
$userIdCount
/
$length
);
$insertData
=
[];
for
(
$i
=
0
;
$i
<
$start
;)
{
$userIds
=
array_slice
(
$userIdList
,
$i
,
$length
);
$today
=
date
(
"Y-m-d"
);
$yesterday
=
date
(
"Y-m-d"
,
strtotime
(
"-1 day"
));
$startTime
=
$yesterday
.
" 16:00:00"
;
$endTime
=
$today
.
" 10:00:00"
;
$colonelConfig
=
$this
->
getColonelConfig
(
$yesterday
);
if
(
!
empty
(
$colonelConfig
[
"data"
]))
{
$configList
=
json_decode
(
$colonelConfig
[
"data"
],
true
);
//完成目标单数
$inviteOrderNumList
=
$this
->
getInviteOrderNum
(
$userIds
,
$yesterday
,
$today
);
foreach
(
$inviteOrderNumList
as
$orderNum
)
{
foreach
(
$configList
as
$config
)
{
if
(
!
empty
(
$orderNum
[
"num"
])
&&
$orderNum
[
"num"
]
>=
$config
[
"assess_order_num"
])
{
$payInfo
=
[
"colonel_user_id"
=>
$orderNum
[
"colonel_user_id"
],
"date"
=>
$yesterday
,
"type"
=>
ColonelDistributorPayInfo
::
TYPE_FINISH_TARGET
,
"reward"
=>
$config
[
"reward_amount"
]
*
100
,
"finish_num"
=>
$config
[
"assess_order_num"
],
"invite_user_id"
=>
0
,
"invite_user_nick"
=>
""
,
];
$insertData
[]
=
$payInfo
;
}
}
}
//新用户奖励
$inviteNewUserList
=
$this
->
getInviteNewUserList
(
$userIds
,
$today
);
if
(
!
empty
(
$inviteNewUserList
))
{
$colonelUserIds
=
array_column
(
$inviteNewUserList
,
"user_id"
);
$userNickList
=
$this
->
getUserList
(
$colonelUserIds
);
foreach
(
$inviteNewUserList
as
$newUser
)
{
$payInfo
=
[
"colonel_user_id"
=>
$newUser
[
"inviter_user_id"
],
"date"
=>
$yesterday
,
"type"
=>
ColonelDistributorPayInfo
::
TYPE_NEW_USER
,
"reward"
=>
5
*
100
,
"finish_num"
=>
1
,
"invite_user_id"
=>
$newUser
[
"user_id"
],
"invite_user_nick"
=>
empty
(
$userNickList
[
$newUser
[
"user_id"
]][
"user_nick"
])
?
""
:
$userNickList
[
$newUser
[
"user_id"
]][
"user_nick"
],
];
$insertData
[]
=
$payInfo
;
}
}
}
$i
=
$i
+
$length
;
}
if
(
!
empty
(
$insertData
))
{
$data
=
$this
->
addIdgenId
(
$insertData
);
$res
=
$this
->
addColonelDistributorPayInfo
(
$data
);
if
(
$res
===
false
)
{
ColonelDistributorPayInfo
::
rollback
();
FileLog
::
info
(
"add_colonel_distributor_pay_info"
,
sprintf
(
"写入错误参数 %s"
,
json_encode
(
$data
)));
}
}
}
if
(
!
ColonelDistributorPayInfo
::
commit
())
{
ColonelDistributorPayInfo
::
rollback
();
}
sleep
(
60
);
sleep
(
60
);
}
}
/**
* 团长任务配置
* @param $yesterday
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
function
getColonelConfig
(
$yesterday
)
{
$type
=
empty
(
$params
[
"type"
])
?
ColonelDistributorConfig
::
TYPE_COLONEL
:
$params
[
"type"
];
$config
=
ColonelDistributorConfig
::
getRecord
([
"date"
=>
$yesterday
,
"type"
=>
$type
]);
if
(
empty
(
$config
))
{
$config
=
ColonelDistributorConfig
::
getRecord
([
"date[<=]"
=>
$yesterday
,
"ORDER"
=>
[
"date"
=>
"DESC"
],
"LIMIT"
=>
1
]);
}
return
$config
;
}
/**
* 团长user_id
* @return array
*/
public
function
getColonelUserIds
()
{
$colonelRes
=
ColonelDistributorColonel
::
select
([
"user_id"
],
[
"LIMIT"
=>
10000000
]);
$userIds
=
[];
if
(
!
empty
(
$colonelRes
))
{
$userIds
=
array_column
(
$colonelRes
,
"user_id"
);
}
return
$userIds
;
}
public
function
getInviteOrder
(
$colonelUserIds
,
$startTime
,
$endTime
)
{
return
ColonelDistributorInviteOrder
::
select
([
"colonel_user_id"
,
"user_id"
,
"is_refund"
,
"create_time"
],
[
"colonel_user_id"
=>
$colonelUserIds
,
"create_time[>=]"
=>
$startTime
,
"create_time[<=]"
=>
$endTime
,
"is_refund"
=>
0
,
],
[]);
}
/**
* 获取order num
* @param $colonelUserIds
* @param $startTime
* @param $endTime
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
function
getInviteOrderNum
(
$colonelUserIds
,
$startTime
,
$endTime
)
{
return
ColonelDistributorInviteOrderNum
::
select
([
"colonel_user_id"
,
"num"
,
"date"
],
[
"colonel_user_id"
=>
$colonelUserIds
,
"date[>=]"
=>
$startTime
,
"date[<=]"
=>
$endTime
,
],
[]);
}
/**
* 获取有效新用户信息
* @param $userIds
* @param $date
* @return array|mixed
* @throws InterfaceException
*/
public
function
getInviteNewUserList
(
$userIds
,
$date
)
{
$url
=
config
(
'interface'
,
'coupon.background.wx_invite_relation_list_by_user_ids'
);
if
(
empty
(
$url
))
{
throw
new
InterfaceException
([
'cus'
=>
0
]);
}
$res
=
HttpUtil
::
get
(
$url
,
[
"user_ids"
=>
$userIds
,
"date"
=>
$date
]);
if
(
!
empty
(
$res
[
"response"
][
"result"
]))
{
$res
=
array_column
(
$res
[
"response"
][
"result"
],
null
,
"user_id"
);
return
array_values
(
$res
);
}
return
[];
}
/**
* 给数据整理 colonel_distributor_pay_info_id
* @param $data
* @param string $type
* @return mixed
*/
public
function
addIdgenId
(
$data
,
$type
=
"goods"
)
{
$count
=
count
(
$data
);
$res
=
Idgen
::
get
(
appConfig
(
'idgen.partner'
),
appConfig
(
'idgen.key'
),
[],
[[
"type"
=>
$type
,
'number'
=>
00
,
"count"
=>
$count
]]);
$ids
=
$res
[
'id_datetime'
][
$type
]
??
[];
foreach
(
$data
as
$key
=>
$item
)
{
$data
[
$key
][
"colonel_distributor_pay_info_id"
]
=
$ids
[
$key
];
}
return
$data
;
}
/**
* 用户信息,获取昵称
* @param $userIds
* @return \Api\PhpUtils\Mysql\MysqlBase|array
*/
public
function
getUserList
(
$userIds
)
{
$list
=
UserWechatBind
::
select
([
"user_id"
,
"user_nick"
],
[
"user_id"
=>
$userIds
],
[]);
if
(
!
empty
(
$list
))
{
$list
=
array_column
(
$list
,
null
,
"user_id"
);
}
return
$list
;
}
/**
* 写入数据
* @param $data
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
function
addColonelDistributorPayInfo
(
$data
)
{
return
ColonelDistributorPayInfo
::
save
(
$data
);
}
}
}
\ No newline at end of file
daemon/Colonelwallet.php
View file @
dc05741f
...
@@ -10,7 +10,7 @@ use \App\Models\marketing\mysql\ColonelDistributorPayInfo;
...
@@ -10,7 +10,7 @@ use \App\Models\marketing\mysql\ColonelDistributorPayInfo;
use
\App\Exception\custom\InterfaceException
;
use
\App\Exception\custom\InterfaceException
;
use
Api\PhpUtils\Http\HttpUtil
;
use
Api\PhpUtils\Http\HttpUtil
;
class
Colonel
order
implements
DaemonServiceInterface
class
Colonel
wallet
implements
DaemonServiceInterface
{
{
public
function
run
()
public
function
run
()
{
{
...
@@ -19,107 +19,6 @@ class Colonelorder implements DaemonServiceInterface
...
@@ -19,107 +19,6 @@ class Colonelorder implements DaemonServiceInterface
sleep
(
5
);
sleep
(
5
);
return
false
;
return
false
;
}
}
\Yaf\Application
::
app
()
->
bootstrap
()
->
getDispatcher
()
->
dispatch
(
new
\Yaf\Request\Simple
(
''
,
'cli'
,
'colonelwallet'
,
'index'
,
[]));
$yesterday
=
date
(
"Y-m-d"
,
strtotime
(
"-1 day"
));
$payInfoList
=
$this
->
getPayInfo
(
$yesterday
);
if
(
!
empty
(
$payInfoList
))
{
$res
=
$this
->
toWallet
(
$payInfoList
);
if
(
$res
)
{
$this
->
deductingInventory
(
$payInfoList
);
}
}
}
/**
* colonel_distributor_pay_info 数据
* @param $date
* @return array
*/
public
function
getPayInfo
(
$date
)
{
$list
=
ColonelDistributorPayInfo
::
select
(
"*"
,
[
"date"
=>
$date
],
[]);
$data
=
[];
if
(
!
empty
(
$list
))
{
foreach
(
$list
as
$item
)
{
//去重
$key
=
$item
[
"colonel_user_id"
]
.
$item
[
"date"
]
.
$item
[
"type"
]
.
$item
[
"finish_num"
];
$data
[
$key
]
=
$item
;
}
$data
=
array_values
(
$data
);
}
return
$data
;
}
/**
* 写入钱包
*/
public
function
toWallet
(
$payInfoList
)
{
$url
=
config
(
'interface'
,
'wallet.account.transfer'
);
if
(
empty
(
$url
))
{
throw
new
InterfaceException
([
'cus'
=>
0
]);
}
$data
=
[];
foreach
(
$payInfoList
as
$payInfo
)
{
if
(
$payInfo
[
"type"
]
==
ColonelDistributorPayInfo
::
TYPE_NEW_USER
)
{
$desc
=
"邀请新用户("
.
$payInfo
[
"invite_user_nick"
]
.
")完成下单奖励"
;
}
if
(
$payInfo
[
"type"
]
==
ColonelDistributorPayInfo
::
TYPE_FINISH_TARGET
)
{
$desc
=
"完成"
.
$payInfo
[
"finish_num"
]
.
"单用户下单奖励"
;
}
$tmp
=
[];
$tmp
[
"user_id"
]
=
$payInfo
[
"colonel_user_id"
];
$tmp
[
"service_name"
]
=
11
;
//服务名字,10生活圈优惠券,11营销活动
$tmp
[
"source_name"
]
=
1
;
//使用方名,1生活圈,2主端
$tmp
[
"third_order_id"
]
=
$payInfo
[
"colonel_distributor_pay_info_id"
];
$tmp
[
"third_order_id_type"
]
=
$payInfo
[
"type"
];
$tmp
[
"third_order_desc"
]
=
$desc
;
$tmp
[
"amount"
]
=
$payInfo
[
"reward"
];
$tmp
[
"extra"
]
=
$payInfo
;
$data
[]
=
$tmp
;
}
$res
=
HttpUtil
::
post
(
$url
,
[
"list"
=>
$data
]);
if
(
$res
[
'code'
]
==
0
&&
isset
(
$res
[
'response'
][
"result"
]))
{
$date
=
date
(
"Y-m-d H:i:s"
);
FileLog
::
info
(
"colonel_distributor_to_wallet"
,
$date
.
" 写入钱包成功"
);
return
true
;
}
else
{
$msg
=
json_encode
([
"list"
=>
$data
]);
FileLog
::
error
(
"colonel_distributor_to_wallet"
,
$msg
,
null
,
'bp-server@yidian-inc.com'
);
return
false
;
}
}
/**
* 资金池授予用户奖励
*/
public
function
deductingInventory
(
$payInfoList
)
{
$url
=
config
(
'interface'
,
'coupon.capitalpool.grant_user_amount'
);
if
(
empty
(
$url
))
{
throw
new
InterfaceException
([
'cus'
=>
0
]);
}
$data
[
"capital_pool_id"
]
=
2
;
foreach
(
$payInfoList
as
$payInfo
)
{
$tmp
=
[];
$tmp
[
"op"
]
=
200
;
//200:团长奖励
$tmp
[
"user_id"
]
=
$payInfo
[
"colonel_user_id"
];
$tmp
[
"amount"
]
=
$payInfo
[
"reward"
];
$data
[
"body"
][]
=
$tmp
;
}
$res
=
HttpUtil
::
post
(
$url
,
$data
);
if
(
$res
[
'code'
]
==
0
&&
isset
(
$res
[
'response'
][
"result"
]))
{
$date
=
date
(
"Y-m-d H:i:s"
);
FileLog
::
info
(
"colonel_distributor_deducting_inventory"
,
$date
.
" 资金池授予用户奖励成功"
);
return
true
;
}
else
{
$msg
=
json_encode
([
"list"
=>
$data
]);
FileLog
::
error
(
"colonel_distributor_deducting_inventory"
,
$msg
,
null
,
'bp-server@yidian-inc.com'
);
return
false
;
}
}
}
}
}
\ No newline at end of file
daemon/Pindan.php
View file @
dc05741f
...
@@ -8,6 +8,7 @@ use Api\PhpServices\Daemon\DaemonServiceInterface;
...
@@ -8,6 +8,7 @@ use Api\PhpServices\Daemon\DaemonServiceInterface;
use
Api\PhpUtils\Log\DaemonLog
;
use
Api\PhpUtils\Log\DaemonLog
;
use
App\Models\marketing\mysql\Marketing
;
use
App\Models\marketing\mysql\Marketing
;
use
Api\PhpServices\Wechat\Msg
;
use
Api\PhpServices\Wechat\Msg
;
use
App\Models\marketing\mysql\MarketingPindan
;
class
Pindan
implements
DaemonServiceInterface
class
Pindan
implements
DaemonServiceInterface
{
{
...
@@ -31,12 +32,9 @@ class Pindan implements DaemonServiceInterface
...
@@ -31,12 +32,9 @@ class Pindan implements DaemonServiceInterface
$where
[
"start_time[>]"
]
=
$lastStartTime
;
$where
[
"start_time[>]"
]
=
$lastStartTime
;
$where
[
"end_time[>=]"
]
=
$now
;
$where
[
"end_time[>=]"
]
=
$now
;
$where
[
'ORDER'
]
=
[
"update_time"
=>
"DESC"
];
$where
[
'ORDER'
]
=
[
"update_time"
=>
"DESC"
];
$where
[
'LIMIT'
]
=
[
0
,
1
];
$marketing
=
Marketing
::
get
([
'marketing_id'
,
'marketing_name'
,
'start_time'
],
$where
);
$list
=
Marketing
::
select
([
"marketing_id"
,
"marketing_name"
,
"marketing_type"
,
"start_time"
,
"end_time"
,
"online_status"
,
"update_time"
,
"create_time"
]
,
$where
);
if
(
empty
(
$
list
))
{
if
(
empty
(
$
marketing
))
{
DaemonLog
::
info
(
DaemonLog
::
info
(
'DaemonServiceInterface_pindan'
,
'DaemonServiceInterface_pindan'
,
'no need to send at'
.
date
(
'Y-m-d H:i:s'
)
'no need to send at'
.
date
(
'Y-m-d H:i:s'
)
...
@@ -44,6 +42,7 @@ class Pindan implements DaemonServiceInterface
...
@@ -44,6 +42,7 @@ class Pindan implements DaemonServiceInterface
sleep
(
60
);
sleep
(
60
);
return
false
;
return
false
;
}
}
$pindan
=
MarketingPindan
::
get
([
"pindan_desc"
],
[
"marketing_id"
=>
$marketing
[
"marketing_id"
]]);
//给订阅用户发送消息
//给订阅用户发送消息
//http://ydwiki.yidian-inc.com/pages/viewpage.action?pageId=71667995
//http://ydwiki.yidian-inc.com/pages/viewpage.action?pageId=71667995
...
@@ -53,10 +52,11 @@ class Pindan implements DaemonServiceInterface
...
@@ -53,10 +52,11 @@ class Pindan implements DaemonServiceInterface
$type
=
2
;
// 1 公众号 2 小程序
$type
=
2
;
// 1 公众号 2 小程序
//活动信息
//活动信息
$params
=
[
$params
=
[
self
::
emojiFilter
(
$
list
[
0
]
[
'marketing_name'
]),
self
::
emojiFilter
(
$
marketing
[
'marketing_name'
]),
$
list
[
0
]
[
'start_time'
],
$
marketing
[
'start_time'
],
$
list
[
0
]
[
'pindan_desc'
]
?:
self
::
DEFAULT_DESC
$
pindan
[
'pindan_desc'
]
?:
self
::
DEFAULT_DESC
];
];
//发送消息
//发送消息
DaemonLog
::
info
(
DaemonLog
::
info
(
'DaemonServiceInterface_pindan'
,
'DaemonServiceInterface_pindan'
,
...
...
deploy/job/run-colonel-order.job
0 → 100644
View file @
dc05741f
type=command
command=bash docker run --rm -e LANG=en_US.UTF-8 -e TZ=Asia/Shanghai --net=bridge -h "`hostname`" --cap-add SYS_PTRACE --privileged docker2.yidian.com:5000/publish/bp-goods-azkaban-test-10-image /bin/bash -c "cd /home/services && sh start_job.sh test ColonelOrder index"
\ No newline at end of file
deploy/job/run-colonel-wallet.job
0 → 100644
View file @
dc05741f
type=command
command=bash docker run --rm -e LANG=en_US.UTF-8 -e TZ=Asia/Shanghai --net=bridge -h "`hostname`" --cap-add SYS_PTRACE --privileged docker2.yidian.com:5000/publish/bp-goods-azkaban-test-10-image /bin/bash -c "cd /home/services && sh start_job.sh test ColonelWallet index"
dependencies=run-colonel-order
\ No newline at end of file
deploy/job/run.job
0 → 100644
View file @
dc05741f
type=command
command=bash docker run --rm -e LANG=en_US.UTF-8 -e TZ=Asia/Shanghai --net=bridge -h "`hostname`" --cap-add SYS_PTRACE --privileged docker2.yidian.com:5000/publish/bp-goods-azkaban-test-10-image /bin/bash -c "cd /home/services && sh start_job.sh test goodstoes index a=3&b=4"
deploy/start_env/start_job.sh
View file @
dc05741f
#!/bin/bash
#!/bin/bash
#
#
#set -xeuo pipefail # 参考: https://mp.weixin.qq.com/s/VmM_U4RefRBHwIw8NegC8Q
set
-xeuo
pipefail
# 参考: https://mp.weixin.qq.com/s/VmM_U4RefRBHwIw8NegC8Q
# 运行环境env
# 运行环境env
if
[[
X
"
$1
"
==
X
""
]]
;
then
if
[[
X
"
$1
"
==
X
""
]]
;
then
...
@@ -49,8 +49,13 @@ sysctl -w net.core.somaxconn=65535
...
@@ -49,8 +49,13 @@ sysctl -w net.core.somaxconn=65535
php api.go2yd.com/htdocs/Website/public/job.php
"
$2
"
"
$3
"
"
$4
"
php api.go2yd.com/htdocs/Website/public/job.php
"
$2
"
"
$3
"
"
$4
"
if
[
$?
-ne
0
]
ret
=
$?
then
# todo
if
[
$ret
-ne
0
]
;
then
echo
"Build failed"
echo
"Build failed"
exit
$ret
else
echo
"Build success"
fi
fi
exit
0
\ 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