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
bed115f0
Commit
bed115f0
authored
Jun 03, 2025
by
hj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新提交
parent
702b1cb1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
69 deletions
+83
-69
server/app/Rhawn/Repositories/Eloquent/Chemsite/ChemsiteCustomerRepositoryEloquent.php
.../Eloquent/Chemsite/ChemsiteCustomerRepositoryEloquent.php
+1
-2
server/app/Rhawn/Repositories/Eloquent/Chemsite/ChemsiteProductRepositoryEloquent.php
...s/Eloquent/Chemsite/ChemsiteProductRepositoryEloquent.php
+2
-1
server/app/Rhawn/Services/Chemsite/ChemsiteOrdersService.php
server/app/Rhawn/Services/Chemsite/ChemsiteOrdersService.php
+18
-15
server/app/Services/Api/Chemsite/ChemsiteOrdersService.php
server/app/Services/Api/Chemsite/ChemsiteOrdersService.php
+62
-51
No files found.
server/app/Rhawn/Repositories/Eloquent/Chemsite/ChemsiteCustomerRepositoryEloquent.php
View file @
bed115f0
...
...
@@ -51,7 +51,7 @@ class ChemsiteCustomerRepositoryEloquent extends BaseRepository implements Chems
*/
public
function
getCustomerDiscountByCusCode
(
$cusCode
)
{
$customerDiscount
=
Rhawn
Customer
::
query
()
$customerDiscount
=
Chemsite
Customer
::
query
()
->
join
(
'cusdiscount'
,
'cusdiscount.cus_id'
,
'customers.cus_id'
)
->
where
(
'customers.cus_no'
,
$cusCode
)
->
get
();
...
...
@@ -61,7 +61,6 @@ class ChemsiteCustomerRepositoryEloquent extends BaseRepository implements Chems
$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
;
...
...
server/app/Rhawn/Repositories/Eloquent/Chemsite/ChemsiteProductRepositoryEloquent.php
View file @
bed115f0
...
...
@@ -40,7 +40,7 @@ class ChemsiteProductRepositoryEloquent extends BaseRepository implements Chemsi
return
null
;
}
public
function
getProductByPcodeAndBid
(
$pCode
,
$bId
)
public
function
getProductByPcodeAndBid
(
$pCode
,
$bId
,
$comId
)
{
$productsModel
=
ChemsiteProducts
::
query
();
if
(
!
is_array
(
$pCode
)){
...
...
@@ -49,6 +49,7 @@ class ChemsiteProductRepositoryEloquent extends BaseRepository implements Chemsi
$productsModel
->
whereIn
(
'products.p_code'
,
$pCode
);
}
$productsModel
->
where
(
'products.b_id'
,
$bId
);
$productsModel
->
where
(
'products.com_id'
,
$comId
);
$product
=
$productsModel
->
get
();
if
(
$product
){
return
$product
->
toArray
();
...
...
server/app/Rhawn/Services/Chemsite/ChemsiteOrdersService.php
View file @
bed115f0
...
...
@@ -11,34 +11,35 @@
namespace
App\Rhawn\Services\Chemsite
;
use
App\Rhawn\Repositories\Contracts\BhuaSordersRepository
;
use
App\Rhawn\Repositories\Eloquent\BhuaCustomerRepositoryEloquent
;
use
App\Rhawn\Repositories\Eloquent\BhuaProductRepositoryEloquent
;
use
App\Rhawn\Repositories\Contracts\Chemsite\ChemsiteSordersRepository
;
use
App\Rhawn\Repositories\Eloquent\BhuaSoitemsRepositoryEloquent
;
use
App\Rhawn\Repositories\Eloquent\Chemsite\ChemsiteCompanyRepositoryEloquent
;
use
App\Rhawn\Repositories\Eloquent\Chemsite\ChemsiteCustomerRepositoryEloquent
;
use
App\Rhawn\Repositories\Eloquent\Chemsite\ChemsiteProductRepositoryEloquent
;
use
App\Support\Facades\SimpleLogs
;
use
Illuminate\Support\Facades\DB
;
class
ChemsiteOrdersService
{
public
function
__construct
(
BhuaSordersRepository
$bhuaSorder
Repository
)
public
function
__construct
(
ChemsiteSordersRepository
$chemsiteSorders
Repository
)
{
$this
->
bhuaSorderRepository
=
$bhuaSorder
Repository
;
$this
->
chemsiteSordersRepository
=
$chemsiteSorders
Repository
;
}
public
function
getCustomerOrderItems
(
$cusCode
,
$soItems
)
public
function
getCustomerOrderItems
(
$c
omId
,
$c
usCode
,
$soItems
)
{
if
(
empty
(
$soItems
)){
throw
new
\Exception
(
'订单项为空'
,
500
);
}
$customerReopository
=
app
(
Bhua
CustomerRepositoryEloquent
::
class
);
$customerReopository
=
app
(
Chemsite
CustomerRepositoryEloquent
::
class
);
$discount
=
$customerReopository
->
getCustomerDiscountByCusCode
(
$cusCode
);
$total
=
0
;
$weight
=
0
;
$productRepository
=
app
(
Bhua
ProductRepositoryEloquent
::
class
);
$productRepository
=
app
(
Chemsite
ProductRepositoryEloquent
::
class
);
foreach
(
$soItems
as
$k
=>
$v
){
$productInfo
=
$productRepository
->
getProductByPcodeAndBid
(
$v
[
'p_code'
],
$v
[
'brand_id'
]);
$productInfo
=
$productRepository
->
getProductByPcodeAndBid
(
$v
[
'p_code'
],
$v
[
'brand_id'
]
,
$comId
);
if
(
!
$productInfo
){
throw
new
\Exception
(
$v
[
'p_code'
]
.
'产品不存在!'
,
500
);
}
...
...
@@ -56,7 +57,7 @@ class ChemsiteOrdersService
$soItems
[
$k
][
'amount'
]
=
round
(
bcmul
(
$productInfo
[
'p_discount'
],
$v
[
'num'
],
3
),
2
);
$soItems
[
$k
][
'weight'
]
=
round
(
bcmul
(
$productInfo
[
'p_weight'
],
$v
[
'num'
],
3
),
3
);
//得到品牌
$brands
=
DB
::
connection
(
$this
->
bhuaSorder
Repository
->
getConnectionName
())
$brands
=
DB
::
connection
(
$this
->
chemsiteSorders
Repository
->
getConnectionName
())
->
table
(
'brands'
)
->
where
(
'b_id'
,
$productInfo
[
'b_id'
])
->
first
();
...
...
@@ -83,14 +84,16 @@ class ChemsiteOrdersService
* @param $data
* @return false
*/
public
function
createOrders
(
$data
)
public
function
createOrders
(
$data
,
$comId
)
{
$connection
=
DB
::
connection
(
$this
->
bhuaSorder
Repository
->
getConnectionName
());
$connection
=
DB
::
connection
(
$this
->
chemsiteSorders
Repository
->
getConnectionName
());
try
{
$connection
->
beginTransaction
();
$data
[
'sorders'
][
'so_no'
]
=
''
;
$data
[
'sorders'
][
'so_ctime'
]
=
time
();
$data
[
'sorders'
][
'com_id'
]
=
$comId
;
//$data['sorders']['so_creater'] = $data['sorders']['creater'];
//$data['sorders']['so_creater'] = $data['sorders']['creater'];
$orderId
=
$connection
->
table
(
'sorders'
)
->
insertGetId
(
$data
[
'sorders'
]);
...
...
@@ -177,12 +180,12 @@ class ChemsiteOrdersService
public
function
getCustomerOrderItemsByOrderId
(
$cusId
,
$orderId
)
{
return
$this
->
bhuaSorder
Repository
->
getCustomerOrderItemsByOrderId
(
$cusId
,
$orderId
);
return
$this
->
chemsiteSorders
Repository
->
getCustomerOrderItemsByOrderId
(
$cusId
,
$orderId
);
}
public
function
getSordersByOrderNo
(
$orderNo
)
{
$order
=
$this
->
bhuaSorder
Repository
->
getSorderFromOrderNo
(
$orderNo
);
$order
=
$this
->
chemsiteSorders
Repository
->
getSorderFromOrderNo
(
$orderNo
);
if
(
$order
){
return
$order
->
toArray
();
}
...
...
@@ -196,7 +199,7 @@ class ChemsiteOrdersService
public
function
getOrderDispatchDetail
(
$orderNumber
)
{
try
{
$dpdetail
=
$this
->
bhuaSorder
Repository
->
getOrderDispatch
(
$orderNumber
);
$dpdetail
=
$this
->
chemsiteSorders
Repository
->
getOrderDispatch
(
$orderNumber
);
$soItemIds
=
[];
if
(
$dpdetail
){
foreach
(
$dpdetail
as
$detail
){
...
...
server/app/Services/Api/Chemsite/ChemsiteOrdersService.php
View file @
bed115f0
...
...
@@ -13,6 +13,7 @@ namespace App\Services\Api\Chemsite;
use
App\Repositories\Transformers\Rhawn\OrderDetailTransformer
;
use
App\Repositories\Transformers\Rhawn\OrdersDispatchTransformer
;
use
App\Rhawn\Repositories\Eloquent\Chemsite\ChemsiteCompanyRepositoryEloquent
;
use
App\Support\Facades\SimpleLogs
;
class
ChemsiteOrdersService
...
...
@@ -29,25 +30,31 @@ class ChemsiteOrdersService
*/
public
function
createNewCustomerOrders
(
$requestParams
)
{
try
{
try
{
$customer
=
$this
->
chemsiteCustomerService
->
checkCustomerExist
(
$requestParams
[
'customer_code'
]);
if
(
!
isset
(
$requestParams
[
'so_ca_county'
]))
{
if
(
!
isset
(
$requestParams
[
'so_ca_county'
]))
{
$requestParams
[
'so_ca_county'
]
=
''
;
}
$orderItems
=
$this
->
chemsiteOrdersService
->
getCustomerOrderItems
(
$customer
[
'cus_no'
],
$requestParams
[
'items'
]);
if
(
!
$orderItems
){
throw
new
\Exception
(
'货号无法匹配'
,
500
);
$companyInfo
=
app
(
ChemsiteCompanyRepositoryEloquent
::
class
)
->
getCompanyThroughCusCode
(
$requestParams
[
'company_code'
]);
$companyInfo
=
$companyInfo
->
toArray
();
if
(
!
$companyInfo
){
throw
new
\Exception
(
'未找到相应供应商'
,
500
);
}
$express
=
$this
->
bhuaOrdersService
->
getExpress
(
$orderItems
[
'weight'
],
$requestParams
[
'so_ca_province'
],
$orderItems
[
'total'
]
$orderItems
=
$this
->
chemsiteOrdersService
->
getCustomerOrderItems
(
$companyInfo
[
'com_id'
],
$customer
[
'cus_no'
],
$requestParams
[
'items'
]);
if
(
!
$orderItems
)
{
throw
new
\Exception
(
'货号无法匹配'
,
500
);
}
$express
=
$this
->
chemsiteOrdersService
->
getExpress
(
$orderItems
[
'weight'
],
$requestParams
[
'so_ca_province'
],
$orderItems
[
'total'
]
);
$order
=
$this
->
bhuaOrdersService
->
bhuaSorder
Repository
->
getSorderFromOrderCusPo
(
$requestParams
[
'so_cus_po'
]);
if
(
$order
)
{
throw
new
\Exception
(
'不能重复创建新订单!'
,
500
);
$order
=
$this
->
chemsiteOrdersService
->
chemsiteSorders
Repository
->
getSorderFromOrderCusPo
(
$requestParams
[
'so_cus_po'
]);
if
(
$order
)
{
throw
new
\Exception
(
'不能重复创建新订单!'
,
500
);
}
$data
=
[];
...
...
@@ -57,37 +64,39 @@ class ChemsiteOrdersService
$data
[
'sorders'
][
'so_ca_mobile'
]
=
$requestParams
[
'so_ca_mobile'
];
$data
[
'sorders'
][
'so_ca_phone'
]
=
!
isset
(
$requestParams
[
'so_ca_phone'
])
?
''
:
$requestParams
[
'so_ca_phone'
];
if
(
!
isset
(
$requestParams
[
'so_ca_province'
])
||
empty
(
$requestParams
[
'so_ca_province'
]))
{
if
(
!
isset
(
$requestParams
[
'so_ca_province'
])
||
empty
(
$requestParams
[
'so_ca_province'
]))
{
throw
new
\Exception
(
'省份必填'
);
}
else
{
}
else
{
$data
[
'sorders'
][
'so_ca_province'
]
=
$requestParams
[
'so_ca_province'
];
}
if
(
!
isset
(
$requestParams
[
'so_ca_city'
])
||
empty
(
$requestParams
[
'so_ca_city'
]))
{
if
(
!
isset
(
$requestParams
[
'so_ca_city'
])
||
empty
(
$requestParams
[
'so_ca_city'
]))
{
throw
new
\Exception
(
'城市必填'
);
}
else
{
}
else
{
$data
[
'sorders'
][
'so_ca_city'
]
=
$requestParams
[
'so_ca_city'
];
}
if
(
!
isset
(
$requestParams
[
'so_ca_county'
])
||
empty
(
$requestParams
[
'so_ca_county'
]))
{
if
(
!
isset
(
$requestParams
[
'so_ca_county'
])
||
empty
(
$requestParams
[
'so_ca_county'
]))
{
throw
new
\Exception
(
'区县必填'
);
}
else
{
}
else
{
$data
[
'sorders'
][
'so_ca_county'
]
=
$requestParams
[
'so_ca_county'
];
}
if
(
!
isset
(
$requestParams
[
'so_ca_street'
])
||
empty
(
$requestParams
[
'so_ca_street'
]))
{
if
(
!
isset
(
$requestParams
[
'so_ca_street'
])
||
empty
(
$requestParams
[
'so_ca_street'
]))
{
throw
new
\Exception
(
'街道必填'
);
}
else
{
}
else
{
$data
[
'sorders'
][
'so_ca_street'
]
=
$requestParams
[
'so_ca_street'
];
}
if
(
$requestParams
[
'so_ci_method'
]
!=
3
)
{
//得到收票地址
$cusiaddrs_arr
=
$this
->
bhuaCustomerService
->
c
ustomerRepository
->
getCustomerAddressByCusCode
(
$customer
[
'cus_no'
]);
$cusinvoice_arr
=
$this
->
bhuaCustomerService
->
c
ustomerRepository
->
getCustomerInvoiceByCusCode
(
$customer
[
'cus_no'
]);
$cusiaddrs_arr
=
$this
->
chemsiteCustomerService
->
chemsiteC
ustomerRepository
->
getCustomerAddressByCusCode
(
$customer
[
'cus_no'
]);
$cusinvoice_arr
=
$this
->
chemsiteCustomerService
->
chemsiteC
ustomerRepository
->
getCustomerInvoiceByCusCode
(
$customer
[
'cus_no'
]);
if
(
!
$cusiaddrs_arr
)
{
throw
new
\Exception
(
'请至会员中心设置收票地址'
,
500
);
if
(
!
$cusiaddrs_arr
)
{
throw
new
\Exception
(
'请至会员中心设置收票地址'
,
500
);
}
if
(
!
$cusinvoice_arr
)
{
throw
new
\Exception
(
'请至会员中心设置发票信息'
,
500
);
if
(
!
$cusinvoice_arr
)
{
throw
new
\Exception
(
'请至会员中心设置发票信息'
,
500
);
}
$cusiaddrs_arr
=
current
(
$cusiaddrs_arr
);
...
...
@@ -112,6 +121,8 @@ class ChemsiteOrdersService
$data
[
'sorders'
][
'so_standard'
]
=
0
;
$data
[
'sorders'
][
'so_from'
]
=
4
;
}
$data
[
'sorders'
][
'so_creater'
]
=
0
;
//$customer['cus_id'];
if
(
!
isset
(
$requestParams
[
'so_note'
])){
...
...
@@ -137,9 +148,9 @@ class ChemsiteOrdersService
array_push
(
$data
[
'soitems'
],
$soitem
);
}
$orderId
=
$this
->
bhuaOrdersService
->
createOrders
(
$data
);
$orderId
=
$this
->
chemsiteOrdersService
->
createOrders
(
$data
,
$companyInfo
[
'com_id'
]
);
if
(
$orderId
){
$orderDetail
=
$this
->
bhua
OrdersService
->
getCustomerOrderItemsByOrderId
(
$customer
[
'cus_id'
],
$orderId
);
$orderDetail
=
$this
->
chemsite
OrdersService
->
getCustomerOrderItemsByOrderId
(
$customer
[
'cus_id'
],
$orderId
);
//处理运费
if
(
$orderDetail
){
$orderDetail
[
'so_freight_price'
]
=
0
;
...
...
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