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
ab60db4e
Commit
ab60db4e
authored
Sep 07, 2021
by
pengfei
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'colonel' into develop
parents
8521e4f0
d974dcc4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
59 deletions
+77
-59
Colonelorder.php
application/modules/Job/controllers/Colonelorder.php
+30
-20
ColonelService.php
application/services/marketing/ColonelService.php
+3
-2
UserService.php
application/services/user/UserService.php
+44
-37
No files found.
application/modules/Job/controllers/Colonelorder.php
View file @
ab60db4e
...
...
@@ -59,7 +59,16 @@ class ColonelorderController extends Job
$this
->
getInviteOrderData
(
$userIds
,
$colonelPayInfoData
);
// 完成目标单数
$this
->
getInviteNewUserData
(
$userIds
,
$colonelPayInfoData
);
// 邀请新用户奖励
}
$this
->
handleSavePayInfo
(
$colonelPayInfoData
);
if
(
!
empty
(
$colonelPayInfoData
))
{
try
{
$this
->
loggerInfo
(
'colonelPayInfoCount='
.
count
(
$colonelPayInfoData
));
$colonelPayInfoData
=
$this
->
getFormatPayInfoData
(
$colonelPayInfoData
);
$this
->
handleSavePayInfo
(
$colonelPayInfoData
);
$this
->
loggerInfo
(
'success'
);
}
catch
(
Exception
$e
)
{
$this
->
loggerError
(
'error='
.
$e
->
getMessage
());
}
}
}
$this
->
loggerInfo
(
'end'
);
}
...
...
@@ -67,27 +76,23 @@ class ColonelorderController extends Job
/**
* Notes: 保存奖励信息
* User: pengfei@yidian-inc.com
* Date: 2021/9/
3 4:34 下
午
* Date: 2021/9/
7 10:40 上
午
* @param $colonelPayInfoData
* @throws Exception
*/
private
function
handleSavePayInfo
(
$colonelPayInfoData
)
{
$this
->
loggerInfo
(
'colonelPayInfoCount='
.
count
(
$colonelPayInfoData
));
if
(
!
empty
(
$colonelPayInfoData
))
{
$data
=
$this
->
getFormatPayInfoData
(
$colonelPayInfoData
);
try
{
ColonelDistributorPayInfo
::
beginTransaction
();
if
(
!
$this
->
addColonelDistributorPayInfo
(
$data
))
{
throw
new
Exception
(
sprintf
(
"写入错误参数 %s"
,
json_encode
(
$data
)));
}
if
(
!
ColonelDistributorPayInfo
::
commit
())
{
throw
new
Exception
(
sprintf
(
"事务提交失败 %s"
,
json_encode
(
$data
)));
}
$this
->
loggerInfo
(
'success'
);
}
catch
(
Exception
$e
)
{
ColonelDistributorPayInfo
::
rollback
();
$this
->
loggerError
(
'error='
.
$e
->
getMessage
());
try
{
ColonelDistributorPayInfo
::
beginTransaction
();
if
(
!
$this
->
addColonelDistributorPayInfo
(
$colonelPayInfoData
))
{
throw
new
Exception
(
sprintf
(
"写入错误参数 %s"
,
json_encode
(
$colonelPayInfoData
)));
}
if
(
!
ColonelDistributorPayInfo
::
commit
())
{
throw
new
Exception
(
sprintf
(
"事务提交失败 %s"
,
json_encode
(
$colonelPayInfoData
)));
}
}
catch
(
Exception
$e
)
{
ColonelDistributorPayInfo
::
rollback
();
throw
new
Exception
(
$e
->
getMessage
());
}
}
...
...
@@ -211,21 +216,26 @@ class ColonelorderController extends Job
/**
* Notes: 获取pay_info数据
* User: pengfei@yidian-inc.com
* Date: 2021/9/
3 4:07 下
午
* Date: 2021/9/
7 10:34 上
午
* @param $data
* @return array
* @throws Exception
*/
private
function
getFormatPayInfoData
(
$data
)
:
array
{
$count
=
count
(
$data
);
$
res
=
Idgen
::
get
(
appConfig
(
'idgen.partner'
),
appConfig
(
'idgen.key'
),
[],
[
$
httpParams
=
[
[
'type'
=>
'goods'
,
'number'
=>
00
,
'count'
=>
$count
]
]);
];
$res
=
Idgen
::
get
(
appConfig
(
'idgen.partner'
),
appConfig
(
'idgen.key'
),
[],
$httpParams
);
$ids
=
$res
[
'id_datetime'
][
'goods'
]
??
[];
if
(
$count
>
count
(
$ids
))
{
throw
new
Exception
(
'请求idgen服务失败,request:'
.
json_encode
(
$httpParams
)
.
';response:'
.
json_encode
(
$res
));
}
foreach
(
$data
as
$key
=>
$item
)
{
$data
[
$key
][
'pay_info_trade_id'
]
=
$ids
[
$key
];
}
...
...
application/services/marketing/ColonelService.php
View file @
ab60db4e
...
...
@@ -153,14 +153,15 @@ class ColonelService
}
// 审核状态数据检测
$applyInfo
=
ColonelDistributorColonelApply
::
getRecord
([
'colonel_apply_id'
=>
$applyId
]);
if
(
empty
(
$applyInfo
)
||
$applyInfo
[
'audit_status'
]
!=
ColonelDistributorColonelApply
::
STATUS_AUDIT
)
{
if
(
empty
(
$applyInfo
)
||
$applyInfo
[
'audit_status'
]
==
ColonelDistributorColonelApply
::
STATUS_PASS
)
{
throw
new
MarketingException
(
MarketingException
::
COLONEL_AUDIT_STATUS_USE
);
}
try
{
ColonelDistributorColonelApply
::
beginTransaction
();
// 修改申请状态
$updateStatus
=
ColonelDistributorColonelApply
::
updateRecord
([
'audit_status'
=>
$auditStatus
],
[
'colonel_apply_id'
=>
$applyId
,
'audit_status'
=>
ColonelDistributorColonelApply
::
STATUS_AUDIT
]);
[
'colonel_apply_id'
=>
$applyId
,
'audit_status'
=>
ColonelDistributorColonelApply
::
STATUS_AUDIT
]
);
if
(
empty
(
$updateStatus
))
{
throw
new
MarketingException
(
MarketingException
::
COLONEL_AUDIT_STATUS_FAILED
);
}
...
...
application/services/user/UserService.php
View file @
ab60db4e
...
...
@@ -3,6 +3,7 @@
namespace
App\Services\user
;
use
Api\PhpUtils\Mon\MonUtil
;
use
App\Models\user\mysql\UserWechatBind
;
use
Api\PhpUtils\Http\Request
;
use
App\Services\user\Weixin\WxBizDataCrypt
;;
...
...
@@ -29,36 +30,42 @@ class UserService
$code
=
!
empty
(
$params
[
'code'
])
?
$params
[
'code'
]
:
''
;
//小程序授权code
$openid
=
!
empty
(
$params
[
'openid'
])
?
$params
[
'openid'
]
:
''
;
//小程序授权code
if
(
empty
(
$code
)
&&
empty
(
$openid
))
{
FileLog
::
error
(
"wechatLogin:获取参数为空"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
FileLog
::
error
(
"wechatLogin:获取参数为空"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
throw
new
UserException
([
'cus'
=>
0
]);
}
//需要授权微信
//if (empty($openid)) {
$appid
=
\Yaf\Registry
::
get
(
'config'
)
->
wechat
->
appid
;
$secret
=
\Yaf\Registry
::
get
(
'config'
)
->
wechat
->
secret
;
$grant_type
=
'authorization_code'
;
$loginUrl
=
'https://api.weixin.qq.com/sns/jscode2session'
;
//请求接口,获取用户openid
$params
=
[
'appid'
=>
$appid
,
'secret'
=>
$secret
,
'js_code'
=>
$code
,
'grant_type'
=>
$grant_type
,
];
$response
=
(
new
Request
())
->
post
(
$loginUrl
,
$params
);
if
(
$response
[
'code'
]
==
0
)
{
$response
=
$response
[
'response'
];
}
$appid
=
\Yaf\Registry
::
get
(
'config'
)
->
wechat
->
appid
;
$secret
=
\Yaf\Registry
::
get
(
'config'
)
->
wechat
->
secret
;
$grant_type
=
'authorization_code'
;
$loginUrl
=
'https://api.weixin.qq.com/sns/jscode2session'
;
//请求接口,获取用户openid
$params
=
[
'appid'
=>
$appid
,
'secret'
=>
$secret
,
'js_code'
=>
$code
,
'grant_type'
=>
$grant_type
,
];
$begin
=
microtime
(
true
);
$response
=
(
new
Request
())
->
post
(
$loginUrl
,
$params
);
if
(
empty
(
$response
)
||
array_key_exists
(
'errcode'
,
$response
))
{
//throw new \Exception('获取openid失败:' . $response['errcode']);
FileLog
::
error
(
"wechatLogin:获取openid失败"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
throw
new
UserException
([
'cus'
=>
1
]);
}
//检查系统是已注册
$openid
=
!
empty
(
$response
[
'openid'
])
?
$response
[
'openid'
]
:
''
;
$end
=
microtime
(
true
);
$totalTime
=
round
((
$end
-
$begin
),
4
)
*
1000
;
if
(
$response
[
'code'
]
==
0
)
{
$response
=
$response
[
'response'
];
}
//mon打点
$env
=
Application
::
app
()
->
environ
()
??
"dev"
;
MonUtil
::
proxyMon
(
$loginUrl
,
$response
[
'code'
],
'weixin_'
.
$env
,
$totalTime
);
if
(
empty
(
$response
)
||
array_key_exists
(
'errcode'
,
$response
))
{
//throw new \Exception('获取openid失败:' . $response['errcode']);
FileLog
::
error
(
"wechatLogin:获取openid失败"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
throw
new
UserException
([
'cus'
=>
1
]);
}
//检查系统是已注册
$openid
=
!
empty
(
$response
[
'openid'
])
?
$response
[
'openid'
]
:
''
;
//}
...
...
@@ -75,34 +82,34 @@ class UserService
$sessionKey
=
!
empty
(
$response
[
'session_key'
])
?
$response
[
'session_key'
]
:
''
;
//$newWechatId = UserWechatBind::save($insert);
$newWechatId
=
UserWechatBind
::
insertDuplicate
(
$insert
,
[
'session_key'
=>
$sessionKey
,
'create_time'
=>
date
(
"Y-m-d H:i:s"
)]);
$newWechatId
=
UserWechatBind
::
insertDuplicate
(
$insert
,
[
'session_key'
=>
$sessionKey
,
'create_time'
=>
date
(
"Y-m-d H:i:s"
)]);
if
(
!
$newWechatId
)
{
FileLog
::
error
(
"wechatLogin:登陆创建用户失败"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
FileLog
::
error
(
"wechatLogin:登陆创建用户失败--insert"
,
json_encode
(
$insert
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
FileLog
::
error
(
"wechatLogin:登陆创建用户失败"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
FileLog
::
error
(
"wechatLogin:登陆创建用户失败--insert"
,
json_encode
(
$insert
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
throw
new
UserException
([
'cus'
=>
2
]);
}
$user
[
'wechat_id'
]
=
$newWechatId
;
$user
[
'openid'
]
=
$response
[
'openid'
];
$user
[
'session_key'
]
=
$response
[
'session_key'
];
}
else
{
}
else
{
if
(
empty
(
$user
))
{
FileLog
::
error
(
"wechatLogin:登陆创建用户失败-- 微信response"
,
json_encode
(
$response
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
FileLog
::
error
(
"wechatLogin:登陆创建用户失败-- 微信response"
,
json_encode
(
$response
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
throw
new
UserException
([
'cus'
=>
2
]);
}
if
(
empty
(
$response
)){
FileLog
::
error
(
"wechatLogin:登陆创建用户失败-- 微信response 获取失败"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
if
(
empty
(
$response
))
{
FileLog
::
error
(
"wechatLogin:登陆创建用户失败-- 微信response 获取失败"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
throw
new
UserException
([
'cus'
=>
2
]);
}
$insert
=
[
'session_key'
=>
!
empty
(
$response
[
'session_key'
])
?
$response
[
'session_key'
]
:
''
,
];
$newWechatId
=
UserWechatBind
::
save
(
$insert
,[
'openid'
=>
$openid
]);
$newWechatId
=
UserWechatBind
::
save
(
$insert
,
[
'openid'
=>
$openid
]);
}
$user
[
'third_session'
]
=
self
::
generate3rdSession
(
$openid
);
return
$user
;
return
$user
;
}
/**
...
...
@@ -117,9 +124,9 @@ class UserService
{
$openid
=
!
empty
(
$params
[
'openid'
])
?
$params
[
'openid'
]
:
''
;
$encryptedData
=
!
empty
(
$params
[
'encryptedData'
])
?
$params
[
'encryptedData'
]
:
''
;
$iv
=
!
empty
(
$params
[
'iv'
])
?
$params
[
'iv'
]
:
''
;
$iv
=
!
empty
(
$params
[
'iv'
])
?
$params
[
'iv'
]
:
''
;
$appid
=
\Yaf\Registry
::
get
(
'config'
)
->
wechat
->
appid
;
if
(
!
$encryptedData
)
{
FileLog
::
error
(
"bindPhone:encryptedData 为空"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
throw
new
UserException
([
'cus'
=>
3
]);
...
...
@@ -204,7 +211,7 @@ class UserService
public
static
function
userWechatBind
(
$params
)
{
$data
[
'wechat_id[>]'
]
=
0
;
if
(
!
empty
(
$params
[
'openid'
]))
{
...
...
@@ -218,7 +225,7 @@ class UserService
if
(
!
empty
(
$params
[
'phone'
]))
{
$data
[
'phone'
]
=
$params
[
'phone'
];
}
$userList
=
UserWechatBind
::
getRecords
(
$data
);
return
$userList
;
}
...
...
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