Commit 698861e8 by 朱继来

批量添加物料

parent 45cce3dc
...@@ -318,11 +318,17 @@ Class AddOrderController extends Controller ...@@ -318,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);
...@@ -607,6 +613,18 @@ Class AddOrderController extends Controller ...@@ -607,6 +613,18 @@ Class AddOrderController extends Controller
$excel = $data->toArray(); $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内容 // 验证excel内容
$valid = $this->excelValid($excel); $valid = $this->excelValid($excel);
...@@ -616,22 +634,24 @@ Class AddOrderController extends Controller ...@@ -616,22 +634,24 @@ Class AddOrderController extends Controller
array_shift($excel); // 删除第一行 array_shift($excel); // 删除第一行
$type = $request->input('type'); // 1.联营 2.自营 $goods_info = $this->handleData($excel, $map); // 处理数据
$goods_info = $this->handleData($excel, $type);
// 推送到API // 推送到API
$data['goods_info'] = $goods_info; $data['data'] = $goods_info;
$data['operator_id'] = $request->user->userId; $data['operator_id'] = $request->user->userId;
$data['type'] = $type; $data['type'] = 3; // 后台批量添加标记
$data['uid'] = $request->input('user_id'); $data['uid'] = $request->input('user_id');
$data['delivery_place'] = $request->input('delivery_place'); $data['delivery_place'] = $request->input('delivery_place');
$url = Config('website.api_domain').'cart/addBatchFromOrder'; if ($type == 1) { // 联营
$url = Config('website.api_domain').'cart/addBatchByOrderSystem';
} else {
$url = Config('website.api_domain').'cart/addBatch';
}
$data['k1'] = time(); $data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi'); $data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
echo '<pre>';
print_r(curlApi($url, $data, "POST"));die;
$temp = json_decode(curlApi($url, $data, "POST"), true); $temp = json_decode(curlApi($url, $data, "POST"), true);
return ['errcode' => $temp['err_code'], 'errmsg' => $temp['err_msg']]; return ['errcode' => $temp['err_code'], 'errmsg' => $temp['err_msg']];
...@@ -670,14 +690,8 @@ print_r(curlApi($url, $data, "POST"));die; ...@@ -670,14 +690,8 @@ print_r(curlApi($url, $data, "POST"));die;
} }
// 处理导入内容---赋上字段 // 处理导入内容---赋上字段
public function handleData($excel, $type) public function handleData($excel, $map)
{ {
if ($type == 1) {
$map = Config('params.joint_map');
} else {
$map = Config('params.self_map');
}
$goods_info = array_map(function($val) use($map) { $goods_info = array_map(function($val) use($map) {
foreach ($val as $k=>$v) { foreach ($val as $k=>$v) {
$tmp[$map[$k]] = $v; $tmp[$map[$k]] = $v;
......
...@@ -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) {
...@@ -553,6 +559,7 @@ ...@@ -553,6 +559,7 @@
success: function(resp){ success: function(resp){
if (resp.errcode == 0) { if (resp.errcode == 0) {
layer.msg(resp.errmsg); layer.msg(resp.errmsg);
loading.lists(user_id, goods_type, is_online); // 加载购物车列表
return false; return false;
} }
...@@ -707,7 +714,8 @@ ...@@ -707,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>'+
......
...@@ -182,6 +182,7 @@ ...@@ -182,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>
......
...@@ -318,6 +318,7 @@ ...@@ -318,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>
......
...@@ -338,6 +338,7 @@ ...@@ -338,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