Commit 1ad91e2c by 朱继来

Merge branch 'master' of http://119.23.72.7/zhujilai/Order into zjl_iteration_20181127

parents 7ddcc0c8 698861e8
...@@ -10,6 +10,7 @@ use Cookie; ...@@ -10,6 +10,7 @@ use Cookie;
use App\Http\Page; use App\Http\Page;
use App\Http\Controllers\PermController; use App\Http\Controllers\PermController;
use App\Http\Error; use App\Http\Error;
use Excel;
Class AddOrderController extends Controller Class AddOrderController extends Controller
{ {
...@@ -317,11 +318,17 @@ Class AddOrderController extends Controller ...@@ -317,11 +318,17 @@ Class AddOrderController extends Controller
$data['uid'] = $request->input('uid'); $data['uid'] = $request->input('uid');
$data['num'] = $request->input('num'); $data['num'] = $request->input('num');
$data['cart_id'] = $request->input('cart_id'); $data['cart_id'] = $request->input('cart_id');
$type = $request->input('type'); // 3-批量添加的商品
$goods_type = $request->input('goods_type');
$data['k1'] = time(); $data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi'); $data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
$url = Config('website.api_domain').'cart/changeNumByOrderSystem'; if ($type == 3 && $goods_type == 1) { // 联营批量添加
$url = Config('website.api_domain').'cart/changeNumForJoint';
} else {
$url = Config('website.api_domain').'cart/changeNumByOrderSystem';
}
$response = json_decode(curlApi($url, $data), true); $response = json_decode(curlApi($url, $data), true);
...@@ -593,4 +600,106 @@ Class AddOrderController extends Controller ...@@ -593,4 +600,106 @@ Class AddOrderController extends Controller
} }
} }
// 商品批量导入
public function batchGoodsImport(Request $request)
{
$file = $_FILES['file']; // $request->file('file')
$filePath = $file['tmp_name']; // 临时路径
// 获取导入内容
$excel = [];
Excel::load($filePath, function($reader) use(&$excel){
$data = $reader->getSheet(0);
$excel = $data->toArray();
});
$type = $request->input('type'); // 1.联营 2.自营
if ($type == 1) {
$map = Config('params.joint_map');
$type_val = '联营';
} else {
$map = Config('params.self_map');
$type_val = '自营';
}
if (count($map) != count($excel[0])) return ['errcode' => 1, 'errmsg' => '导入模板错误,需导入'.$type_val.'模板'];
// 验证excel内容
$valid = $this->excelValid($excel);
if ($valid['errcode'] != 0) {
return $valid;
}
array_shift($excel); // 删除第一行
$goods_info = $this->handleData($excel, $map); // 处理数据
// 推送到API
$data['data'] = $goods_info;
$data['operator_id'] = $request->user->userId;
$data['type'] = 3; // 后台批量添加标记
$data['uid'] = $request->input('user_id');
$data['delivery_place'] = $request->input('delivery_place');
if ($type == 1) { // 联营
$url = Config('website.api_domain').'cart/addBatchByOrderSystem';
} else {
$url = Config('website.api_domain').'cart/addBatch';
}
$data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
$temp = json_decode(curlApi($url, $data, "POST"), true);
return ['errcode' => $temp['err_code'], 'errmsg' => $temp['err_msg']];
}
// 验证导入excel
public function excelValid($excel)
{
$count = count($excel);
if ($count == 1) return ['errcode' => 1, 'errmsg' => '未填写物料信息'];
// 获取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, $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
...@@ -573,6 +573,8 @@ Class OrderController extends Controller ...@@ -573,6 +573,8 @@ Class OrderController extends Controller
{ {
$shipping = DB::connection('order')->table('lie_shipping')->select('shipping_id', 'shipping_name')->get(); $shipping = DB::connection('order')->table('lie_shipping')->select('shipping_id', 'shipping_name')->get();
$info['shippings'] = [];
if ($shipping) { if ($shipping) {
foreach ($shipping as $v) { foreach ($shipping as $v) {
$shippingInfo[$v->shipping_id] = $v->shipping_name; $shippingInfo[$v->shipping_id] = $v->shipping_name;
......
...@@ -100,6 +100,7 @@ Route::group(['middleware' => 'web'], function () { ...@@ -100,6 +100,7 @@ Route::group(['middleware' => 'web'], function () {
Route::post('/ajax/selfCheck', 'AddOrderController@selfCheck'); Route::post('/ajax/selfCheck', 'AddOrderController@selfCheck');
Route::post('/ajax/switchSaleType', 'AddOrderController@switchSaleType'); Route::post('/ajax/switchSaleType', 'AddOrderController@switchSaleType');
Route::post('/ajax/checkStock', 'AddOrderController@checkStock'); Route::post('/ajax/checkStock', 'AddOrderController@checkStock');
Route::post('/ajax/batchGoodsImport', 'AddOrderController@batchGoodsImport');
Route::match(['get', 'post'],'/web/{key}', 'WebController@info'); Route::match(['get', 'post'],'/web/{key}', 'WebController@info');
Route::match(['get', 'post'],'/api/{key}', 'ApiController@Entrance'); Route::match(['get', 'post'],'/api/{key}', 'ApiController@Entrance');
......
...@@ -3,4 +3,21 @@ ...@@ -3,4 +3,21 @@
'joint_addr' => '深圳市龙岗区坂田五和大道南2号万科星火online六栋三楼猎芯科技', // 联营自提地址 'joint_addr' => '深圳市龙岗区坂田五和大道南2号万科星火online六栋三楼猎芯科技', // 联营自提地址
'self_addr' => '深圳市光明新区新湖街道楼村社区荔都路32号A栋三楼', // 自营自提地址 '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
...@@ -95,6 +95,21 @@ li { ...@@ -95,6 +95,21 @@ li {
border-radius: 3px; border-radius: 3px;
} }
.search-user, .search-sku {
width: 240px !important;
}
.label-prompt {
padding: 6px 6px;
}
.get-user, .get-sku {
padding: 3px 6px;
margin-right: 20px;
}
.batch-btn {
float: right;
}
.order-invoice select { .order-invoice select {
width: 150px !important; width: 150px !important;
} }
...@@ -103,7 +118,7 @@ li { ...@@ -103,7 +118,7 @@ li {
resize: none; resize: none;
} }
/*新增订单*/ /* 后台新增订单 start */
.user-info, .address-content, .invoice-content, .order-info { .user-info, .address-content, .invoice-content, .order-info {
display: none; display: none;
} }
...@@ -193,6 +208,8 @@ li { ...@@ -193,6 +208,8 @@ li {
.con-val { .con-val {
float: left; float: left;
} }
/* END */
.other-infos, .click-up{ .other-infos, .click-up{
display: none; display: none;
...@@ -207,7 +224,7 @@ li { ...@@ -207,7 +224,7 @@ li {
} }
.payment-status { .payment-status {
width: 420px; width: 420px !important;
} }
/* 响应式 */ /* 响应式 */
...@@ -230,7 +247,7 @@ li { ...@@ -230,7 +247,7 @@ li {
.show-list-info { display: none; } .show-list-info { display: none; }
.payment-status { width: 220px; } .payment-status { width: 220px !important; }
} }
@media screen and (max-width: 460px) { @media screen and (max-width: 460px) {
......
...@@ -267,10 +267,15 @@ ...@@ -267,10 +267,15 @@
html += '<tr><th>阶梯</th><th>RMB价格</th>'; html += '<tr><th>阶梯</th><th>RMB价格</th>';
if (data.ac_type == 1) { if (data.ac_type) {
html += '<th>活动价</th>'; switch (data.ac_type) {
case 1: html += '<th>限时限量</th>'; break;
case 2: html += '<th>活动价</th>'; break;
case 3: html += '<th>会员价</th>'; break;
default: html += ''; break;
}
} }
if (goods_type == 1) { if (goods_type == 1) {
html += '<th>USD价格</th>'; html += '<th>USD价格</th>';
} }
...@@ -400,6 +405,7 @@ ...@@ -400,6 +405,7 @@
var self = $(this); var self = $(this);
var num = self.val(); var num = self.val();
var cart_id = self.parents('tr').data('cid'); var cart_id = self.parents('tr').data('cid');
var type = self.parents('tr').data('type');
var user_id = 0; var user_id = 0;
if (is_online) { if (is_online) {
...@@ -411,7 +417,7 @@ ...@@ -411,7 +417,7 @@
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: '/ajax/changeNum', url: '/ajax/changeNum',
data: {uid : user_id, num : num, cart_id : cart_id}, data: {uid: user_id, num: num, cart_id: cart_id, type: type, goods_type: goods_type},
dataType: "json", dataType: "json",
success: function(resp){ success: function(resp){
if (resp.errcode == 0) { if (resp.errcode == 0) {
...@@ -513,6 +519,59 @@ ...@@ -513,6 +519,59 @@
} }
}) })
// 批量导入物料
$('.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>');
var type = $(this).data('type'); // 1-联营模板,2-自营模板
form.find('input').change(function(){
var formData = new FormData();
formData.append('file', this.files[0]);
formData.append('type', type);
formData.append('user_id', user_id);
formData.append('delivery_place', delivery_place);
$.ajax({
type: "POST",
url: '/ajax/batchGoodsImport',
data: formData,
dataType: 'json',
cache: false,
processData: false,
contentType: false,
success: function(resp){
if (resp.errcode == 0) {
layer.msg(resp.errmsg);
loading.lists(user_id, goods_type, is_online); // 加载购物车列表
return false;
}
layer.msg(resp.errmsg);
},
})
})
form.find('input[type="file"]').trigger('click');
})
// 提交订单 // 提交订单
$('.submit-order').click(function() { $('.submit-order').click(function() {
var address_id = $('input[name=address_id]').val(); var address_id = $('input[name=address_id]').val();
...@@ -655,7 +714,8 @@ ...@@ -655,7 +714,8 @@
if (len > 0) { if (len > 0) {
// 购物车列表 // 购物车列表
for (var i = 0; i < len; i++) { for (var i = 0; i < len; i++) {
html += '<tr data-cid="'+list[i].cart_id+'">'+ html += '<tr data-cid="'+list[i].cart_id+'" data-type="'+list[i].type+'">'+
'<td>'+(i+1)+'</td>'+
'<td class="goods_id">'+list[i].goods_id+'</td>'+ '<td class="goods_id">'+list[i].goods_id+'</td>'+
'<td>'+list[i].goods_name+'</td>'+ '<td>'+list[i].goods_name+'</td>'+
'<td>'+list[i].brand_name+'</td>'+ '<td>'+list[i].brand_name+'</td>'+
......
...@@ -85,11 +85,16 @@ ...@@ -85,11 +85,16 @@
.label-prompt{padding: 6px 6px;} .label-prompt{padding: 6px 6px;}
.get-sku{padding: 3px 6px; margin-right: 20px;} .get-sku{padding: 3px 6px; margin-right: 20px;}
</style> </style>
<div class="col-sm-6"> <div class="col-sm-12">
<input type="text" class="search-sku" name="sku_id" value="" placeholder="请输入SKUID"> <input type="text" class="search-sku" name="sku_id" value="" placeholder="请输入SKUID">
<a class="btn btn-info get-sku">获取SKU信息</a> <a class="btn btn-info get-sku">获取SKU信息</a>
<span>快捷入口:<a href="{{Config('website.search-sku-url-2')}}" target="_blank">查询SKU</a></span> <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>
</div> </div>
...@@ -177,6 +182,7 @@ ...@@ -177,6 +182,7 @@
<table class="table table-bordered table-hover shop-table"> <table class="table table-bordered table-hover shop-table">
<thead> <thead>
<tr> <tr>
<th width="5%">序号</th>
<th width="15%">SKUID</th> <th width="15%">SKUID</th>
<th width="20%">商品名称</th> <th width="20%">商品名称</th>
<th width="10%">制造商</th> <th width="10%">制造商</th>
......
...@@ -5,11 +5,6 @@ ...@@ -5,11 +5,6 @@
<div class="ibox-content"> <div class="ibox-content">
<div class="row" style="margin-bottom: 30px;"> <div class="row" style="margin-bottom: 30px;">
<style>
.search-user{width: 240px !important;}
.label-prompt{padding: 6px 6px;}
.get-user{padding: 3px 6px; margin-right: 20px;}
</style>
<div class="col-sm-12"> <div class="col-sm-12">
<input type="text" class="search-user" name="user-mobile" value="" placeholder="请输入会员账号"> <input type="text" class="search-user" name="user-mobile" value="" placeholder="请输入会员账号">
<a class="btn btn-info get-user">获取用户信息</a> <a class="btn btn-info get-user">获取用户信息</a>
...@@ -223,11 +218,6 @@ ...@@ -223,11 +218,6 @@
<div class="ibox-content"> <div class="ibox-content">
<div class="row"> <div class="row">
<style>
.search-sku{width: 240px !important;}
.label-prompt{padding: 6px 6px;}
.get-sku{padding: 3px 6px; margin-right: 20px;}
</style>
<div class="col-sm-12"> <div class="col-sm-12">
<input type="text" class="search-sku" name="sku_id" value="" placeholder="请输入SKUID"> <input type="text" class="search-sku" name="sku_id" value="" placeholder="请输入SKUID">
<a class="btn btn-info get-sku">获取SKU信息</a> <a class="btn btn-info get-sku">获取SKU信息</a>
...@@ -235,6 +225,11 @@ ...@@ -235,6 +225,11 @@
<span>快捷入口: <span>快捷入口:
<a href="{{Config('website.search-sku-url-2')}}" target="_blank">查询SKU</a> <a href="{{Config('website.search-sku-url-2')}}" target="_blank">查询SKU</a>
</span> </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>
</div> </div>
...@@ -323,6 +318,7 @@ ...@@ -323,6 +318,7 @@
<table class="table table-bordered table-hover shop-table"> <table class="table table-bordered table-hover shop-table">
<thead> <thead>
<tr> <tr>
<th width="5%">序号</th>
<th width="15%">SKUID</th> <th width="15%">SKUID</th>
<th width="20%">商品名称</th> <th width="20%">商品名称</th>
<th width="10%">制造商</th> <th width="10%">制造商</th>
......
...@@ -5,11 +5,6 @@ ...@@ -5,11 +5,6 @@
<div class="ibox-content"> <div class="ibox-content">
<div class="row" style="margin-bottom: 30px;"> <div class="row" style="margin-bottom: 30px;">
<style>
.search-user{width: 240px !important;}
.label-prompt{padding: 6px 6px;}
.get-user{padding: 3px 6px; margin-right: 20px;}
</style>
<div class="col-sm-12"> <div class="col-sm-12">
<input type="text" class="search-user" name="user-mobile" value="" placeholder="请输入会员账号"> <input type="text" class="search-user" name="user-mobile" value="" placeholder="请输入会员账号">
<a class="btn btn-info get-user">获取用户信息</a> <a class="btn btn-info get-user">获取用户信息</a>
...@@ -241,11 +236,6 @@ ...@@ -241,11 +236,6 @@
<div class="ibox-content"> <div class="ibox-content">
<div class="row"> <div class="row">
<style>
.search-sku{width: 240px !important;}
.label-prompt{padding: 6px 6px;}
.get-sku{padding: 3px 6px; margin-right: 20px;}
</style>
<div class="col-sm-12"> <div class="col-sm-12">
<input type="text" class="search-sku" name="sku_id" value="" placeholder="请输入SKUID"> <input type="text" class="search-sku" name="sku_id" value="" placeholder="请输入SKUID">
<a class="btn btn-info get-sku">获取SKU信息</a> <a class="btn btn-info get-sku">获取SKU信息</a>
...@@ -254,6 +244,11 @@ ...@@ -254,6 +244,11 @@
<a href="{{Config('website.add-sku-url')}}" target="_blank" style="margin-right: 10px;">+新增SKU</a> <a href="{{Config('website.add-sku-url')}}" target="_blank" style="margin-right: 10px;">+新增SKU</a>
<a href="{{Config('website.search-sku-url-1')}}" target="_blank">查询SKU</a> <a href="{{Config('website.search-sku-url-1')}}" target="_blank">查询SKU</a>
</span> </span>
<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/%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>
</div> </div>
...@@ -343,6 +338,7 @@ ...@@ -343,6 +338,7 @@
<table class="table table-bordered table-hover shop-table"> <table class="table table-bordered table-hover shop-table">
<thead> <thead>
<tr> <tr>
<th width="5%">序号</th>
<th width="15%">SKUID</th> <th width="15%">SKUID</th>
<th width="20%">商品名称</th> <th width="20%">商品名称</th>
<th width="10%">制造商</th> <th width="10%">制造商</th>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment