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
70a9a8dd
Commit
70a9a8dd
authored
Sep 13, 2021
by
jianghaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'test' of
https://gitlab.yidian-inc.com/bp/goods
into test
parents
dfbfb97d
5303e2a5
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
118 additions
and
39 deletions
+118
-39
BaseException.php
application/exception/BaseException.php
+3
-3
GoodsException.php
application/exception/custom/GoodsException.php
+2
-0
BaseValidate.php
application/library/Validate/BaseValidate.php
+1
-1
OtaValidate.php
application/library/Validate/OtaValidate.php
+19
-6
Ota.php
application/modules/Goods/controllers/Ota.php
+15
-2
OtaService.php
application/services/goods/OtaService.php
+63
-9
UserService.php
application/services/user/UserService.php
+12
-18
FeiPrinter.php
vendor/api/php_services/src/Printer/Fei/FeiPrinter.php
+3
-0
No files found.
application/exception/BaseException.php
View file @
70a9a8dd
...
@@ -33,11 +33,11 @@ class BaseException extends \Exception
...
@@ -33,11 +33,11 @@ class BaseException extends \Exception
$this
->
msg
=
$params
[
'msg'
]
??
Registry
::
get
(
'config'
)
->
exception
->
user
->
msg
;
$this
->
msg
=
$params
[
'msg'
]
??
Registry
::
get
(
'config'
)
->
exception
->
user
->
msg
;
if
(
isset
(
$params
[
'cus'
])
&&
$this
->
cus
&&
isset
(
$this
->
cus
[
intval
(
$params
[
'cus'
])])
&&
$this
->
base_code
)
{
if
(
isset
(
$params
[
'cus'
])
&&
$this
->
cus
&&
isset
(
$this
->
cus
[
intval
(
$params
[
'cus'
])])
&&
$this
->
base_code
)
{
return
$this
->
setCusMsg
(
$params
[
'cus'
]);
return
$this
->
setCusMsg
(
$params
[
'cus'
]
,
$params
[
'data'
]
??
''
);
}
}
}
}
public
function
setCusMsg
(
$cus
)
public
function
setCusMsg
(
$cus
,
$data
=
''
)
{
{
//每个服务都有自己的codePrefix
//每个服务都有自己的codePrefix
$appid
=
\Yaf\Application
::
app
()
->
getConfig
()
->
get
(
"appid"
);
$appid
=
\Yaf\Application
::
app
()
->
getConfig
()
->
get
(
"appid"
);
...
@@ -48,7 +48,7 @@ class BaseException extends \Exception
...
@@ -48,7 +48,7 @@ class BaseException extends \Exception
$base_code
=
intval
(
$this
->
base_code
);
$base_code
=
intval
(
$this
->
base_code
);
$this
->
code
=
$codePrefix
+
$base_code
+
$cus_code
;
$this
->
code
=
$codePrefix
+
$base_code
+
$cus_code
;
$this
->
msg
=
isset
(
$params
[
'data'
])
?
vsprintf
(
$this
->
cus
[
$cus_code
],
$params
[
'data'
]
)
:
$this
->
cus
[
$cus_code
];
$this
->
msg
=
!
empty
(
$data
)
?
vsprintf
(
$this
->
cus
[
$cus_code
],
$data
)
:
$this
->
cus
[
$cus_code
];
}
}
public
function
__get
(
$name
)
:
bool
public
function
__get
(
$name
)
:
bool
...
...
application/exception/custom/GoodsException.php
View file @
70a9a8dd
...
@@ -18,6 +18,7 @@ class GoodsException extends BaseException
...
@@ -18,6 +18,7 @@ class GoodsException extends BaseException
const
NOT_FIND_MARKETING
=
51
;
const
NOT_FIND_MARKETING
=
51
;
const
LABEL_PRINTER_ALREADY_EXIST
=
53
;
const
LABEL_PRINTER_ALREADY_EXIST
=
53
;
const
PRINTER_BIND_ERROR
=
54
;
const
PRINTER_BIND_ERROR
=
54
;
const
PRINTER_SN_ERROR
=
55
;
protected
$cus
=
[
protected
$cus
=
[
0
=>
'商品创建失败,请稍后重试'
,
0
=>
'商品创建失败,请稍后重试'
,
...
@@ -75,5 +76,6 @@ class GoodsException extends BaseException
...
@@ -75,5 +76,6 @@ class GoodsException extends BaseException
52
=>
'过期时间不得小于等于上架开始时间'
,
52
=>
'过期时间不得小于等于上架开始时间'
,
self
::
LABEL_PRINTER_ALREADY_EXIST
=>
'标签打印机已被%s绑定'
,
self
::
LABEL_PRINTER_ALREADY_EXIST
=>
'标签打印机已被%s绑定'
,
self
::
PRINTER_BIND_ERROR
=>
'打印机绑定失败:%s'
,
self
::
PRINTER_BIND_ERROR
=>
'打印机绑定失败:%s'
,
self
::
PRINTER_SN_ERROR
=>
'打印机sn号码有误'
,
];
];
}
}
\ No newline at end of file
application/library/Validate/BaseValidate.php
View file @
70a9a8dd
...
@@ -41,7 +41,7 @@ class BaseValidate extends Validate
...
@@ -41,7 +41,7 @@ class BaseValidate extends Validate
protected
function
isMobile
(
$value
)
protected
function
isMobile
(
$value
)
{
{
$rule
=
'^1(3|4|5|
7|8
)[0-9]\d{8}$^'
;
$rule
=
'^1(3|4|5|
6|7|8|9
)[0-9]\d{8}$^'
;
$result
=
preg_match
(
$rule
,
$value
);
$result
=
preg_match
(
$rule
,
$value
);
if
(
$result
)
{
if
(
$result
)
{
return
true
;
return
true
;
...
...
application/library/Validate/OtaValidate.php
View file @
70a9a8dd
...
@@ -14,10 +14,10 @@ class OtaValidate extends \Validate\BaseValidate
...
@@ -14,10 +14,10 @@ class OtaValidate extends \Validate\BaseValidate
protected
$rule
=
[
protected
$rule
=
[
'ota_name'
=>
'require'
,
'ota_name'
=>
'require'
,
'ota_id'
=>
'require'
,
'ota_id'
=>
'require'
,
'address'
=>
'require'
,
//
'address' => 'require',
'location'
=>
'require'
,
//
'location' => 'require',
'longitude'
=>
'require'
,
//
'longitude' => 'require',
'latitude'
=>
'require'
,
//
'latitude' => 'require',
'offset'
=>
'egt:0'
,
'offset'
=>
'egt:0'
,
'limit'
=>
'elt:100'
,
'limit'
=>
'elt:100'
,
];
];
...
@@ -42,19 +42,32 @@ class OtaValidate extends \Validate\BaseValidate
...
@@ -42,19 +42,32 @@ class OtaValidate extends \Validate\BaseValidate
public
function
sceneAdd
()
public
function
sceneAdd
()
{
{
return
$this
->
only
([
'ota_name'
,
'address'
,
'longitude'
,
'latitude'
,
'location'
]);
return
$this
->
only
([
'ota_name'
]);
}
}
public
function
sceneDelete
()
public
function
sceneDelete
()
{
{
return
$this
->
only
([
'ota_id'
]);
return
$this
->
only
([
'ota_id'
]);
}
}
public
function
sceneUndelete
()
{
return
$this
->
only
([
'ota_id'
]);
}
public
function
sceneUpdate
()
public
function
sceneUpdate
()
{
{
return
$this
->
only
([
'ota_id'
,
'ota_name'
,
'address'
,
'longitude'
,
'latitude'
,
'location'
]);
return
$this
->
only
([
'ota_id'
,
'ota_name'
]);
}
}
public
function
sceneListByIds
()
public
function
sceneListByIds
()
{
{
return
$this
->
only
([
'ota_id'
]);
return
$this
->
only
([
'ota_id'
]);
}
}
public
function
is_label_printer_sn
(
$value
){
if
(
substr
(
$value
,
3
,
1
)
!=
'2'
){
return
false
;
}
return
true
;
}
}
}
\ No newline at end of file
application/modules/Goods/controllers/Ota.php
View file @
70a9a8dd
...
@@ -24,9 +24,10 @@ class OtaController extends Base
...
@@ -24,9 +24,10 @@ class OtaController extends Base
$printerKey
=
$this
->
params
[
'printer_key'
]
??
''
;
$printerKey
=
$this
->
params
[
'printer_key'
]
??
''
;
$labelPrinterSn
=
$this
->
params
[
'label_printer_sn'
]
??
''
;
$labelPrinterSn
=
$this
->
params
[
'label_printer_sn'
]
??
''
;
$labelPrinterKey
=
$this
->
params
[
'label_printer_key'
]
??
''
;
$labelPrinterKey
=
$this
->
params
[
'label_printer_key'
]
??
''
;
$isNormal
=
$this
->
params
[
'is_normal'
]
??
false
;
$offset
=
$this
->
params
[
'offset'
]
??
0
;
$offset
=
$this
->
params
[
'offset'
]
??
0
;
$limit
=
$this
->
params
[
'limit'
]
??
20
;
$limit
=
$this
->
params
[
'limit'
]
??
20
;
$res
=
OtaService
::
list
(
$name
,
$printerSn
,
$printerKey
,
$labelPrinterSn
,
$labelPrinterKey
,
$offset
,
$limit
);
$res
=
OtaService
::
list
(
$name
,
$printerSn
,
$printerKey
,
$labelPrinterSn
,
$labelPrinterKey
,
$
isNormal
,
$
offset
,
$limit
);
$this
->
success
([
'result'
=>
$res
]);
$this
->
success
([
'result'
=>
$res
]);
}
}
...
@@ -69,6 +70,18 @@ class OtaController extends Base
...
@@ -69,6 +70,18 @@ class OtaController extends Base
$this
->
success
([
'status'
=>
$res
?
'success'
:
'failed'
]);
$this
->
success
([
'status'
=>
$res
?
'success'
:
'failed'
]);
}
}
/**
* 删除一个供应商
* @throws \App\Exception\custom\ParamException
*/
public
function
undeleteAction
()
{
(
new
OtaValidate
())
->
scene
(
'undelete'
)
->
validate
();
$res
=
OtaService
::
undeleteOne
(
$this
->
params
[
'ota_id'
]);
$this
->
success
([
'status'
=>
$res
?
'success'
:
'failed'
]);
}
/**
/**
* 更新供应商
* 更新供应商
...
@@ -77,7 +90,7 @@ class OtaController extends Base
...
@@ -77,7 +90,7 @@ class OtaController extends Base
public
function
updateAction
()
public
function
updateAction
()
{
{
(
new
OtaValidate
())
->
scene
(
'update'
)
->
validate
();
(
new
OtaValidate
())
->
scene
(
'update'
)
->
validate
();
$res
=
OtaService
::
update
(
$this
->
params
);
$res
=
OtaService
::
update
(
$this
->
params
,
true
);
$this
->
success
([
'status'
=>
$res
?
'success'
:
'failed'
]);
$this
->
success
([
'status'
=>
$res
?
'success'
:
'failed'
]);
}
}
...
...
application/services/goods/OtaService.php
View file @
70a9a8dd
...
@@ -5,6 +5,7 @@ namespace App\Services\goods;
...
@@ -5,6 +5,7 @@ namespace App\Services\goods;
use
App\Exception\custom\GoodsException
;
use
App\Exception\custom\GoodsException
;
use
App\Models\goods\mysql\Ota
;
use
App\Models\goods\mysql\Ota
;
use
Api\PhpServices\Printer\PrinterFactory
;
use
Api\PhpServices\Printer\PrinterFactory
;
use
Validate\OtaValidate
;
class
OtaService
class
OtaService
{
{
...
@@ -18,7 +19,7 @@ class OtaService
...
@@ -18,7 +19,7 @@ class OtaService
* @param int $limit
* @param int $limit
* @return \Api\PhpUtils\Mysql\MysqlBase
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
*/
public
static
function
list
(
$otaName
=
''
,
$printerSN
=
''
,
$printerKey
=
''
,
$labelPrinterSN
=
''
,
$labelPrinterKey
=
''
,
$offset
=
0
,
$limit
=
20
)
public
static
function
list
(
$otaName
=
''
,
$printerSN
=
''
,
$printerKey
=
''
,
$labelPrinterSN
=
''
,
$labelPrinterKey
=
''
,
$isNormal
=
false
,
$offset
=
0
,
$limit
=
20
)
{
{
$otaName
&&
$where
[
'ota_name'
]
=
$otaName
;
$otaName
&&
$where
[
'ota_name'
]
=
$otaName
;
$printerSN
&&
$where
[
"printer_sn"
]
=
$printerSN
;
$printerSN
&&
$where
[
"printer_sn"
]
=
$printerSN
;
...
@@ -26,7 +27,7 @@ class OtaService
...
@@ -26,7 +27,7 @@ class OtaService
$labelPrinterSN
&&
$where
[
"label_printer_sn"
]
=
$labelPrinterSN
;
$labelPrinterSN
&&
$where
[
"label_printer_sn"
]
=
$labelPrinterSN
;
$labelPrinterKey
&&
$where
[
'label_printer_key'
]
=
$labelPrinterKey
;
$labelPrinterKey
&&
$where
[
'label_printer_key'
]
=
$labelPrinterKey
;
//
$where['status'] = Ota::STATUS_NORMAL;
$isNormal
&&
$where
[
'status'
]
=
Ota
::
STATUS_NORMAL
;
$where
[
'ORDER'
]
=
[
'ota_id'
=>
'DESC'
];
$where
[
'ORDER'
]
=
[
'ota_id'
=>
'DESC'
];
$where
[
'LIMIT'
]
=
[
$offset
,
$limit
];
$where
[
'LIMIT'
]
=
[
$offset
,
$limit
];
...
@@ -77,8 +78,10 @@ class OtaService
...
@@ -77,8 +78,10 @@ class OtaService
//检查打印机是否已存在 -- 打印机已被(商家名称)绑定
//检查打印机是否已存在 -- 打印机已被(商家名称)绑定
if
(
isset
(
$params
[
'printer_sn'
])
&&
$params
[
'printer_sn'
])
{
if
(
isset
(
$params
[
'printer_sn'
])
&&
$params
[
'printer_sn'
])
{
if
((
new
OtaValidate
())
->
is_label_printer_sn
(
$params
[
'printer_sn'
]))
{
throw
new
GoodsException
([
'cus'
=>
GoodsException
::
PRINTER_SN_ERROR
]);
}
$printer
=
self
::
list
(
''
,
$params
[
'printer_sn'
]);
$printer
=
self
::
list
(
''
,
$params
[
'printer_sn'
]);
if
(
$printer
[
'total'
]
>
0
)
{
if
(
$printer
[
'total'
]
>
0
)
{
throw
new
GoodsException
(
throw
new
GoodsException
(
[
'cus'
=>
GoodsException
::
PRINTER_ALREADY_EXIST
,
'data'
=>
[
$printer
[
'list'
][
0
][
'ota_name'
]]]
[
'cus'
=>
GoodsException
::
PRINTER_ALREADY_EXIST
,
'data'
=>
[
$printer
[
'list'
][
0
][
'ota_name'
]]]
...
@@ -87,8 +90,11 @@ class OtaService
...
@@ -87,8 +90,11 @@ class OtaService
}
}
//检查标签打印机是否已存在 -- 打印机已被(商家名称)绑定
//检查标签打印机是否已存在 -- 打印机已被(商家名称)绑定
if
(
isset
(
$params
[
'label_printer_sn'
])
&&
$params
[
'label_printer_sn'
])
{
if
(
isset
(
$params
[
'label_printer_sn'
])
&&
$params
[
'label_printer_sn'
])
{
$printer
=
self
::
list
(
''
,
''
,
''
,
$params
[
'label_printer_sn'
]);
if
(
!
(
new
OtaValidate
())
->
is_label_printer_sn
(
$params
[
'label_printer_sn'
]))
{
throw
new
GoodsException
([
'cus'
=>
GoodsException
::
PRINTER_SN_ERROR
]);
}
$printer
=
self
::
list
(
''
,
''
,
''
,
$params
[
'label_printer_sn'
]);
if
(
$printer
[
'total'
]
>
0
)
{
if
(
$printer
[
'total'
]
>
0
)
{
throw
new
GoodsException
(
throw
new
GoodsException
(
[
'cus'
=>
GoodsException
::
LABEL_PRINTER_ALREADY_EXIST
,
'data'
=>
[
$printer
[
'list'
][
0
][
'ota_name'
]]]
[
'cus'
=>
GoodsException
::
LABEL_PRINTER_ALREADY_EXIST
,
'data'
=>
[
$printer
[
'list'
][
0
][
'ota_name'
]]]
...
@@ -145,13 +151,23 @@ class OtaService
...
@@ -145,13 +151,23 @@ class OtaService
return
self
::
update
([
'ota_id'
=>
$otaId
,
'status'
=>
Ota
::
STATUS_DELETE
]);
return
self
::
update
([
'ota_id'
=>
$otaId
,
'status'
=>
Ota
::
STATUS_DELETE
]);
}
}
/**
* 取消删除供应商
* @param $otaId
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
static
function
unDeleteOne
(
$otaId
)
{
return
self
::
update
([
'ota_id'
=>
$otaId
,
'status'
=>
Ota
::
STATUS_NORMAL
]);
}
/**
/**
* 更新供应商信息
* 更新供应商信息
* @param $params
* @param $params
* @return \Api\PhpUtils\Mysql\MysqlBase
* @return \Api\PhpUtils\Mysql\MysqlBase
* @throws GoodsException
* @throws GoodsException
*/
*/
public
static
function
update
(
$params
)
public
static
function
update
(
$params
,
$canUnBind
=
false
)
{
{
if
(
empty
(
$params
[
'ota_id'
]))
{
if
(
empty
(
$params
[
'ota_id'
]))
{
...
@@ -166,24 +182,53 @@ class OtaService
...
@@ -166,24 +182,53 @@ class OtaService
//检查打印机是否已存在 -- 打印机已被(商家名称)绑定
//检查打印机是否已存在 -- 打印机已被(商家名称)绑定
if
(
isset
(
$params
[
'printer_sn'
])
&&
$params
[
'printer_sn'
])
{
if
(
isset
(
$params
[
'printer_sn'
])
&&
$params
[
'printer_sn'
]
&&
$otaDetail
[
'printer_sn'
]
!=
$params
[
'printer_sn'
])
{
$printer
=
self
::
list
(
''
,
$params
[
'printer_sn'
]);
if
((
new
OtaValidate
())
->
is_label_printer_sn
(
$params
[
'printer_sn'
]))
{
throw
new
GoodsException
([
'cus'
=>
GoodsException
::
PRINTER_SN_ERROR
]);
}
$printer
=
self
::
list
(
''
,
$params
[
'printer_sn'
]);
if
(
$printer
[
'total'
]
>
0
)
{
if
(
$printer
[
'total'
]
>
0
)
{
throw
new
GoodsException
(
throw
new
GoodsException
(
[
'cus'
=>
GoodsException
::
PRINTER_ALREADY_EXIST
,
'data'
=>
[
$printer
[
'list'
][
0
][
'ota_name'
]]]
[
'cus'
=>
GoodsException
::
PRINTER_ALREADY_EXIST
,
'data'
=>
[
$printer
[
'list'
][
0
][
'ota_name'
]]]
);
);
}
}
try
{
$FeiPrinter
=
PrinterFactory
::
getPrinter
(
'Fei'
);
$FeiPrinter
->
addPrinter
([
'printer_sn'
=>
$params
[
'printer_sn'
],
'printer_key'
=>
$params
[
'printer_key'
],
'ota_name'
=>
$params
[
'ota_name'
],
]);
}
catch
(
\Exception
$e
)
{
throw
new
GoodsException
([
'cus'
=>
GoodsException
::
PRINTER_BIND_ERROR
,
'data'
=>
[
$e
->
getMessage
()]]);
}
}
}
//检查标签打印机是否已存在 -- 打印机已被(商家名称)绑定
//检查标签打印机是否已存在 -- 打印机已被(商家名称)绑定
if
(
isset
(
$params
[
'label_printer_sn'
])
&&
$params
[
'label_printer_sn'
])
{
if
(
isset
(
$params
[
'label_printer_sn'
])
&&
$params
[
'label_printer_sn'
]
&&
$otaDetail
[
'label_printer_sn'
]
!=
$params
[
'label_printer_sn'
])
{
$printer
=
self
::
list
(
''
,
''
,
''
,
$params
[
'label_printer_sn'
]);
if
(
!
(
new
OtaValidate
())
->
is_label_printer_sn
(
$params
[
'label_printer_sn'
]))
{
throw
new
GoodsException
([
'cus'
=>
GoodsException
::
PRINTER_SN_ERROR
]);
}
$printer
=
self
::
list
(
''
,
''
,
''
,
$params
[
'label_printer_sn'
]);
if
(
$printer
[
'total'
]
>
0
)
{
if
(
$printer
[
'total'
]
>
0
)
{
throw
new
GoodsException
(
throw
new
GoodsException
(
[
'cus'
=>
GoodsException
::
LABEL_PRINTER_ALREADY_EXIST
,
'data'
=>
[
$printer
[
'list'
][
0
][
'ota_name'
]]]
[
'cus'
=>
GoodsException
::
LABEL_PRINTER_ALREADY_EXIST
,
'data'
=>
[
$printer
[
'list'
][
0
][
'ota_name'
]]]
);
);
}
}
try
{
$FeiPrinter
=
PrinterFactory
::
getPrinter
(
'Fei'
);
$FeiPrinter
->
addPrinter
([
'printer_sn'
=>
$params
[
'label_printer_sn'
],
'printer_key'
=>
$params
[
'label_printer_key'
],
'ota_name'
=>
$params
[
'ota_name'
],
]);
}
catch
(
\Exception
$e
)
{
throw
new
GoodsException
([
'cus'
=>
GoodsException
::
PRINTER_BIND_ERROR
,
'data'
=>
[
$e
->
getMessage
()]]);
}
}
}
...
@@ -199,6 +244,15 @@ class OtaService
...
@@ -199,6 +244,15 @@ class OtaService
isset
(
$params
[
'address'
])
&&
$data
[
'address'
]
=
$params
[
'address'
];
isset
(
$params
[
'address'
])
&&
$data
[
'address'
]
=
$params
[
'address'
];
isset
(
$params
[
'status'
])
&&
$data
[
'status'
]
=
$params
[
'status'
];
isset
(
$params
[
'status'
])
&&
$data
[
'status'
]
=
$params
[
'status'
];
// 解绑
if
(
$canUnBind
&&
!
empty
(
$otaDetail
[
'printer_sn'
])
&&
empty
(
$params
[
'printer_sn'
])
&&
empty
(
$params
[
'printer_key'
]))
{
$data
[
'printer_sn'
]
=
$data
[
'printer_key'
]
=
''
;
}
if
(
$canUnBind
&&
!
empty
(
$otaDetail
[
'label_printer_sn'
])
&&
empty
(
$params
[
'label_printer_sn'
])
&&
empty
(
$params
[
'label_printer_key'
]))
{
$data
[
'label_printer_sn'
]
=
$data
[
'label_printer_key'
]
=
''
;
}
return
Ota
::
update
(
return
Ota
::
update
(
$data
,
$data
,
[
'ota_id'
=>
$params
[
'ota_id'
]]
[
'ota_id'
=>
$params
[
'ota_id'
]]
...
...
application/services/user/UserService.php
View file @
70a9a8dd
...
@@ -3,12 +3,12 @@
...
@@ -3,12 +3,12 @@
namespace
App\Services\user
;
namespace
App\Services\user
;
use
Api\PhpUtils\Mon\MonUtil
;
use
App\Models\user\mysql\UserWechatBind
;
use
App\Models\user\mysql\UserWechatBind
;
use
Api\PhpUtils\Http\Request
;
use
Api\PhpUtils\Http\Request
;
use
App\Services\user\Weixin\WxBizDataCrypt
;;
use
App\Services\user\Weixin\WxBizDataCrypt
;;
use
App\Exception\BaseException
;
use
App\Exception\BaseException
;
use
App\Exception\custom\UserException
;
use
App\Exception\custom\UserException
;
use
Api\PhpUtils\Validate\Validate
;
use
Api\PhpUtils\Validate\Validate
;
use
Api\PhpServices\Idgen\Idgen
;
use
Api\PhpServices\Idgen\Idgen
;
use
Api\PhpUtils\Redis\RedisUtil
;
use
Api\PhpUtils\Redis\RedisUtil
;
...
@@ -64,24 +64,18 @@ class UserService
...
@@ -64,24 +64,18 @@ class UserService
];
];
$response
=
(
new
Request
())
->
post
(
$loginUrl
,
$params
);
$response
=
(
new
Request
())
->
post
(
$loginUrl
,
$params
);
$end
=
microtime
(
true
);
$totalTime
=
round
((
$end
-
$begin
),
4
)
*
1000
;
if
(
$response
[
'code'
]
==
0
)
{
if
(
$response
[
'code'
]
==
0
)
{
$response
=
$response
[
'response'
];
$response
=
$response
[
'response'
];
}
}
//mon打点
$env
=
\Yaf\Application
::
app
()
->
environ
()
??
"dev"
;
MonUtil
::
proxyMon
(
$loginUrl
,
$response
[
'code'
],
'weixin_'
.
$env
,
$totalTime
);
if
(
empty
(
$response
)
||
array_key_exists
(
'errcode'
,
$response
))
{
if
(
empty
(
$response
)
||
array_key_exists
(
'errcode'
,
$response
))
{
//throw new \Exception('获取openid失败:' . $response['errcode']);
//throw new \Exception('获取openid失败:' . $response['errcode']);
FileLog
::
error
(
"wechatLogin:获取openid失败"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
FileLog
::
error
(
"wechatLogin:获取openid失败"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
throw
new
UserException
([
'cus'
=>
1
]);
throw
new
UserException
([
'cus'
=>
1
]);
}
}
//检查系统是已注册
//检查系统是已注册
$openid
=
!
empty
(
$response
[
'openid'
])
?
$response
[
'openid'
]
:
''
;
$openid
=
!
empty
(
$response
[
'openid'
])
?
$response
[
'openid'
]
:
''
;
//}
$user
=
UserWechatBind
::
getRecordMaster
([
'openid'
=>
$openid
]);
$user
=
UserWechatBind
::
getRecordMaster
([
'openid'
=>
$openid
]);
...
...
vendor/api/php_services/src/Printer/Fei/FeiPrinter.php
View file @
70a9a8dd
...
@@ -108,6 +108,9 @@ class FeiPrinter extends \Api\PhpServices\Printer\Printer
...
@@ -108,6 +108,9 @@ class FeiPrinter extends \Api\PhpServices\Printer\Printer
if
(
is_array
(
$res
[
'response'
][
'data'
][
'ok'
])
&&
count
(
$res
[
'response'
][
'data'
][
'ok'
])
>
0
)
{
if
(
is_array
(
$res
[
'response'
][
'data'
][
'ok'
])
&&
count
(
$res
[
'response'
][
'data'
][
'ok'
])
>
0
)
{
return
true
;
return
true
;
}
}
if
(
strpos
(
$res
[
'response'
][
'data'
][
'no'
][
0
],
'已被添加过'
))
{
return
true
;
}
throw
new
\Exception
(
$res
[
'response'
][
'data'
][
'no'
][
0
]);
throw
new
\Exception
(
$res
[
'response'
][
'data'
][
'no'
][
0
]);
}
}
throw
new
\Exception
(
$res
[
'response'
][
'msg'
]);
throw
new
\Exception
(
$res
[
'response'
][
'msg'
]);
...
...
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