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
d6bf41e8
authored
Dec 30, 2019
by
朱继来
Browse files
Options
_('Browse Files')
Download
Plain Diff
合并v3.09
parents
f3d4e84c
6abb2f02
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
226 additions
and
7 deletions
app/Http/Controllers/ApiController.php
app/Http/Controllers/OrderController.php
app/Http/Function.php
app/Http/routes.php
app/Model/CmsModel.php
public/js/order.js
resources/views/detail/content.blade.php
resources/views/orderlist/content.blade.php
app/Http/Controllers/ApiController.php
View file @
d6bf41e8
...
...
@@ -193,6 +193,13 @@ class ApiController extends Controller
$data
[
'id'
]
=
$request
->
input
(
'id'
);
$data
[
'remarks'
]
=
$request
->
input
(
'remarks'
);
$data
[
'buyer_id'
]
=
$request
->
input
(
'userId'
);
//采购id
$data
[
'batch'
]
=
$request
->
input
(
'batch'
);
//采购id
if
(
$data
[
'buyer_id'
]
==
-
1
){
unset
(
$data
[
'buyer_id'
]);
}
$result
=
$OrderItemsModel
->
updateData
(
$data
);
...
...
@@ -204,4 +211,22 @@ class ApiController extends Controller
}
/*
检查内部系统用户是否存在
*/
public
function
check_user_exists
(
$request
){
$CmsModel
=
new
CmsModel
();
$userName
=
$request
->
input
(
'user'
);
$user_info
=
$CmsModel
->
getUserInfo
(
array
(
'name'
=>
$userName
));
if
(
$user_info
){
$this
->
Export
(
1
,
'success'
,
$user_info
[
'userId'
]);
}
else
{
$this
->
Export
(
-
1
,
'error'
);
}
}
}
app/Http/Controllers/OrderController.php
View file @
d6bf41e8
...
...
@@ -17,6 +17,7 @@ use App\Model\UserMainModel;
use
App\Model\OrderActionLogModel
;
use
App\Model\OrderReturnModel
;
use
App\Model\OrderItemsTrackModel
;
use
App\Model\CmsModel
;
use
Session
;
use
Hprose\Http\Client
;
...
...
@@ -398,9 +399,10 @@ Class OrderController extends Controller
$info
=
$this
->
getPageInfo
(
$request
);
$map
=
array
();
// 页面参数
$map
[
'order_type'
]
=
$request
->
input
(
'order_type'
,
''
);
$map
[
'select_time_val'
]
=
$request
->
input
(
'select_time_val'
,
''
);
$map
[
'order_contain'
]
=
$request
->
input
(
'order_contain'
,
''
);
$map
[
'order_sn'
]
=
$request
->
input
(
'order_sn'
,
''
);
$map
[
'erp_sn'
]
=
$request
->
input
(
'erp_sn'
,
''
);
...
...
@@ -494,7 +496,7 @@ Class OrderController extends Controller
public
function
getOrderInfo
(
$request
,
$tid
=
1
)
{
$info
=
$this
->
_search
(
$request
,
$tid
);
$key
=
Config
(
'perm_args.redis_search_sales'
)[
$tid
];
$redis
=
Redis
::
connection
(
'read'
);
$sale_list
=
$redis
->
get
(
$key
);
...
...
@@ -747,6 +749,7 @@ Class OrderController extends Controller
public
function
templateData
(
Request
$request
,
$id
,
$view_id
)
{
$info
=
$this
->
orderDetail
(
$request
,
$id
);
$this
->
pageHeader
(
$request
,
$info
,
'订单详情'
);
if
(
$info
[
'order_info'
][
'order_goods_type'
]
==
2
&&
in_array
(
$info
[
'order_info'
][
'order_type'
],
[
1
,
3
]))
{
// 平台自营订单
...
...
@@ -760,6 +763,38 @@ Class OrderController extends Controller
return
view
(
$view_id
,
$info
);
}
/*
获取采购人名称
*/
public
function
getBuyerName
(
&
$info
){
if
(
count
(
$info
[
'order_items_info'
])
<=
0
){
return
;
}
foreach
(
$info
[
'order_items_info'
]
as
$key
=>
$value
)
{
$data
[]
=
$value
[
'buyer_id'
];
}
$CmsModel
=
new
CmsModel
();
$name_data
=
$CmsModel
->
getBatchUserName
(
$data
);
foreach
(
$info
[
'order_items_info'
]
as
$key
=>
$value
)
{
foreach
(
$name_data
as
$k
=>
$v
)
{
if
(
$v
[
'userId'
]
==
$value
[
'buyer_id'
]){
$info
[
'order_items_info'
][
$key
][
'buyerName'
]
=
$v
[
'name'
];
$info
[
'order_items_info'
][
$key
][
'send_email'
]
=
$v
[
'email'
];
break
;
//找到了就不必再循环这个数组了
}
}
}
}
// 详情页自营其他数据
public
function
selfOtherData
(
&
$info
,
$order_id
)
{
...
...
@@ -790,6 +825,7 @@ Class OrderController extends Controller
public
function
changeOrder
(
Request
$request
,
$id
)
{
$info
=
$this
->
orderDetail
(
$request
,
$id
);
$this
->
pageHeader
(
$request
,
$info
,
'人工审单'
,
[
"title"
=>
'人工审单'
,
"href"
=>
'#'
]);
if
(
$info
[
'order_info'
][
'order_goods_type'
]
==
2
&&
in_array
(
$info
[
'order_info'
][
'order_type'
],
[
1
,
3
]))
{
// 平台自营订单
...
...
@@ -1549,6 +1585,9 @@ Class OrderController extends Controller
$response
=
array_merge
(
$response
,
$info
);
// 获取数组中的采购人id的名字
$this
->
getBuyerName
(
$response
);
return
$response
;
}
...
...
@@ -2020,4 +2059,100 @@ Class OrderController extends Controller
});
}
/*
发送邮件
*/
public
function
send_mail
(
Request
$request
){
$id
=
$_REQUEST
[
'id'
];
$info
=
$this
->
orderDetail
(
$request
,
$id
);
//循环订单详情
foreach
(
$info
[
'order_items_info'
]
as
$key
=>
$value
)
{
$tmp
[
'orderNum'
]
=
$info
[
'order_temp_info'
][
'erp_sn'
];
$tmp
[
'goods'
]
=
$value
[
'goods_name'
];
$tmp
[
'purchasingPrice'
]
=
$value
[
'goods_price'
];
//采购价
$tmp
[
'unitPrice'
]
=
$value
[
'goods_price'
];
//单价
$tmp
[
'brand'
]
=
$value
[
'brand_name'
];
$tmp
[
'nums'
]
=
$value
[
'goods_number'
];
$tmp
[
'currency'
]
=
$info
[
'order_info'
][
'currency'
]
==
1
?
'人民币'
:
'美元'
;
$tmp
[
'totalPrice'
]
=
$value
[
'goods_amount'
];
$tmp
[
'remarks'
]
=
$value
[
'remarks'
];
$tmp
[
'material'
]
=
$value
[
'erp_rec_id'
];
$tmp
[
'purchasing'
]
=
!
empty
(
$value
[
'buyerName'
])
?
$value
[
'buyerName'
]
:
''
;
$tmp
[
'projectId'
]
=
$key
+
1
;
if
(
empty
(
$value
[
'batch'
])){
$msg
=
'商品:'
.
$tmp
[
'goods'
]
.
'缺少批次<br/>'
.
'请填写批次后再发送'
;
echo
json_encode
([
'errcode'
=>-
1
,
'errmsg'
=>
$msg
]);
exit
;
}
if
(
empty
(
$value
[
'buyerName'
])){
$msg
=
'商品:'
.
$tmp
[
'goods'
]
.
'缺少采购人员<br/>'
.
'请填写采购后再发送'
;
echo
json_encode
([
'errcode'
=>-
1
,
'errmsg'
=>
$msg
]);
exit
;
}
//批次
$tmp
[
'deliveryTime'
]
=
$value
[
'batch'
];
$tmp
[
'send_email'
]
=
!
empty
(
$value
[
'send_email'
])
?
$value
[
'send_email'
]
:
''
;
$data
[
'data'
][]
=
$tmp
;
}
//循环出邮件接收人
foreach
(
$data
[
'data'
]
as
$key
=>
$value
)
{
$send_mail_array
[]
=
$value
[
'send_email'
];
}
$send_mail_array
=
array_unique
(
$send_mail_array
);
$data
[
'combined'
]
=
$info
[
'order_info'
][
'order_amount'
];
$data
[
'order_amount'
]
=
$info
[
'order_info'
][
'order_amount'
];
$data
[
'date'
]
=
date
(
'Y-m-d'
,
time
());
if
(
empty
(
$send_mail_array
[
0
])){
echo
json_encode
([
'errcode'
=>-
1
,
'errmsg'
=>
'没有填写采购人员,请至少填写一个采购人员'
]);
exit
;
}
$data
[
'toUser'
]
=
$send_mail_array
[
0
];
unset
(
$send_mail_array
[
0
]);
$data
[
'ccUser'
]
=
$send_mail_array
;
$CmsModel
=
new
CmsModel
();
//获取业务员
$data
[
'id'
]
=
$CmsModel
->
getUserName
(
$info
[
'order_info'
][
'sale_id'
]);
$crm_url
=
Config
(
'website.crm_domain'
)
.
'/api/sendCaiGouEmailByOrderAdmin'
;
$data
=
json_encode
(
$data
);
$crm_header
=
array
(
'api-key: crm a1b2c3d4e5f6g7h8i9jk'
);
$res
=
json_decode
(
post_curl
(
$crm_url
,
$data
,
$crm_header
));
if
(
!
empty
(
$res
->
err_code
)
&&
$res
->
err_code
==
0
){
echo
json_encode
([
'errcode'
=>
1
,
'errmsg'
=>
'发送成功'
]);
exit
;
}
else
{
echo
json_encode
([
'errcode'
=>-
1
,
'errmsg'
=>
'邮件发送接口错误,邮件发送失败'
]);
exit
;
}
}
}
\ No newline at end of file
app/Http/Function.php
View file @
d6bf41e8
...
...
@@ -482,4 +482,29 @@ function S_hash($key, $field='', $value='')
}
return
$redis
->
hset
(
$key
,
$field
,
$value
);
}
// curl post
function
post_curl
(
$url
,
$data
,
$headers
=
array
(),
$cookie
=
""
)
{
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$ch
,
CURLOPT_HEADER
,
0
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$ch
,
CURLOPT_POST
,
1
);
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$data
);
curl_setopt
(
$ch
,
CURLOPT_TIMEOUT
,
3
);
if
(
count
(
$headers
)){
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
$headers
);
}
if
(
$cookie
){
curl_setopt
(
$ch
,
CURLOPT_COOKIE
,
$cookie
);
}
if
(
strpos
(
$url
,
'https://'
)
!==
false
)
{
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYHOST
,
1
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
false
);
}
$output
=
curl_exec
(
$ch
);
curl_close
(
$ch
);
return
$output
;
}
\ No newline at end of file
app/Http/routes.php
View file @
d6bf41e8
...
...
@@ -62,6 +62,7 @@ Route::group(['middleware' => 'web'], function () {
Route
::
resource
(
'/prompt'
,
'PromptController@index'
);
Route
::
get
(
'/count'
,
'OrderCountController@count'
);
Route
::
post
(
'/send_mail'
,
'OrderController@send_mail'
);
Route
::
get
(
'/self_count'
,
'OrderCountController@selfCount'
);
Route
::
get
(
'/amount'
,
'OrderCountController@amount'
);
Route
::
get
(
'/self_amount'
,
'OrderCountController@selfAmount'
);
...
...
app/Model/CmsModel.php
View file @
d6bf41e8
...
...
@@ -32,4 +32,20 @@ class CmsModel extends Model
return
$user
?
$user
->
userId
:
0
;
}
/*
查询cms系统用户信息
*/
public
function
getUserInfo
(
$where
){
return
$this
->
where
(
$where
)
->
select
(
'userId'
)
->
first
();
}
/*
批量查询用户姓名
*/
public
function
getBatchUserName
(
$user_ids
){
return
$this
->
whereIn
(
'userId'
,
$user_ids
)
->
select
(
'userId'
,
'name'
,
'email'
)
->
get
()
->
toArray
();
}
}
\ No newline at end of file
public/js/order.js
View file @
d6bf41e8
This diff is collapsed.
Click to expand it.
resources/views/detail/content.blade.php
View file @
d6bf41e8
This diff is collapsed.
Click to expand it.
resources/views/orderlist/content.blade.php
View file @
d6bf41e8
...
...
@@ -43,14 +43,25 @@
</dd>
</dl>
<dl>
<dt>
创建日期:
</dt>
<dd
style=
"width:auto !important;"
>
<input
type=
"text"
name=
"time_start"
value=
"{{ !empty($condition['time_start']) ? date('Y/m/d', $condition['time_start']) : '' }}"
class=
"Wdate "
onfocus=
"WdatePicker({dateFmt:'yyyy/MM/dd'})"
placeholder=
"开始时间"
autocomplete=
"off"
/>
<dd
style=
"width: 110px;"
>
<div
class=
"droplist"
data-default=
"{{$condition['select_time_type']}}"
id=
"select_time_type"
name=
"select_time_type"
>
<ul
class=
"dropdown-menu"
>
<li
class=
"select_time_type_tab active"
data-val=
""
>
创建日期
</li>
<li
class=
"select_time_type_tab"
data-val=
"1"
>
审核日期
</li>
<li
class=
"select_time_type_tab"
data-val=
"2"
>
收款日期
</li>
<li
class=
"select_time_type_tab"
data-val=
"3"
>
发货日期
</li>
<li
class=
"select_time_type_tab"
data-val=
"4"
>
订单完成
</li>
</ul>
</div>
</dd>
<dd
style=
"width:auto !important;"
>
<!-- <dt>创建日期: </dt> -->
<dd
style=
"width: 120px;"
>
<input
type=
"text"
name=
"time_start"
value=
"{{ !empty($condition['time_start']) ? date('Y/m/d', $condition['time_start']) : '' }}"
class=
"Wdate "
onfocus=
"WdatePicker({dateFmt:'yyyy/MM/dd'})"
placeholder=
"开始时间"
autocomplete=
"off"
style=
"width: 140px;"
/>
</dd>
<dd
style=
"width: 120px; margin-left: 20px;"
>
<input
type=
"text"
name=
"time_end"
value=
"{{ !empty($condition['time_end']) ? date('Y/m/d', $condition['time_end']) : '' }}"
class=
"Wdate "
onfocus=
"WdatePicker({dateFmt:'yyyy/MM/dd'})"
placeholder=
"结束时间"
autocomplete=
"off"
/>
</dd>
</dl>
</dl>
<dl>
<dt>
型号名称:
</dt>
<dd>
...
...
@@ -69,6 +80,9 @@
</select>
</dd>
</dl>
<dl>
<dt>
付款类型:
</dt>
<dd>
...
...
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