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
e668cd25
Commit
e668cd25
authored
Sep 06, 2021
by
pengfei
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into colonel
parents
f2f599e7
669def92
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
58 additions
and
36 deletions
+58
-36
UserException.php
application/exception/custom/UserException.php
+3
-0
UserWechatBind.php
application/models/user/mysql/UserWechatBind.php
+9
-1
GoodsService.php
application/services/goods/GoodsService.php
+0
-12
MarketingPindanGoodsService.php
application/services/goods/MarketingPindanGoodsService.php
+0
-11
UserService.php
application/services/user/UserService.php
+44
-10
application.ini
conf/application.ini
+1
-1
cli.ini
conf/cli.ini
+1
-1
No files found.
application/exception/custom/UserException.php
View file @
e668cd25
...
...
@@ -22,5 +22,8 @@ class UserException extends BaseException
8
=>
'绑定手机号失败'
,
9
=>
'该手机号已绑定其他用户不能重复绑定'
,
10
=>
'mysql 异常'
,
11
=>
'头像昵称更新失败'
,
12
=>
'绑定手机号保存失败'
,
13
=>
'请求太频繁,稍后重试'
,
];
}
\ No newline at end of file
application/models/user/mysql/UserWechatBind.php
View file @
e668cd25
...
...
@@ -26,6 +26,14 @@ class UserWechatBind extends MysqlBase
return
self
::
get
(
$columns
,
$where
);
}
public
static
function
getRecordMaster
(
$where
,
$columns
=
[])
{
if
(
empty
(
$columns
))
{
$columns
=
'*'
;
}
return
self
::
getMaster
(
$columns
,
$where
);
}
public
static
function
getRecords
(
$where
,
$columns
=
[])
{
if
(
empty
(
$columns
))
{
...
...
@@ -34,7 +42,7 @@ class UserWechatBind extends MysqlBase
return
self
::
select
(
$columns
,
$where
);
}
public
static
function
getRecord
Master
(
$where
,
$columns
=
[])
public
static
function
getRecord
sMaster
(
$where
,
$columns
=
[])
{
if
(
empty
(
$columns
))
{
$columns
=
'*'
;
...
...
application/services/goods/GoodsService.php
View file @
e668cd25
...
...
@@ -157,11 +157,6 @@ class GoodsService
throw
new
GoodsException
([
'cus'
=>
2
]);
}
$spuId
=
$res
[
0
];
$checkName
=
self
::
checkGoodsName
(
$spuData
[
"goods_name"
],
$spuData
[
"life_account_id"
]);
if
(
!
$checkName
[
"can_use"
])
{
throw
new
GoodsException
([
'cus'
=>
17
]);
}
$spuParams
=
[
"goods_spu_id"
=>
$spuId
,
"shop_id"
=>
$shopId
,
...
...
@@ -771,13 +766,6 @@ class GoodsService
*/
private
static
function
editGoodsSpu
(
$goodsSpu
,
$params
=
[])
{
$checkName
=
self
::
checkGoodsName
(
$params
[
"goods_name"
],
$goodsSpu
[
"life_account_id"
],
$goodsSpu
[
"goods_spu_id"
]);
if
(
!
$checkName
[
"can_use"
])
{
throw
new
GoodsException
([
'cus'
=>
17
]);
}
return
GoodsSpu
::
save
([
"goods_name"
=>
$params
[
"goods_name"
],
"desc_pic_url"
=>
$params
[
"desc_pic_url"
],
...
...
application/services/goods/MarketingPindanGoodsService.php
View file @
e668cd25
...
...
@@ -165,12 +165,6 @@ class MarketingPindanGoodsService
*/
private
static
function
addGoodsSku
(
$spuData
,
$shopId
,
$skuData
=
[])
{
$pindanSku
=
PindanGoodsSku
::
get
(
"goods_sku_id"
,
[
"goods_name"
=>
$skuData
[
"goods_name"
]
,
"life_account_id"
=>
$skuData
[
"life_account_id"
]]);
if
(
!
empty
(
$pindanSku
))
{
throw
new
GoodsException
([
'cus'
=>
17
]);
}
$res
=
GoodsService
::
getIdgenId
(
substr
(
$shopId
,
-
2
),
"goods"
);
if
(
empty
(
$res
))
{
throw
new
GoodsException
([
'cus'
=>
2
]);
...
...
@@ -267,11 +261,6 @@ class MarketingPindanGoodsService
*/
private
static
function
editGoodsSpu
(
$goodsSpu
,
$params
=
[])
{
$checkName
=
GoodsService
::
checkGoodsName
(
$params
[
"goods_name"
],
$goodsSpu
[
"life_account_id"
],
$goodsSpu
[
"goods_spu_id"
]);
if
(
!
$checkName
[
"can_use"
])
{
throw
new
GoodsException
([
'cus'
=>
17
]);
}
return
GoodsSpu
::
save
([
"desc_pic_url"
=>
$params
[
"desc_pic_url"
],
"desc"
=>
$params
[
"desc"
],
...
...
application/services/user/UserService.php
View file @
e668cd25
...
...
@@ -14,6 +14,8 @@ use Api\PhpServices\Idgen\Idgen;
use
Api\PhpUtils\Redis\RedisUtil
;
use
Api\PhpServices\JwUser\JwUser
;
use
App\Services\common\CommonService
;
use
Api\PhpUtils\Log\FileLog
;
use
Api\PhpUtils\Lock\FrequencyLockUtil
;
class
UserService
{
...
...
@@ -23,13 +25,14 @@ class UserService
public
static
function
wechatLogin
(
$params
)
{
$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'
);
throw
new
UserException
([
'cus'
=>
0
]);
}
//需要授权微信
//if (empty($openid)) {
$appid
=
\Yaf\Registry
::
get
(
'config'
)
->
wechat
->
appid
;
...
...
@@ -51,6 +54,7 @@ class UserService
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
]);
}
//检查系统是已注册
...
...
@@ -58,7 +62,7 @@ class UserService
//}
$user
=
UserWechatBind
::
getRecord
([
'openid'
=>
$openid
]);
$user
=
UserWechatBind
::
getRecord
Master
([
'openid'
=>
$openid
]);
//如果系统不存在,用户信息,则注册新用户
if
(
empty
(
$user
)
&&
!
empty
(
$response
))
{
$insert
=
[
...
...
@@ -68,8 +72,13 @@ class UserService
'create_time'
=>
date
(
"Y-m-d H:i:s"
)
];
$newWechatId
=
UserWechatBind
::
save
(
$insert
);
$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"
)]);
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'
);
throw
new
UserException
([
'cus'
=>
2
]);
}
...
...
@@ -78,13 +87,17 @@ class UserService
$user
[
'session_key'
]
=
$response
[
'session_key'
];
}
else
{
if
(
empty
(
$user
))
{
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'
);
throw
new
UserException
([
'cus'
=>
2
]);
}
$insert
=
[
'session_key'
=>
!
empty
(
$response
[
'session_key'
])
?
$response
[
'session_key'
]
:
''
,
];
$newWechatId
=
UserWechatBind
::
save
(
$insert
,[
'openid'
=>
$openid
]);
}
...
...
@@ -108,17 +121,20 @@ class UserService
$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
]);
}
if
(
!
$iv
)
{
FileLog
::
error
(
"bindPhone:iv 为空"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
throw
new
UserException
([
'cus'
=>
4
]);
}
$userInfo
=
UserWechatBind
::
getRecord
([
'openid'
=>
$openid
]);
$userInfo
=
UserWechatBind
::
getRecord
Master
([
'openid'
=>
$openid
]);
$sessionKey
=
!
empty
(
$userInfo
[
'session_key'
])
?
$userInfo
[
'session_key'
]
:
''
;
$openid
=
isset
(
$userInfo
[
'openid'
])
&&
$userInfo
[
'openid'
]
?
$userInfo
[
'openid'
]
:
''
;
if
(
empty
(
$userInfo
)
||
!
$sessionKey
||
!
$openid
)
{
FileLog
::
error
(
"bindPhone:userInfo获取失败"
,
json_encode
(
$userInfo
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
throw
new
UserException
([
'cus'
=>
5
]);
}
...
...
@@ -128,18 +144,23 @@ class UserService
$errCode
=
$wXBizDataCrypt
->
decryptData
(
$encryptedData
,
$iv
,
$decryptData
);
if
(
$errCode
)
{
FileLog
::
error
(
"bindPhone:解密失败"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
throw
new
UserException
([
'cus'
=>
6
]);
}
// 手机号解密
成功
// 手机号解密
失败
if
(
empty
(
$decryptData
[
'phoneNumber'
]))
{
FileLog
::
error
(
"bindPhone:手机号解密失败"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
FileLog
::
error
(
"bindPhone:手机号解密失败--decryptData"
,
json_encode
(
$decryptData
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
throw
new
UserException
([
'cus'
=>
7
]);
}
$phoneNumber
=
strval
(
$decryptData
[
'phoneNumber'
]);
//判断是否已
$user
=
UserWechatBind
::
getRecord
([
'phone'
=>
$phoneNumber
]);
$user
=
UserWechatBind
::
getRecord
Master
([
'phone'
=>
$phoneNumber
]);
if
(
!
empty
(
$user
)
&&
$openid
!=
$user
[
'openid'
])
{
FileLog
::
error
(
"bindPhone:该手机号已绑定其他用户不能重复绑定"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
FileLog
::
error
(
"bindPhone:该手机号已绑定其他用户不能重复绑定--user"
,
json_encode
(
$user
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
throw
new
UserException
([
'cus'
=>
9
]);
}
...
...
@@ -157,7 +178,13 @@ class UserService
];
$bindStatus
=
UserWechatBind
::
save
(
$update
,[
'wechat_id'
=>
$userInfo
[
'wechat_id'
]]);
if
(
empty
(
$bindStatus
)){
FileLog
::
error
(
"bindPhone:绑定手机号保存失败"
,
json_encode
(
$update
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
throw
new
UserException
([
'cus'
=>
12
]);
}
if
(
!
$phoneNumber
)
{
FileLog
::
error
(
"bindPhone:该手机号已绑定其他用户不能重复绑定--user"
,
json_encode
(
$user
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
throw
new
UserException
([
'cus'
=>
8
]);
}
...
...
@@ -210,10 +237,17 @@ class UserService
"city"
=>
!
empty
(
$params
[
'city'
])
?
$params
[
'city'
]
:
''
,
"language"
=>
!
empty
(
$params
[
'language'
])
?
$params
[
'language'
]
:
''
,
];
$bindStatus
=
UserWechatBind
::
save
(
$update
,[
'openid'
=>
$params
[
'openid'
]]);
$user
=
UserWechatBind
::
getRecordMaster
([
'openid'
=>
$params
[
'openid'
]]);
if
(
empty
(
$user
)){
$update
[
'openid'
]
=
$params
[
'openid'
];
$bindStatus
=
UserWechatBind
::
save
(
$update
);
}
else
{
$bindStatus
=
UserWechatBind
::
save
(
$update
,[
'openid'
=>
$params
[
'openid'
]]);
}
if
(
!
$bindStatus
)
{
throw
new
UserException
([
'cus'
=>
8
]);
FileLog
::
error
(
"bindAvatar:绑定头像失败"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
FileLog
::
error
(
"bindAvatar:绑定头像失败--update"
,
json_encode
(
$update
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
throw
new
UserException
([
'cus'
=>
11
]);
}
return
$update
;
}
...
...
conf/application.ini
View file @
e668cd25
...
...
@@ -31,6 +31,6 @@ exception.sys.msg = "系统未定义异常,研发正在赶来的路上..."
[prod : common : exception]
[p
re
: common : exception]
[p
erf
: common : exception]
[test : common : exception]
[dev : common : exception]
\ No newline at end of file
conf/cli.ini
View file @
e668cd25
...
...
@@ -11,6 +11,6 @@ idgen.partner = "bp"
idgen.key
=
"5cfdb867e96374c7883b31d6928cc4cb"
[prod : common]
[p
re
: common ]
[p
erf
: common ]
[test: common ]
[dev : common ]
\ 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