Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
朱继来
/
后台订单管理
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
04d38872
authored
Jun 17, 2020
by
孙龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
bom
parent
0540a7fb
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
615 additions
and
167 deletions
app/Http/Controllers/BomApiController.php
app/Http/Controllers/WebController.php
app/Model/Bom/BomItemMatchModel.php
app/Model/Bom/BomItemModel.php
app/Model/Bom/BomModel.php
app/Services/Bom/BomService.php
public/js/web/BomReport.js
resources/views/web/BomReport.blade.php
app/Http/Controllers/BomApiController.php
View file @
04d38872
...
...
@@ -82,11 +82,23 @@ class BomApiController extends Controller{
}
/*
* 创建订单
*/
public
function
createBomOrder
(
$request
,
$id
){
$res
=
$this
->
bomService
->
createBomOrder
(
$request
);
return
$this
->
ajaxReturn
(
$res
[
'errcode'
],
$res
[
'errmsg'
]);
}
/*
* 数据报表
*/
public
function
bomReportCount
(
$request
,
$id
){
$res
=
$this
->
bomService
->
bomReportCount
(
$request
);
return
$this
->
ajaxReturn
(
$res
[
'errcode'
],
$res
[
'errmsg'
],
$res
[
'data'
]);
}
}
\ No newline at end of file
app/Http/Controllers/WebController.php
View file @
04d38872
...
...
@@ -335,6 +335,7 @@ class WebController extends Controller
public
function
BomReport
(
$request
,
$data
,
$id
)
{
$data
[
'title'
]
=
'BOM报表'
;
return
view
(
'web'
,
$data
);
}
...
...
app/Model/Bom/BomItemMatchModel.php
View file @
04d38872
...
...
@@ -41,6 +41,81 @@ class BomItemMatchModel extends BomItemMatchBaseModel{
return
self
::
suffix
(
$suffix
)
->
insert
(
$data
);
}
public
function
bomExtend
(){
return
$this
->
belongsTo
(
\App\Model\Bom\BomExtendModel
::
class
,
"bom_id"
,
"bom_id"
);
}
/*
* 获取bom下单型号的数量
*/
public
function
countCOrderBomItems
(
$is_kefu
,
$bom_sn
,
$begin_time
,
$end_time
){
$count
=
0
;
for
(
$i
=
0
;
$i
<=
9
;
$i
++
){
$query
=
self
::
suffix
(
$i
);
$query
=
$this
->
buildCountQuery
(
$query
,
$is_kefu
,
$bom_sn
,
$begin_time
,
$end_time
);
$count
+=
$query
->
where
([
"is_corder"
=>
1
])
->
count
(
"matching_id"
);
}
return
$count
;
}
protected
function
buildCountQuery
(
$query
,
$is_kefu
,
$bom_sn
,
$begin_time
,
$end_time
){
$bom_id
=
0
;
if
(
$bom_sn
!=
""
){
$bom
=
BomModel
::
where
(
"bom_sn"
,
trim
(
$bom_sn
))
->
select
(
"bom_id"
)
->
first
();
$bom_id
=
$bom
?
$bom
->
bom_id
:
0
;
}
if
(
$bom_id
>
0
){
$query
=
$query
->
where
([
"bom_id"
=>
$bom_id
]);
}
$begin_time
=
$begin_time
?
strtotime
(
$begin_time
.
" 00:00:00"
)
:
0
;
$end_time
=
$end_time
?
strtotime
(
$end_time
.
" 23:59:59"
)
:
0
;
if
(
$begin_time
){
if
(
$end_time
){
$query
=
$query
->
where
(
'add_time'
,
">="
,
$begin_time
)
->
where
(
'add_time'
,
"<="
,
$end_time
);
}
else
{
$query
=
$query
->
where
(
'add_time'
,
">="
,
$begin_time
);
}
}
elseif
(
$end_time
){
$query
=
$query
->
where
(
'add_time'
,
"<="
,
$end_time
);
}
if
(
$is_kefu
==
'0'
){
$query
=
$query
->
whereDoesntHave
(
"bomExtend"
,
function
(
$query
)
{
$query
->
where
(
'kefu_id'
,
"!="
,
0
);
});
}
elseif
(
$is_kefu
==
'1'
){
$query
=
$query
->
whereHas
(
"bomExtend"
,
function
(
$query
)
{
$query
->
where
(
'kefu_id'
,
"!="
,
0
);
});
}
return
$query
;
}
/*
* 获取bom提交BOM金额
* $type 1提交的bom金额 2下单的bom金额
*/
public
function
bomAmount
(
$is_kefu
,
$bom_sn
,
$begin_time
,
$end_time
,
$type
=
0
){
$amount
=
0
;
for
(
$i
=
0
;
$i
<=
9
;
$i
++
){
$query
=
self
::
suffix
(
$i
);
$query
=
$this
->
buildCountQuery
(
$query
,
$is_kefu
,
$bom_sn
,
$begin_time
,
$end_time
);
if
(
$type
==
0
){
$query
=
$query
->
where
([
"is_corder"
=>
0
]);
}
elseif
(
$type
==
1
){
$query
=
$query
->
where
([
"is_corder"
=>
1
]);
}
$sumamount
=
$query
->
selectRaw
(
"sum(number*price) as sumamount"
)
->
first
();
$amount
+=
$sumamount
?
$sumamount
->
sumamount
:
0
;
}
return
$amount
;
}
...
...
app/Model/Bom/BomItemModel.php
View file @
04d38872
...
...
@@ -34,6 +34,59 @@ class BomItemModel extends BomItemMatchBaseModel{
return
$query
;
}
public
function
bomExtend
(){
return
$this
->
belongsTo
(
\App\Model\Bom\BomExtendModel
::
class
,
"bom_id"
,
"bom_id"
);
}
/*
* 获取bom提交型号的数量
*/
public
function
countBomItems
(
$is_kefu
,
$bom_sn
,
$begin_time
,
$end_time
){
$count
=
0
;
for
(
$i
=
0
;
$i
<=
9
;
$i
++
){
$query
=
self
::
suffix
(
$i
);
$bom_id
=
0
;
if
(
$bom_sn
!=
""
){
$bom
=
BomModel
::
where
(
"bom_sn"
,
trim
(
$bom_sn
))
->
select
(
"bom_id"
)
->
first
();
$bom_id
=
$bom
?
$bom
->
bom_id
:
0
;
}
if
(
$bom_id
>
0
){
$query
=
$query
->
where
([
"bom_id"
=>
$bom_id
]);
}
$begin_time
=
$begin_time
?
strtotime
(
$begin_time
.
" 00:00:00"
)
:
0
;
$end_time
=
$end_time
?
strtotime
(
$end_time
.
" 23:59:59"
)
:
0
;
if
(
$begin_time
){
if
(
$end_time
){
$query
=
$query
->
where
(
'add_time'
,
">="
,
$begin_time
)
->
where
(
'add_time'
,
"<="
,
$end_time
);
}
else
{
$query
=
$query
->
where
(
'add_time'
,
">="
,
$begin_time
);
}
}
elseif
(
$end_time
){
$query
=
$query
->
where
(
'add_time'
,
"<="
,
$end_time
);
}
if
(
$is_kefu
==
'0'
){
$query
=
$query
->
whereDoesntHave
(
"bomExtend"
,
function
(
$query
)
{
$query
->
where
(
'kefu_id'
,
"!="
,
0
);
});
}
elseif
(
$is_kefu
==
'1'
){
$query
=
$query
->
whereHas
(
"bomExtend"
,
function
(
$query
)
{
$query
->
where
(
'kefu_id'
,
"!="
,
0
);
});
}
$count
+=
$query
->
count
(
"bom_item_id"
);
}
return
$count
;
}
...
...
app/Model/Bom/BomModel.php
View file @
04d38872
<?php
namespace
App\Model\Bom
;
use
Illuminate\Database\Eloquent\Model
;
class
BomModel
extends
BomItemMatchBaseModel
{
protected
$connection
=
'bom'
;
//库名
protected
$table
=
'bom'
;
protected
$primaryKey
=
'bom_id'
;
//设置id
protected
$guarded
=
[
'bom_id'
];
//设置字段黑名单
public
$timestamps
=
true
;
const
CREATED_AT
=
'add_time'
;
const
UPDATED_AT
=
'update_time'
;
protected
$dateFormat
=
'Y-m-d H:i:s'
;
public
static
$STATUS
=
[
1
=>
"正常"
,
2
=>
"删除"
,
];
public
function
fromDateTime
(
$value
){
return
strtotime
(
parent
::
fromDateTime
(
$value
));
}
public
function
scopeSearchByrole
(
$query
,
$role_id
=
""
,
$sale_ids
=
[]){
if
(
$role_id
==
1
){
return
$query
;
}
elseif
(
$role_id
==
2
&&
is_array
(
$sale_ids
)
&&
!
empty
(
$sale_ids
)
&&
count
(
$sale_ids
)
>
0
){
array_push
(
$sale_ids
,
0
);
$wherein
=
implode
(
","
,
$sale_ids
);
$query
=
$query
->
whereRaw
(
"bom_id in (select bom_id from lie_bom_extend where kefu_id in (
{
$wherein
}
))"
);
}
elseif
(
$role_id
==
3
&&
!
is_array
(
$sale_ids
)){
$query
=
$query
->
whereRaw
(
"bom_id in (select bom_id from lie_bom_extend where kefu_id = 0 or kefu_id =
{
$sale_ids
}
)"
);
}
return
$query
;
}
public
function
scopeSearchByBomSn
(
$query
,
$bom_sn
=
""
){
if
(
$bom_sn
!=
''
){
$query
=
$query
->
where
(
'bom_sn'
,
$bom_sn
);
}
return
$query
;
}
public
function
scopeSearchByIsCorder
(
$query
,
$is_corder
=
""
){
if
(
$is_corder
==
"all"
||
$is_corder
==
""
){
return
$query
;
}
else
{
$query
=
$query
->
where
(
'is_corder'
,
intval
(
$is_corder
));
}
return
$query
;
}
public
function
scopeSearchByUserNameOrKefu
(
$query
,
$username
=
""
,
$is_kefu
=
'all'
){
$username
=
trim
(
$username
);
$is_kefu
=
trim
(
$is_kefu
);
if
(
$username
==
""
){
if
(
$is_kefu
==
'0'
){
$query
=
$query
->
whereDoesntHave
(
"bomExtend"
,
function
(
$query
)
{
$query
->
where
(
'kefu_
name'
,
"!="
,
""
);
});
}
elseif
(
$is_kefu
==
'1'
){
$query
=
$query
->
whereHas
(
"bomExtend"
,
function
(
$query
)
{
$query
->
where
(
'kefu_
name'
,
"!="
,
""
);
});
}
return
$query
;
}
else
{
$query
=
$query
->
whereHas
(
"bomExtend"
,
function
(
$query
)
use
(
$username
,
$is_kefu
)
{
if
(
$username
){
$query
->
where
(
'user_name'
,
$username
);
}
if
(
$is_kefu
==
'0'
){
$query
->
where
(
'kefu_
name'
,
"="
,
""
);
}
elseif
(
$is_kefu
==
'1'
){
$query
->
where
(
'kefu_
name'
,
"!="
,
""
);
}
});
}
return
$query
;
}
public
function
scopeSearchByTime
(
$query
,
$begin_time
=
''
,
$end_time
=
''
){
$begin_time
=
$begin_time
?
strtotime
(
$begin_time
.
" 00:00:00"
)
:
0
;
$end_time
=
$end_time
?
strtotime
(
$end_time
.
" 23:59:59"
)
:
0
;
if
(
$begin_time
){
if
(
$end_time
){
$query
=
$query
->
where
(
'add_time'
,
">="
,
$begin_time
)
->
where
(
'add_time'
,
"<="
,
$end_time
);
}
else
{
$query
=
$query
->
where
(
'add_time'
,
">="
,
$begin_time
);
}
}
elseif
(
$end_time
){
$query
=
$query
->
where
(
'add_time'
,
"<="
,
$end_time
);
}
return
$query
;
}
public
function
scopeCreateUserId
(
$query
,
$create_userid
=
0
,
$role
=
null
,
$create_username
=
''
,
$userType
=
0
){
if
(
$userType
==
1
){
return
$query
->
where
(
'create_userid'
,
1000
);
}
if
(
$create_userid
&&
$role
!=
1
){
$query
=
$query
->
where
(
'create_userid'
,
$create_userid
);
}
if
(
$create_username
&&
$role
==
1
){
$query
=
$query
->
where
(
'create_username'
,
"like"
,
"%"
.
trim
(
$create_username
)
.
"%"
);
}
return
$query
;
}
public
function
bomExtend
()
{
return
$this
->
hasOne
(
\App\Model\Bom\BomExtendModel
::
class
,
"bom_id"
,
"bom_id"
);
}
<?php
namespace
App\Model\Bom
;
use
Illuminate\Database\Eloquent\Model
;
class
BomModel
extends
BomItemMatchBaseModel
{
protected
$connection
=
'bom'
;
//库名
protected
$table
=
'bom'
;
protected
$primaryKey
=
'bom_id'
;
//设置id
protected
$guarded
=
[
'bom_id'
];
//设置字段黑名单
public
$timestamps
=
true
;
const
CREATED_AT
=
'add_time'
;
const
UPDATED_AT
=
'update_time'
;
protected
$dateFormat
=
'Y-m-d H:i:s'
;
public
static
$STATUS
=
[
1
=>
"正常"
,
2
=>
"删除"
,
];
public
function
fromDateTime
(
$value
){
return
strtotime
(
parent
::
fromDateTime
(
$value
));
}
public
function
scopeSearchByrole
(
$query
,
$role_id
=
""
,
$sale_ids
=
[]){
if
(
$role_id
==
1
){
return
$query
;
}
elseif
(
$role_id
==
2
&&
is_array
(
$sale_ids
)
&&
!
empty
(
$sale_ids
)
&&
count
(
$sale_ids
)
>
0
){
array_push
(
$sale_ids
,
0
);
$wherein
=
implode
(
","
,
$sale_ids
);
$query
=
$query
->
whereRaw
(
"bom_id in (select bom_id from lie_bom_extend where kefu_id in (
{
$wherein
}
))"
);
}
elseif
(
$role_id
==
3
&&
!
is_array
(
$sale_ids
)){
$query
=
$query
->
whereRaw
(
"bom_id in (select bom_id from lie_bom_extend where kefu_id = 0 or kefu_id =
{
$sale_ids
}
)"
);
}
return
$query
;
}
public
function
scopeSearchByBomSn
(
$query
,
$bom_sn
=
""
){
if
(
$bom_sn
!=
''
){
$query
=
$query
->
where
(
'bom_sn'
,
$bom_sn
);
}
return
$query
;
}
public
function
scopeSearchByIsCorder
(
$query
,
$is_corder
=
""
){
if
(
$is_corder
==
"all"
||
$is_corder
==
""
){
return
$query
;
}
else
{
$query
=
$query
->
where
(
'is_corder'
,
intval
(
$is_corder
));
}
return
$query
;
}
public
function
scopeSearchByUserNameOrKefu
(
$query
,
$username
=
""
,
$is_kefu
=
'all'
){
$username
=
trim
(
$username
);
$is_kefu
=
trim
(
$is_kefu
);
if
(
$username
==
""
){
if
(
$is_kefu
==
'0'
){
$query
=
$query
->
whereDoesntHave
(
"bomExtend"
,
function
(
$query
)
{
$query
->
where
(
'kefu_
id'
,
"!="
,
0
);
});
}
elseif
(
$is_kefu
==
'1'
){
$query
=
$query
->
whereHas
(
"bomExtend"
,
function
(
$query
)
{
$query
->
where
(
'kefu_
id'
,
"!="
,
0
);
});
}
return
$query
;
}
else
{
$query
=
$query
->
whereHas
(
"bomExtend"
,
function
(
$query
)
use
(
$username
,
$is_kefu
)
{
if
(
$username
){
$query
->
where
(
'user_name'
,
$username
);
}
if
(
$is_kefu
==
'0'
){
$query
->
where
(
'kefu_
id'
,
"="
,
0
);
}
elseif
(
$is_kefu
==
'1'
){
$query
->
where
(
'kefu_
id'
,
"!="
,
0
);
}
});
}
return
$query
;
}
public
function
scopeSearchByTime
(
$query
,
$begin_time
=
''
,
$end_time
=
''
){
$begin_time
=
$begin_time
?
strtotime
(
$begin_time
.
" 00:00:00"
)
:
0
;
$end_time
=
$end_time
?
strtotime
(
$end_time
.
" 23:59:59"
)
:
0
;
if
(
$begin_time
){
if
(
$end_time
){
$query
=
$query
->
where
(
'add_time'
,
">="
,
$begin_time
)
->
where
(
'add_time'
,
"<="
,
$end_time
);
}
else
{
$query
=
$query
->
where
(
'add_time'
,
">="
,
$begin_time
);
}
}
elseif
(
$end_time
){
$query
=
$query
->
where
(
'add_time'
,
"<="
,
$end_time
);
}
return
$query
;
}
public
function
scopeCreateUserId
(
$query
,
$create_userid
=
0
,
$role
=
null
,
$create_username
=
''
,
$userType
=
0
){
if
(
$userType
==
1
){
return
$query
->
where
(
'create_userid'
,
1000
);
}
if
(
$create_userid
&&
$role
!=
1
){
$query
=
$query
->
where
(
'create_userid'
,
$create_userid
);
}
if
(
$create_username
&&
$role
==
1
){
$query
=
$query
->
where
(
'create_username'
,
"like"
,
"%"
.
trim
(
$create_username
)
.
"%"
);
}
return
$query
;
}
public
function
bomExtend
()
{
return
$this
->
hasOne
(
\App\Model\Bom\BomExtendModel
::
class
,
"bom_id"
,
"bom_id"
);
}
}
\ No newline at end of file
app/Services/Bom/BomService.php
View file @
04d38872
...
...
@@ -426,7 +426,6 @@ class BomService {
try
{
$err_msg
=
[];
$data
=
$request
->
input
(
"data"
,
''
);
// dump($data);exit;
$bom_id
=
$data
[
0
][
"bom_id"
];
$bom
=
BomModel
::
where
([
"bom_id"
=>
intval
(
$bom_id
)])
->
select
(
"user_id"
,
"where"
)
->
first
();
$user_id
=
$bom
->
user_id
;
...
...
@@ -448,13 +447,13 @@ class BomService {
$extend
[
"delivery_type"
]
=
$delivery_type
;
$extend
[
"currency"
]
=
$currency
;
$extend
[
"bom_id"
]
=
$bom_id
;
dump
(
$extend
);
// dump($data);
$address_id
=
$this
->
getAddress
(
$user_id
);
dump
(
$address_id
)
;
$extend
[
"address_id"
]
=
$address_id
;
$ziying
=
[];
$lianying
=
[];
foreach
(
$data
as
$k
=>
$item
){
if
(
$item
[
"is_corder"
]
==
1
)
continue
;
if
(
in_array
(
$item
[
"match_goods_type"
],[
0
])){
...
...
@@ -463,62 +462,125 @@ class BomService {
$ziying
[
$k
][
"num"
]
=
$item
[
"match_number"
];
}
else
{
//联营
//
$lianying
[
$k
][
"goods_name"
]
=
$item
[
'match_goods_name'
];
$lianying
[
$k
][
"brand_name"
]
=
$item
[
'match_brand_name'
];
$lianying
[
$k
][
"num"
]
=
$item
[
'match_number'
];
$lianying
[
$k
][
"goods_price"
]
=
$item
[
'match_price'
];
$lianying
[
$k
][
"delivery_time"
]
=
$item
[
'match_delivery'
];
$lianying
[
$k
][
"supplier_name"
]
=
$item
[
'match_supplier_name'
];
$lianying
[
$k
][
"id"
]
=
$item
[
'match_goods_id'
];
}
}
//加入购物车
$addZYShopCart
=
$this
->
createZYOrderToShopCart
(
$user_id
,
$ziying
,
$extend
);
if
(
!
empty
(
$addZYShopCart
)
&&
$addZYShopCart
[
'err_code'
]
==
0
){
//假如购物车成功
//获取自营购物车
$car_ids
=
$this
->
getShopCart
(
$user_id
,
3
);
array_push
(
$err_msg
,
$addZYShopCart
[
"err_msg"
]);
if
(
!
empty
(
$car_ids
)){
$extend
[
'address_id'
]
=
$address_id
;
//创建订单
$addzyOrder
=
$this
->
createOrder
(
$user_id
,
$car_ids
,
$extend
,
3
);
if
(
!
empty
(
$addzyOrder
)
&&
$addzyOrder
[
'err_code'
]
==
0
){
//创建订单成功
$this
->
zyOrder
(
$user_id
,
$ziying
,
$extend
,
$err_msg
);
$this
->
lyOrder
(
$user_id
,
$lianying
,
$extend
,
$err_msg
);
}
else
{
if
(
is_array
(
$addzyOrder
)
&&
!
empty
(
$addzyOrder
)){
array_push
(
$err_msg
,
$addzyOrder
[
"err_msg"
]);
}
}
}
return
[
'errcode'
=>
0
,
"errmsg"
=>
"下单成功"
];
}
catch
(
BomException
$e
){
array_push
(
$err_msg
,
$e
->
getMessage
());
return
[
'errcode'
=>
$e
->
getCode
(),
"errmsg"
=>
implode
(
","
,
$err_msg
)];
}
catch
(
\Exception
$e
){
array_push
(
$err_msg
,
$e
->
getMessage
());
return
[
'errcode'
=>-
1
,
"errmsg"
=>
$e
->
getMessage
()];
}
}
}
else
{
//bom加入购物车失败
if
(
is_array
(
$addZYShopCart
)
&&
!
empty
(
$addZYShopCart
)){
array_push
(
$err_msg
,
$addZYShopCart
[
"err_msg"
]);
/*
* 创建联营订单
*/
protected
function
lyOrder
(
$user_id
,
$lianying
,
$extend
,
&
$err_msg
){
//创建购物车
$lyShopCart
=
$this
->
createLYOrderToShopCart
(
$user_id
,
$lianying
,
$extend
,
$err_msg
);
if
(
!
empty
(
$lyShopCart
)
&&
$lyShopCart
[
'err_code'
]
==
0
){
//加入购物车成功
//获取联营购物车
$car_ids
=
$this
->
getShopCart
(
$user_id
,
1
);
// array_push($err_msg,$lyShopCart["err_msg"]);
if
(
!
empty
(
$car_ids
)){
//创建订单 请求api创建联营订单
$addOrder
=
$this
->
createOrder
(
$user_id
,
$car_ids
,
$extend
,
1
);
if
(
!
empty
(
$addOrder
)
&&
$addOrder
[
'err_code'
]
==
0
){
//创建订单成功
return
true
;
}
else
{
if
(
is_array
(
$addOrder
)
&&
!
empty
(
$addOrder
)){
array_push
(
$err_msg
,
$addOrder
[
"err_msg"
]);
}
}
}
}
else
{
//bom加入购物车失败
if
(
is_array
(
$lyShopCart
)
&&
!
empty
(
$lyShopCart
)){
array_push
(
$err_msg
,
$lyShopCart
[
"err_msg"
]);
}
}
return
false
;
}
/*
* 联营添加购物车
*/
protected
function
createLYOrderToShopCart
(
$user_id
,
$lianying
,
$extend
){
$url
=
Config
(
'website.addlyorder_url'
);
$data
[
'bom_id'
]
=
$extend
[
"bom_id"
];
$data
[
'uid'
]
=
intval
(
$user_id
)
?
intval
(
$user_id
)
:
0
;
$data
[
"type"
]
=
2
;
//1-前台,2-后台,3-后台批量添加
$data
[
'delivery_place'
]
=
$extend
[
"delivery_type"
];
$data
[
'data'
]
=
$lianying
;
$data
[
'k1'
]
=
time
();
$data
[
'k2'
]
=
md5
(
md5
(
$data
[
'k1'
])
.
'fh6y5t4rr351d2c3bryi'
);
$response
=
json_decode
(
curlApi
(
$url
,
$data
,
'POST'
),
true
);
return
$response
;
}
// $this->createZYOrder($lianying);
/*
* 创建自营订单
* 1,加入购物车
* 2,下单
*/
protected
function
zyOrder
(
$user_id
,
$ziying
,
$extend
,
&
$err_msg
){
//请求 api接口 加入购物车
$addZYShopCart
=
$this
->
createZYOrderToShopCart
(
$user_id
,
$ziying
,
$extend
);
if
(
!
empty
(
$addZYShopCart
)
&&
$addZYShopCart
[
'err_code'
]
==
0
){
//加入购物车成功
//获取自营购物车
$car_ids
=
$this
->
getShopCart
(
$user_id
,
3
);
if
(
!
empty
(
$car_ids
)){
//创建订单 请求api创建自营订单
$addzyOrder
=
$this
->
createOrder
(
$user_id
,
$car_ids
,
$extend
,
2
);
if
(
!
empty
(
$addzyOrder
)
&&
$addzyOrder
[
'err_code'
]
==
0
){
//创建订单成功
return
true
;
}
else
{
if
(
is_array
(
$addzyOrder
)
&&
!
empty
(
$addzyOrder
)){
array_push
(
$err_msg
,
$addzyOrder
[
"err_msg"
]);
}
}
}
}
else
{
//bom加入购物车失败
if
(
is_array
(
$addZYShopCart
)
&&
!
empty
(
$addZYShopCart
)){
array_push
(
$err_msg
,
$addZYShopCart
[
"err_msg"
]);
}
}
catch
(
BomException
$e
){
return
[
'errcode'
=>
$e
->
getCode
(),
"errmsg"
=>
$e
->
getMessage
()];
}
catch
(
\Exception
$e
){
return
[
'errcode'
=>-
1
,
"errmsg"
=>
$e
->
getMessage
()];
}
return
false
;
}
/*
* 创建订单
*
*/
protected
function
createOrder
(
$user_id
,
$car_ids
,
$extend
,
$type
=
3
){
protected
function
createOrder
(
$user_id
,
$car_ids
,
$extend
,
$type
=
2
){
$url
=
Config
(
'website.api_create_order'
);
$data
[
'bom_id'
]
=
$extend
[
"bom_id"
];
$data
[
'uid'
]
=
intval
(
$user_id
)
?
intval
(
$user_id
)
:
0
;
$data
[
"type"
]
=
2
;
//订单类型:1.联营, 2.自营线上, 3.自营线下, 4.自营其他业务订单
$data
[
"type"
]
=
$type
;
//订单类型:1.联营, 2.自营线上, 3.自营线下, 4.自营其他业务订单
$data
[
"cart_id"
]
=
implode
(
","
,
$car_ids
);
$data
[
'address_id'
]
=
$extend
[
"address_id"
];
$data
[
'k1'
]
=
time
();
...
...
@@ -609,4 +671,55 @@ class BomService {
public
function
bomReportCount
(
$request
){
try
{
$is_kefu
=
$request
->
input
(
"is_kefu"
,
'all'
);
$bom_sn
=
$request
->
input
(
"bom_sn"
,
''
);
$begin_time
=
$request
->
input
(
"begin_time"
,
''
);
$end_time
=
$request
->
input
(
"end_time"
,
''
);
$data
[
'field1'
]
=
"-"
;
$data
[
'field2'
]
=
"-"
;
$data
[
'field3'
]
=
"-"
;
$data
[
'field4'
]
=
"-"
;
$data
[
'field5'
]
=
""
;
$data
[
'field6'
]
=
"-"
;
$data
[
'field7'
]
=
"-"
;
$data
[
'field8'
]
=
"-"
;
$data
[
'field9'
]
=
"-"
;
$data
[
'field10'
]
=
"-"
;
$data
[
'field11'
]
=
"-"
;
$bomModel
=
new
BomModel
;
$bomItemsModel
=
new
BomItemModel
();
$bomItemsMatchModel
=
new
BomItemMatchModel
();
//提交BOM单数量
$data
[
'field1'
]
=
$bomModel
->
SearchByBomSn
(
$bom_sn
)
->
SearchByUserNameOrKefu
(
""
,
$is_kefu
)
->
where
(
"is_corder"
,
1
)
->
SearchByTime
(
$begin_time
,
$end_time
)
->
count
(
"bom_id"
);
//BOM单数量
$data
[
'field2'
]
=
$bomModel
->
SearchByBomSn
(
$bom_sn
)
->
SearchByUserNameOrKefu
(
""
,
$is_kefu
)
->
SearchByTime
(
$begin_time
,
$end_time
)
->
count
(
"bom_id"
);
//提交型号数
$data
[
'field4'
]
=
$bomItemsModel
->
countBomItems
(
$is_kefu
,
$bom_sn
,
$begin_time
,
$end_time
);
//下单型号数
$data
[
'field5'
]
=
$bomItemsMatchModel
->
countCOrderBomItems
(
$is_kefu
,
$bom_sn
,
$begin_time
,
$end_time
);
//提交BOM金额
$data
[
'field7'
]
=
$bomItemsMatchModel
->
bomAmount
(
$is_kefu
,
$bom_sn
,
$begin_time
,
$end_time
,
0
);
//下单BOM金额
$data
[
'field8'
]
=
$bomItemsMatchModel
->
bomAmount
(
$is_kefu
,
$bom_sn
,
$begin_time
,
$end_time
,
1
);
return
[
'errcode'
=>
0
,
"errmsg"
=>
"ok"
,
"data"
=>
$data
];
}
catch
(
BomException
$e
){
return
[
'errcode'
=>
$e
->
getCode
(),
"errmsg"
=>
$e
->
getMessage
(),
"data"
=>
[]];
}
catch
(
\Exception
$e
){
return
[
'errcode'
=>-
1
,
"errmsg"
=>
$e
->
getMessage
(),
"data"
=>
[]];
}
}
}
\ No newline at end of file
public/js/web/BomReport.js
0 → 100644
View file @
04d38872
layui
.
use
([
'form'
,
'table'
,
'laydate'
],
function
()
{
var
form
=
layui
.
form
;
var
table
=
layui
.
table
;
var
laydate
=
layui
.
laydate
;
//时间选择器
laydate
.
render
({
elem
:
'#begin_time'
//指定元素
});
laydate
.
render
({
elem
:
'#end_time'
//指定元素
});
function
initDataCount
(
datax
){
$
.
post
(
"/ajax/bom/bomReportCount"
,
datax
,
function
(
res
){
if
(
res
.
errcode
==
0
){
$
.
each
(
res
.
data
,
function
(
k
,
v
){
$
(
"#"
+
k
).
text
(
v
);
})
}
})
}
initDataCount
({});
$
(
"#test1_button"
).
click
(
function
(){
var
aa
=
$
(
"#test1_form"
).
serialize
()
initDataCount
(
aa
)
})
})
\ No newline at end of file
resources/views/web/BomReport.blade.php
0 → 100644
View file @
04d38872
<div
class=
"layui-col-md12"
style=
"padding-bottom: 15px"
>
<h3>
数据概况
</h3>
<hr>
<form
class=
"layui-form layui-box"
id=
"test1_form"
method=
"post"
>
<div
class=
"layui-form-item"
>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
BOM单号
</label>
<div
class=
"layui-input-inline"
>
<input
type=
"text"
name=
"bom_sn"
placeholder=
"填写BOM单号"
autocomplete=
"off"
class=
"layui-input"
>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
创建日期:
</label>
<div
class=
"layui-input-inline"
>
<input
type=
"text"
name=
"begin_time"
value=
""
autocomplete=
"off"
placeholder=
"选择开始时间"
class=
"layui-input"
id=
"begin_time"
readonly
>
</div>
<div
class=
"layui-form-mid"
>
-
</div>
<div
class=
"layui-input-inline"
>
<input
type=
"text"
name=
"end_time"
value=
""
autocomplete=
"off"
placeholder=
"选择结束时间"
class=
"layui-input"
id=
"end_time"
readonly
>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
客服
</label>
<div
class=
"layui-input-inline"
>
<select
name=
"is_kefu"
lay-verify=
""
lay-search
>
<option
value=
"all"
>
全部
</option>
<option
value=
"1"
>
是
</option>
<option
value=
"0"
>
否
</option>
</select>
</div>
</div>
<div
class=
"layui-inline"
style=
"text-align: center;"
>
<a
id=
"test1_button"
class=
"layui-btn"
>
搜索
</a>
<!-- <button type="button" class="layui-btn layui-btn-normal export">导出</button> -->
</div>
</div>
</form>
<div
class=
"layui-card-body"
>
<table
class=
"layui-table"
id=
"dataCont"
>
<tr>
<th
lay-data=
""
>
提交BOM单数量
</th>
<th
lay-data=
""
>
BOM单数量
</th>
<th
lay-data=
""
>
BOM付款数量
</th>
<th
lay-data=
""
>
提交型号数
</th>
<th
lay-data=
""
>
下单型号数
</th>
<th
lay-data=
>
付款型号数</th
>
<th
lay-data=
>
提交BOM金额</th
>
<th
lay-data=
>
下单BOM金额</th
>
</tr>
<tr>
<th
id=
"field1"
></th>
<th
id=
"field2"
></th>
<th
id=
"field3"
></th>
<th
id=
"field4"
></th>
<th
id=
"field5"
></th>
<th
id=
"field6"
></th>
<th
id=
"field7"
></th>
<th
id=
"field8"
></th>
</tr>
<tr>
<th
>
付款BOM金额
</th>
<th
>
无结果型号
</th>
<th>
询价型号数
</th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
<tr>
<th
id=
"field9"
></th>
<th
id=
"field10"
></th>
<th
id=
"field11"
></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</table>
</div>
</div>
<div
class=
"layui-card"
style=
""
>
<h3>
用户数据
</h3>
<hr>
<form
class=
"layui-form layui-box"
id=
"test5"
method=
"post"
>
<div
class=
"layui-form-item"
>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
创建日期:
</label>
<div
class=
"layui-input-inline"
>
<input
type=
"text"
name=
"begin_time"
value=
""
autocomplete=
"off"
placeholder=
"选择开始时间"
class=
"layui-input"
id=
"begin_time"
readonly
>
</div>
<div
class=
"layui-form-mid"
>
-
</div>
<div
class=
"layui-input-inline"
>
<input
type=
"text"
name=
"end_time"
value=
""
autocomplete=
"off"
placeholder=
"选择结束时间"
class=
"layui-input"
id=
"end_time"
readonly
>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
客服
</label>
<div
class=
"layui-input-inline"
>
<select
name=
"is_kefu"
lay-verify=
""
lay-search
>
<option
value=
"all"
>
全部
</option>
<option
value=
"1"
>
是
</option>
<option
value=
"0"
>
否
</option>
</select>
</div>
</div>
<div
class=
"layui-inline"
style=
"text-align: center;"
>
<button
class=
"layui-btn"
data-type=
"search"
>
搜索
</button>
<!-- <button type="button" class="layui-btn layui-btn-normal export">导出</button> -->
</div>
</div>
</form>
</div>
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