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
8cc80fd3
authored
Dec 16, 2019
by
allen
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
订单周迭代
parent
5cff11f3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
396 additions
and
19 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
app/Http/Controllers/ApiController.php
View file @
8cc80fd3
...
...
@@ -193,6 +193,13 @@ class ApiController extends Controller
$data
[
'id'
]
=
$request
->
input
(
'id'
);
$data
[
'remarks'
]
=
$request
->
input
(
'remarks'
);
$data
[
'buyerId'
]
=
$request
->
input
(
'userId'
);
//采购id
$data
[
'batch'
]
=
$request
->
input
(
'batch'
);
//采购id
if
(
$data
[
'buyerId'
]
==
-
1
){
unset
(
$data
[
'buyerId'
]);
}
$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 @
8cc80fd3
...
...
@@ -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
;
...
...
@@ -754,6 +755,12 @@ Class OrderController extends Controller
public
function
templateData
(
Request
$request
,
$id
,
$view_id
)
{
$info
=
$this
->
orderDetail
(
$request
,
$id
);
//获取数组中的采购人id的名字
$this
->
getBuyerName
(
$info
);
// dump($info['order_temp_info']);exit;
$this
->
pageHeader
(
$request
,
$info
,
'订单详情'
);
if
(
$info
[
'order_info'
][
'order_goods_type'
]
==
2
&&
in_array
(
$info
[
'order_info'
][
'order_type'
],
[
1
,
3
]))
{
// 平台自营订单
...
...
@@ -767,6 +774,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
[
'buyerid'
];
}
$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
[
'buyerid'
]){
$info
[
'order_items_info'
][
$key
][
'buyerName'
]
=
$v
[
'name'
];
$info
[
'order_items_info'
][
$key
][
'send_email'
]
=
$v
[
'email'
];
break
;
//找到了就不必再循环这个数组了
}
}
}
}
// 详情页自营其他数据
public
function
selfOtherData
(
&
$info
,
$order_id
)
{
...
...
@@ -2025,4 +2064,100 @@ Class OrderController extends Controller
});
}
/*
发送邮件
*/
public
function
send_mail
(
Request
$request
){
$id
=
$_REQUEST
[
'id'
];
$info
=
$this
->
orderDetail
(
$request
,
$id
);
// $info['order_items_info'];
// $info['order_temp_info']['erp_sn'] =
// dump($info);exit;
//获取数组中的采购人id的名字
$this
->
getBuyerName
(
$info
);
//循环订单详情
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
;
}
//批次
$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
(
$res
->
err_code
==
0
){
echo
json_encode
([
'errcode'
=>
1
,
'errmsg'
=>
'发送成功'
]);
exit
;
}
else
{
echo
json_encode
([
'errcode'
=>-
1
,
'errmsg'
=>
$res
->
msg
]);
exit
;
}
}
}
\ No newline at end of file
app/Http/Function.php
View file @
8cc80fd3
...
...
@@ -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 @
8cc80fd3
...
...
@@ -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 @
8cc80fd3
...
...
@@ -20,4 +20,20 @@ class CmsModel extends Model
return
$user
?
$user
->
name
:
''
;
}
/*
查询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 @
8cc80fd3
This diff is collapsed.
Click to expand it.
resources/views/detail/content.blade.php
View file @
8cc80fd3
This diff is collapsed.
Click to expand it.
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