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
6eaed4b6
authored
Dec 05, 2018
by
朱继来
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
temp2
parent
d3b28a3e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
117 additions
and
10 deletions
app/Http/Controllers/AddOrderController.php
config/params.php
public/js/add_order.js
resources/views/addOffline/content.blade.php
resources/views/addOnline/content.blade.php
resources/views/addOrder/content.blade.php
resources/views/detail/content.blade.php
app/Http/Controllers/AddOrderController.php
View file @
6eaed4b6
...
...
@@ -598,27 +598,94 @@ Class AddOrderController extends Controller
public
function
batchGoodsImport
(
Request
$request
)
{
$file
=
$_FILES
[
'file'
];
// $request->file('file')
$type
=
$request
->
input
(
'type'
);
// 1.联营 2.自营
$filePath
=
$file
[
'tmp_name'
];
// 临时路径
// 获取导入内容
$excel
=
[];
Excel
::
load
(
$filePath
,
function
(
$reader
)
use
(
&
$excel
){
$data
=
$reader
->
getSheet
(
0
);
$excel
=
$data
->
toArray
();
});
return
$this
->
excelValid
(
$excel
,
$type
);
// 验证excel内容
$valid
=
$this
->
excelValid
(
$excel
);
if
(
$valid
[
'errcode'
]
!=
0
)
{
return
$valid
;
}
array_shift
(
$excel
);
// 删除第一行
$type
=
$request
->
input
(
'type'
);
// 1.联营 2.自营
$goods_info
=
$this
->
handleData
(
$excel
,
$type
);
// 推送到API
$data
[
'goods_info'
]
=
$goods_info
;
$data
[
'operator_id'
]
=
$request
->
user
->
userId
;
$data
[
'type'
]
=
$type
;
$data
[
'uid'
]
=
$request
->
input
(
'user_id'
);
$data
[
'delivery_place'
]
=
$request
->
input
(
'delivery_place'
);
$url
=
Config
(
'website.api_domain'
)
.
'cart/addBatchFromOrder'
;
$data
[
'k1'
]
=
time
();
$data
[
'k2'
]
=
md5
(
md5
(
$data
[
'k1'
])
.
'fh6y5t4rr351d2c3bryi'
);
echo
'<pre>'
;
print_r
(
curlApi
(
$url
,
$data
,
"POST"
));
die
;
$temp
=
json_decode
(
curlApi
(
$url
,
$data
,
"POST"
),
true
);
return
[
'errcode'
=>
$temp
[
'err_code'
],
'errmsg'
=>
$temp
[
'err_msg'
]];
}
// 验证导入excel
public
function
excelValid
(
$excel
,
$type
)
public
function
excelValid
(
$excel
)
{
$count
=
count
(
$excel
);
if
(
$count
==
1
)
return
[
'errcode'
=>
1
,
'errmsg'
=>
'未填写物料信息'
];
// if ($type)
// 获取excel菜单栏必填项
$required
=
array_filter
(
$excel
[
0
],
function
(
$v
)
{
return
strpos
(
$v
,
'*'
)
===
false
?
false
:
true
;
});
$required_keys
=
array_keys
(
$required
);
// 必填项keys
$err
=
[
'errcode'
=>
0
,
'errmsg'
=>
'验证成功'
];
// 提示信息
array_walk
(
$excel
,
function
(
$val
,
$key
)
use
(
$required
,
$required_keys
,
&
$err
)
{
// 跳过第一条
if
(
$key
!=
0
)
{
foreach
(
$val
as
$k
=>
$v
)
{
if
(
in_array
(
$k
,
$required_keys
))
{
if
(
empty
(
$v
))
{
// 若必填项值为空,返回提示信息
$err
=
[
'errcode'
=>
1
,
'errmsg'
=>
$required
[
$k
]
.
'列,第'
.
$key
.
'行不能为空'
];
break
;
}
}
}
}
});
return
$err
;
}
// 处理导入内容---赋上字段
public
function
handleData
(
$excel
,
$type
)
{
if
(
$type
==
1
)
{
$map
=
Config
(
'params.joint_map'
);
}
else
{
$map
=
Config
(
'params.self_map'
);
}
$goods_info
=
array_map
(
function
(
$val
)
use
(
$map
)
{
foreach
(
$val
as
$k
=>
$v
)
{
$tmp
[
$map
[
$k
]]
=
$v
;
}
return
$tmp
;
},
$excel
);
return
$goods_info
;
}
}
\ No newline at end of file
config/params.php
View file @
6eaed4b6
...
...
@@ -3,4 +3,21 @@
'joint_addr'
=>
'深圳市龙岗区坂田五和大道南2号万科星火online六栋三楼猎芯科技'
,
// 联营自提地址
'self_addr'
=>
'深圳市光明新区新湖街道楼村社区荔都路32号A栋三楼'
,
// 自营自提地址
// 批量导入物料
'joint_map'
=>
[
0
=>
'goods_name'
,
1
=>
'brand_name'
,
2
=>
'num'
,
3
=>
'goods_price'
,
4
=>
'delivery_time'
,
5
=>
'supplier_name'
,
],
'self_map'
=>
[
0
=>
'id'
,
1
=>
'goods_name'
,
2
=>
'brand_name'
,
3
=>
'num'
,
],
];
\ No newline at end of file
public/js/add_order.js
View file @
6eaed4b6
...
...
@@ -515,6 +515,21 @@
// 批量导入物料
$
(
'.goods_import'
).
click
(
function
()
{
var
user_id
=
$
(
'.user_id'
).
val
();
var
delivery_place
=
1
;
// 1.大陆,2.香港 自营默认是大陆
user_id
=
internal_uid
?
internal_uid
:
user_id
;
// 若是内部下单则使用内部用户ID
if
(
!
user_id
)
{
layer
.
msg
(
'请先选择用户'
);
return
false
;
}
if
(
goods_type
==
1
)
{
delivery_place
=
$
(
'input[name=delivery_place]:checked'
).
val
();
}
// 上传文件
var
form
=
$
(
'<form id="formUpload" method="post" enctype="multipart/form-data">\
<input type="file" name="upload" id="fileInput" accept="application/vnd.ms-excel, application/x-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">\
</form>'
);
...
...
@@ -524,7 +539,8 @@
var
formData
=
new
FormData
();
formData
.
append
(
'file'
,
this
.
files
[
0
]);
formData
.
append
(
'type'
,
type
);
console
.
log
(
formData
)
formData
.
append
(
'user_id'
,
user_id
);
formData
.
append
(
'delivery_place'
,
delivery_place
);
$
.
ajax
({
type
:
"POST"
,
...
...
resources/views/addOffline/content.blade.php
View file @
6eaed4b6
...
...
@@ -85,11 +85,16 @@
.label-prompt
{
padding
:
6px
6px
;}
.get-sku
{
padding
:
3px
6px
;
margin-right
:
20px
;}
</style>
<div
class=
"col-sm-
6
"
>
<div
class=
"col-sm-
12
"
>
<input
type=
"text"
class=
"search-sku"
name=
"sku_id"
value=
""
placeholder=
"请输入SKUID"
>
<a
class=
"btn btn-info get-sku"
>
获取SKU信息
</a>
<span>
快捷入口:
<a
href=
"{{Config('website.search-sku-url-2')}}"
target=
"_blank"
>
查询SKU
</a></span>
<div
class=
"batch-btn"
>
<a
class=
"btn btn-success goods_import"
data-type=
"2"
>
批量导入物料
</a>
<a
class=
"btn btn-info"
href=
"http://img.ichunt.com/doc/excel/template/%E8%87%AA%E8%90%A5%E8%AE%A2%E5%8D%95%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E6%A8%A1%E6%9D%BF.xlsx"
>
自营物料模板下载
</a>
</div>
</div>
</div>
...
...
resources/views/addOnline/content.blade.php
View file @
6eaed4b6
...
...
@@ -228,7 +228,7 @@
<div
class=
"batch-btn"
>
<a
class=
"btn btn-success goods_import"
data-type=
"2"
>
批量导入物料
</a>
<a
class=
"btn btn-info"
href=
"http://img.ichunt.com/doc/excel/template/
b7af3ef88497e57e6cdf45782deb5c15.xlsx"
>
物料模板下载
</a>
<a
class=
"btn btn-info"
href=
"http://img.ichunt.com/doc/excel/template/
%E8%87%AA%E8%90%A5%E8%AE%A2%E5%8D%95%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E6%A8%A1%E6%9D%BF.xlsx"
>
自营
物料模板下载
</a>
</div>
</div>
</div>
...
...
resources/views/addOrder/content.blade.php
View file @
6eaed4b6
...
...
@@ -247,7 +247,7 @@
<div
class=
"batch-btn"
>
<a
class=
"btn btn-success goods_import"
data-type=
"1"
>
批量导入物料
</a>
<a
class=
"btn btn-info"
href=
"http://img.ichunt.com/doc/excel/template/
dcf485c2883829b24320b58b0a6888bc.xlsx"
>
物料模板下载
</a>
<a
class=
"btn btn-info"
href=
"http://img.ichunt.com/doc/excel/template/
%E8%81%94%E8%90%A5%E8%AE%A2%E5%8D%95%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E6%A8%A1%E6%9D%BF.xlsx"
>
联营
物料模板下载
</a>
</div>
</div>
</div>
...
...
resources/views/detail/content.blade.php
View file @
6eaed4b6
...
...
@@ -443,7 +443,7 @@
<td>
{{$v['delivery_time']}}
</td>
<td>
{{$v['supplier_name']}}
</td>
@if ($action_name == 'changeOrder'
&&
count($order_items_info) > 1
&&
$order_info['status'] == 1
)
@if ($action_name == 'changeOrder'
&&
count($order_items_info) > 1
&&
in_array($order_info['status'], [1, 2])
)
<td><a
class=
"btn btn-danger deletegoods"
href=
"javascript:;"
data-id=
"{{$v['rec_id']}}"
>
删除
</a></td>
@endif
</tr>
...
...
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