Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
openApi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hj
openApi
Commits
71715610
Commit
71715610
authored
Jul 28, 2023
by
hj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新
parent
60432502
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
295 additions
and
7 deletions
+295
-7
server/app/Exceptions/AuthenticateException.php
server/app/Exceptions/AuthenticateException.php
+14
-0
server/app/Exceptions/NotFoundHttpException.php
server/app/Exceptions/NotFoundHttpException.php
+14
-0
server/app/Exceptions/ResourcesException.php
server/app/Exceptions/ResourcesException.php
+12
-0
server/app/Exceptions/ServerRunTimeException.php
server/app/Exceptions/ServerRunTimeException.php
+12
-0
server/app/Rhawn/Repositories/Contracts/Chemsite/ChemsiteCustomerRepository.php
...itories/Contracts/Chemsite/ChemsiteCustomerRepository.php
+21
-0
server/app/Rhawn/Repositories/Eloquent/BaseRepository.php
server/app/Rhawn/Repositories/Eloquent/BaseRepository.php
+5
-5
server/app/Rhawn/Repositories/Eloquent/BhuaBrandsRepositoryEloquent.php
...wn/Repositories/Eloquent/BhuaBrandsRepositoryEloquent.php
+2
-2
server/app/Rhawn/Repositories/Eloquent/Chemsite/ChemsiteCustomerRepositoryEloquent.php
.../Eloquent/Chemsite/ChemsiteCustomerRepositoryEloquent.php
+122
-0
server/app/Rhawn/Repositories/Models/Chemsite/ChemsiteCustomer.php
...p/Rhawn/Repositories/Models/Chemsite/ChemsiteCustomer.php
+50
-0
server/app/Rhawn/Services/Chemsite/ChemsiteCustomerService.php
...r/app/Rhawn/Services/Chemsite/ChemsiteCustomerService.php
+43
-0
No files found.
server/app/Exceptions/AuthenticateException.php
0 → 100644
View file @
71715610
<?php
namespace
App\Exceptions
;
use
Illuminate\Auth\AuthenticationException
;
class
AuthenticateException
extends
AuthenticationException
{
public
function
__construct
(
string
$message
=
''
,
array
$guards
=
[],
$redirectTo
=
null
)
{
$this
->
code
=
401
;
parent
::
__construct
(
$message
,
$guards
,
$redirectTo
);
}
}
\ No newline at end of file
server/app/Exceptions/NotFoundHttpException.php
0 → 100644
View file @
71715610
<?php
namespace
App\Exceptions
;
use
Symfony\Component\HttpKernel\Exception\HttpException
;
class
NotFoundHttpException
extends
HttpException
{
public
function
__construct
(
string
$message
=
''
,
\Throwable
$previous
=
null
)
{
parent
::
__construct
(
404
,
$message
,
$previous
);
}
}
server/app/Exceptions/ResourcesException.php
0 → 100644
View file @
71715610
<?php
namespace
App\Exceptions
;
class
ResourcesException
extends
\Exception
{
public
function
__construct
(
string
$message
=
''
,
\Throwable
$previous
=
null
)
{
parent
::
__construct
(
$message
,
200
,
$previous
);
}
}
server/app/Exceptions/ServerRunTimeException.php
0 → 100644
View file @
71715610
<?php
namespace
App\Exceptions
;
class
ServerRunTimeException
extends
\Exception
{
public
function
__construct
(
string
$message
=
''
,
\Throwable
$previous
=
null
)
{
parent
::
__construct
(
$message
,
500
,
$previous
);
}
}
server/app/Rhawn/Repositories/Contracts/Chemsite/ChemsiteCustomerRepository.php
0 → 100644
View file @
71715610
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
App\Rhawn\Repositories\Contracts\Chemsite
;
use
Prettus\Repository\Contracts\RepositoryInterface
;
/**
* Interface UserRepository.
*/
interface
ChemsiteCustomerRepository
extends
RepositoryInterface
{
}
server/app/Rhawn/Repositories/Eloquent/BaseRepository.php
View file @
71715610
...
...
@@ -16,17 +16,17 @@ use Prettus\Repository\Eloquent\BaseRepository as BaseRepositoryEloquent;
abstract
class
BaseRepository
extends
BaseRepositoryEloquent
{
protected
function
getConnectionName
()
protected
function
getConnectionName
()
:
?string
{
return
app
(
$this
->
model
()
)
->
getConnectionName
();
return
$this
->
makeModel
(
)
->
getConnectionName
();
}
protected
function
getTableName
()
protected
function
getTableName
()
:
string
{
return
app
(
$this
->
model
()
)
->
getTable
();
return
$this
->
makeModel
(
)
->
getTable
();
}
public
function
getConnection
()
public
function
getConnection
()
:
\Illuminate\Database\ConnectionInterface
{
return
DB
::
connection
(
$this
->
getConnectionName
());
}
...
...
server/app/Rhawn/Repositories/Eloquent/BhuaBrandsRepositoryEloquent.php
View file @
71715610
...
...
@@ -17,7 +17,7 @@ class BhuaBrandsRepositoryEloquent extends BaseRepository implements BhuaBrandsR
*
* @return string
*/
public
function
model
()
public
function
model
()
:
string
{
return
BhuaBrands
::
class
;
}
...
...
@@ -48,7 +48,7 @@ class BhuaBrandsRepositoryEloquent extends BaseRepository implements BhuaBrandsR
return
null
;
}
public
function
getBrandById
(
$id
)
public
function
getBrandById
(
$id
)
:
array
{
$brand
=
$this
->
findWhere
([
'b_id'
=>
$id
]);
return
$brand
->
toArray
();
...
...
server/app/Rhawn/Repositories/Eloquent/Chemsite/ChemsiteCustomerRepositoryEloquent.php
0 → 100644
View file @
71715610
<?php
namespace
App\Rhawn\Repositories\Eloquent\Chemsite
;
use
App\Rhawn\Repositories\Contracts\Chemsite\ChemsiteCustomerRepository
;
use
App\Rhawn\Repositories\Eloquent\BaseRepository
;
use
App\Rhawn\Repositories\Models\Chemsite\ChemsiteCustomer
;
use
App\Rhawn\Repositories\Models\RhawnCustomer
;
use
Illuminate\Support\Facades\DB
;
/**
* Class UserRepositoryEloquent.
*/
class
ChemsiteCustomerRepositoryEloquent
extends
BaseRepository
implements
ChemsiteCustomerRepository
{
/**
* Specify Model class name.
*
* @return string
*/
public
function
model
()
:
string
{
return
ChemsiteCustomer
::
class
;
}
public
function
getRhawnCustomerThroughtCusCode
(
$cusCode
)
{
$customer
=
$this
->
findWhere
([
'cus_no'
=>
$cusCode
])
->
first
();
if
(
$customer
){
return
$customer
->
toArray
();
}
return
null
;
}
public
function
getCustomerList
(
$where
,
$offset
,
$limit
)
{
$customerModel
=
DB
::
connection
(
$this
->
getConnectionName
())
->
table
(
$this
->
getTableName
());
if
(
!
empty
(
$where
)){
$customerModel
=
$customerModel
->
where
(
$where
);
}
$customerInfo
=
$customerModel
->
offset
(
$offset
)
->
limit
(
$limit
)
->
get
();
if
(
$customerInfo
){
return
$customerInfo
->
toArray
();
}
return
null
;
}
/**
* 获取客户折扣信息
* @param $cusCode
* @return array
*/
public
function
getCustomerDiscountByCusCode
(
$cusCode
)
{
$customerDiscount
=
RhawnCustomer
::
query
()
->
join
(
'cusdiscount'
,
'cusdiscount.cus_id'
,
'customers.cus_id'
)
->
where
(
'customers.cus_no'
,
$cusCode
)
->
get
();
$cusdiscountArr
=
[];
if
(
$customerDiscount
){
$customerDiscount
=
$customerDiscount
->
toArray
();
foreach
(
$customerDiscount
as
$k
=>
$v
){
$cusdiscountArr
[
$v
[
'b_id'
]][
'cd_discount'
]
=
$v
[
'cd_discount'
];
$cusdiscountArr
[
$v
[
'b_id'
]][
'cd_pre_discount'
]
=
$v
[
'cd_pre_discount'
];
}
}
return
$cusdiscountArr
;
}
/**
* 获取客户地址信息
* @param $cusCode
* @return array|null
*/
public
function
getCustomerAddressByCusCode
(
$cusCode
)
{
$customerAddress
=
RhawnCustomer
::
query
()
->
join
(
'cusiaddrs'
,
'cusiaddrs.cus_id'
,
'customers.cus_id'
)
->
where
(
'customers.cus_no'
,
$cusCode
)
->
orderBy
(
'cusiaddrs.cia_if_default'
,
'DESC'
)
->
orderBy
(
'cusiaddrs.cia_id'
,
'DESC'
)
->
get
();
if
(
$customerAddress
){
return
$customerAddress
->
toArray
();
}
return
null
;
}
/**
* 获取客户开票信息
* @param $cusCode
* @return array
*/
public
function
getCustomerInvoiceByCusCode
(
$cusCode
)
{
$customerInvoice
=
RhawnCustomer
::
query
()
->
join
(
'cusinvoice'
,
'cusinvoice.cus_id'
,
'customers.cus_id'
)
->
where
(
'customers.cus_no'
,
$cusCode
)
->
orderBy
(
'cusinvoice.ci_if_default'
,
'DESC'
)
->
orderBy
(
'cusinvoice.ci_id'
,
'DESC'
)
->
get
();
if
(
$customerInvoice
){
$customerInvoice
=
$customerInvoice
->
toArray
();
foreach
(
$customerInvoice
as
&
$invoice
){
if
(
$invoice
[
'ci_type'
]
==
1
){
$invoice
[
'ci_type_name'
]
=
'普票'
;
}
if
(
$invoice
[
'ci_type'
]
==
2
){
$invoice
[
'ci_type_name'
]
=
'专票'
;
}
}
return
$customerInvoice
;
}
return
null
;
}
}
server/app/Rhawn/Repositories/Models/Chemsite/ChemsiteCustomer.php
0 → 100644
View file @
71715610
<?php
namespace
App\Rhawn\Repositories\Models\Chemsite
;
use
App\Repositories\Models\Model
;
class
ChemsiteCustomer
extends
Model
{
protected
$table
=
'customers'
;
protected
$connection
=
'chemsite_mysql'
;
protected
$primaryKey
=
'cus_id'
;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected
$fillable
=
[
];
protected
$guarded
=
[
'created_at'
,
'updated_at'
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected
$hidden
=
[
];
/**
* update时不做自动更新时间操作
* @return null
*/
public
function
getUpdatedAtColumn
()
{
return
null
;
}
public
function
getCreatedAtColumn
()
{
return
null
;
}
}
\ No newline at end of file
server/app/Rhawn/Services/Chemsite/ChemsiteCustomerService.php
0 → 100644
View file @
71715610
<?php
namespace
App\Rhawn\Services\Chemsite
;
use
App\Exceptions\ServerRunTimeException
;
use
App\Rhawn\Repositories\Contracts\Chemsite\ChemsiteCustomerRepository
;
class
ChemsiteCustomerService
{
private
ChemsiteCustomerRepository
$customerRepository
;
public
function
__construct
(
ChemsiteCustomerRepository
$chemsiteCustomerRepository
)
{
$this
->
customerRepository
=
$chemsiteCustomerRepository
;
}
public
function
getCustomerThroughCusCode
(
$cusCode
)
{
return
$this
->
customerRepository
->
getRhawnCustomerThroughtCusCode
(
$cusCode
);
}
public
function
getCustomerListByCusCode
(
$cusNo
,
$offset
,
$limit
)
:
?
array
{
return
$this
->
customerRepository
->
getCustomerList
([
'cus_no'
=>
$cusNo
],
$offset
,
$limit
);
}
/**
* 检查客户信息是否存在
* @param $cusCode
* @return mixed
* @throws ServerRunTimeException
*/
public
function
checkCustomerExist
(
$cusCode
)
{
//查询用户是否存在
$customer
=
$this
->
customerRepository
->
getRhawnCustomerThroughtCusCode
(
$cusCode
);
if
(
!
$customer
){
throw
new
ServerRunTimeException
(
'客户编号为:['
.
$cusCode
.
']的用户不存在!'
);
}
return
$customer
;
}
}
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