Commit 01230040 by 朱继来

Merge branch 'lt_订单添加dgk'

parents bf702ea8 6871523e
......@@ -72,6 +72,12 @@ Class AddOrderController extends Controller
$info['crm_account'] = $user_info['mobile'] ? $user_info['mobile'] : $user_info['email'];
}
$data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
$url = Config('website.api_domain').'cart/getDJKConfg';
$info['api_dgk_url'] = ($url.'?k1='.$data['k1']."&".'k2='.$data['k2']);
return view('addOrder', $info);
}
......@@ -538,6 +544,14 @@ Class AddOrderController extends Controller
$data['tax_id'] = $request->input('tax_id');
$data['user_coupon_id'] = $request->input('user_coupon_id');
if ($data['type'] == 1) { // 联营
$data['customer_cn'] = $request->input('customer_cn', '');
$data['customer_en'] = $request->input('customer_en', '');
$data['customer_type'] = $request->input('customer_type', '');
$data['product_use_classone_sn'] = $request->input('product_use_classone_sn', '');
$data['product_use_classtwo_sn'] = $request->input('product_use_classtwo_sn', '');
}
if ($data['type'] == 4) {
$data['business_type'] = $request->input('business_type');
}
......@@ -722,7 +736,7 @@ Class AddOrderController extends Controller
$excel = $this->handleData($excel, $map); // 处理数据
// 验证excel内容
$valid = $this->excelValid($excel);
$valid = $this->excelValid($excel, $type);
if ($valid['errcode'] != 0) {
errorLog(Error::E_IMPORT_VALID_FAILED, $valid['errmsg']);
......@@ -753,7 +767,7 @@ Class AddOrderController extends Controller
}
// 验证导入excel
public function excelValid($excel)
public function excelValid($excel, $type=1)
{
$count = count($excel);
......@@ -766,22 +780,52 @@ Class AddOrderController extends Controller
$required_keys = array_keys($required); // 必填项keys
$err = ['errcode' => 0, 'errmsg' => '验证成功']; // 提示信息
array_walk($excel, function($val, $key) use($required, $required_keys, &$err) {
$err = []; // 提示信息
array_walk($excel, function($val, $key) use($required, $required_keys, &$err, $type) {
// 跳过第一条
if ($key != 0) {
if ($type == 1 && strtolower($val['supplier_name']) == 'digikey') { // 联营
if (empty($val['id'])) {
$err[] = '第'.$key.'行,供应商为digikey,SKUID不能为空';
return;
}
$url = Config('website.search-skuid');
$data['id'] = $val['id'];
$data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
$response = json_decode(curlApi($url, $data, 'POST'), true);
if (empty($response['data']) || empty($response['data']['goods_id'])) {
$err[] = '第'.$key.'行,供应商为digikey,未找SKU信息';
return;
}
if ($response['data']['goods_name'] != $val['goods_name']) {
$err[] = '第'.$key.'行,供应商为digikey,商品名称不匹配';
return;
}
if ($response['data']['brand_name'] != $val['brand_name']) {
$err[] = '第'.$key.'行,供应商为digikey,制造商不匹配';
return;
}
}
foreach ($val as $k=>$v) {
if (in_array($k, $required_keys)) {
if (empty($v)) { // 若必填项值为空,返回提示信息
$err = ['errcode' => 1, 'errmsg' => $required[$k].'列,第'.$key.'行不能为空'];
$err[] = $required[$k].'列,第'.$key.'行不能为空';
break;
}
}
// 自营ID、采购数量和单价为数字类型
if ($k == 'id' || $k == 'num' || $k == 'goods_price') {
if (($type == 2 && $k == 'id') || $k == 'num' || $k == 'goods_price') {
if (!preg_match('/\d/', $v)) {
$err = ['errcode' => 2, 'errmsg' => $required[$k].'列,第'.$key.'行格式错误'];
$err[] = $required[$k].'列,第'.$key.'行格式错误';
break;
}
}
......@@ -789,7 +833,11 @@ Class AddOrderController extends Controller
}
});
return $err;
if (!empty($err)) {
return ['errcode' => 1, 'errmsg' => implode('; ', $err)];
}
return ['errcode' => 0, 'errmsg' => '验证成功'];
}
// 处理导入内容---赋上字段
......@@ -816,6 +864,7 @@ Class AddOrderController extends Controller
$data['add_goods_name'] = $request->input('add_goods_name', '');
$data['add_brand_name'] = $request->input('add_brand_name', '');
$data['add_supplier_name'] = $request->input('add_supplier_name', '');
$data['add_goods_id'] = $request->input('add_goods_id', 0);
$data['add_goods_number'] = $request->input('add_goods_number', 0);
$data['add_goods_price'] = $request->input('add_goods_price', 0);
$data['add_delivery_time'] = $request->input('add_delivery_time', '');
......
......@@ -57,9 +57,10 @@
3 => 'goods_price',
4 => 'delivery_time',
5 => 'supplier_name',
6 => 'buyer_id',
7 => 'remarks',
8 => 'batch',
6 => 'id',
7 => 'buyer_id',
8 => 'remarks',
9 => 'batch',
],
'self_map' => [
......
......@@ -119,7 +119,7 @@ li {
}
/* 后台新增订单 start */
.user-info, .address-content, .invoice-content, .order-info {
.user-info, .address-content, .invoice-content, .order-info, .client-info {
display: none;
}
......
......@@ -270,6 +270,7 @@
dataType: 'json',
success: function (resp) { console.log(resp)
if (resp.errcode != 0) {
console.log(resp.data)
layer.msg(resp.errmsg);
return false;
}
......@@ -663,9 +664,18 @@
user_id = $('.user_id').val();
}
var is_dgk = false;
$('.shop-table tbody tr').each(function() {
var cid = $(this).data('cid');
cart_ids.push(cid);
var supplier_id = $(this).data('sup_id');
var supplier_name = $(this).data('sup_name');
if (supplier_id == '7' || supplier_name.toLowerCase() == 'digikey') {
is_dgk = true;
}
})
if (cart_ids.length > 0) {
......@@ -703,6 +713,52 @@
}
}
if (type == 1 && is_dgk) { // 联营包含digikey商品,则填写终端资料
var customer_cn = $('.customer_cn').val();
var customer_en = $('.customer_en').val();
var customer_type = $('.customer_type').val();
var product_use_classone_sn = $('.product_use_classone_sn').val();
var product_use_classtwo_sn = $('.product_use_classtwo_sn').val();
if (!customer_cn) {
layer.msg('请填写终端中文名称');
return false;
}
// var cn_reg = /^[\u4e00-\u9fa5]+$/;
// if(!cn_reg.test(customer_cn)){
// layer.msg('请填写全中文名称');
// return false;
// }
if (!customer_en) {
layer.msg('请填写终端英文名称');
return false;
}
var en_reg = /^[a-zA-Z0-9\.\s\,]+$/;
if(!en_reg.test(customer_en)){
layer.msg('请填写全英文名称');
return false;
}
if (customer_type == '') {
layer.msg('请选择客户类型');
return false;
}
if (product_use_classone_sn == '') {
layer.msg('请选择产品用途一级分类');
return false;
}
datax.customer_cn = customer_cn;
datax.customer_en = customer_en;
datax.customer_type = customer_type;
datax.product_use_classone_sn = product_use_classone_sn;
datax.product_use_classtwo_sn = product_use_classtwo_sn;
}
datax.tax_id = tax_id;
datax.user_coupon_id = user_coupon_id;
}
......@@ -770,13 +826,20 @@
} else if (resp.errcode == 21024) {
layer.alert('该用户已进入公司黑名单,具体请联系吴承义,同时订单无法提交');
return false;
} else if (resp.errcode == 21030) {
layer.alert(resp.errmsg);
var delivery_place = $('.delivery_place').val();
loading.lists(user_id, goods_type, is_online, delivery_place); // 加载购物车列表
loading.confirm(user_id, address_id, cart_ids, user_coupon_id, goods_type, is_online); // 确认订单信息
return false;
}
layer.alert(resp.errmsg);
},
})
layer.msg('订单生成中...', {icon: 16, time: 0, shade: 0.3});
// layer.msg('订单生成中...', {icon: 16, time: 0, shade: 0.3});
}
} else {
layer.msg('请先添加商品');
......@@ -808,7 +871,7 @@
// 购物车列表
for (var i = 0; i < len; i++) {
html += '<tr data-cid="'+list[i].cart_id+'" data-type="'+list[i].type+'" min_buy="'+list[i].min_buy+'">'+
html += '<tr data-cid="'+list[i].cart_id+'" data-type="'+list[i].type+'" min_buy="'+list[i].min_buy+'" data-sup_name="'+list[i].supplier_name+'" data-sup_id="'+list[i].supplier_id+'">'+
'<td>'+(i+1)+'</td>'+
'<td class="goods_id">'+list[i].goods_id+'</td>'+
'<td>'+list[i].goods_name+'</td>'+
......@@ -969,6 +1032,23 @@
}
}
if (goods_type == 1) {
var list = resp.data.list;
var is_dgk = false;
for (var i = 0; i < list.length; i++) {
if (list[i].supplier_id == '7' || list[i].supplier_name.toLowerCase() == 'digikey') {
is_dgk = true;
}
}
if (is_dgk) {
$('.client-info').css('display', 'block');
} else {
$('.client-info').css('display', 'none');
}
}
if (data.extend_fee) {
$('.extend_fee').show();
$('.extend_fee_val').empty().text(data.extend_fee_format); // 附加费
......@@ -983,6 +1063,8 @@
}
return false;
} else {
$('.client-info').css('display', 'none'); // 隐藏终端信息
}
layer.msg(resp.errmsg || '网络异常');
......
......@@ -80,6 +80,19 @@
})
})
// 无SKUID --- 供应商
$('#addGoodsNoSkuid').delegate('.add_supplier_name', 'keyup', function() {
var val = $(this).val();
if (val.toLowerCase() == 'digikey') {
$('.skuid-info').css('display', 'block');
$('.layui-layer-iframe .layui-layer-btn, .layui-layer-page .layui-layer-btn').css('padding-top', '50px');
} else {
$('.skuid-info').css('display', 'none');
$('.layui-layer-iframe .layui-layer-btn, .layui-layer-page .layui-layer-btn').css('padding-top', '0px');
}
})
$('.order-change-main').on('click', '.add_goods_no_skuid', function() {
layer.open({
area: ['600px'],
......@@ -92,6 +105,7 @@
var add_goods_name = $('input[name=add_goods_name]').val();
var add_brand_name = $('input[name=add_brand_name]').val();
var add_supplier_name = $('input[name=add_supplier_name]').val();
var add_goods_id = $('input[name=add_goods_id]').val();
var add_goods_number = $('input[name=add_goods_number]').val();
var add_goods_price = $('input[name=add_goods_price]').val();
var add_delivery_time = $('input[name=add_delivery_time]').val();
......@@ -115,6 +129,18 @@
return false;
}
if (add_supplier_name.toLowerCase() == 'digikey') {
if (!add_goods_id) {
layer.msg('供应商为digikey,请输入SKUID');
return false;
}
if (!reg.test(add_goods_id)) {
layer.msg('格式错误,请输入正确的SKUID');
return false;
}
}
if (!add_goods_number) {
layer.msg('请输入采购数量');
return false;
......@@ -146,6 +172,7 @@
add_goods_name: add_goods_name,
add_brand_name: add_brand_name,
add_supplier_name: add_supplier_name,
add_goods_id: add_goods_id,
add_goods_number: add_goods_number,
add_goods_price: add_goods_price,
add_delivery_time: add_delivery_time,
......
......@@ -227,6 +227,53 @@
</div>
</div>
</div>
<div class="client-info">
<h4>终端客户信息 <span class="title-tips"><i class="fa fa-info-circle"></i>digikey渠道商品必填,其他渠道可不填写</span></h4>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<span><i class="text-danger">*</i> 终端中文名称:</span>
<input type="text" class="customer_cn" name="customer_cn" value="">
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<span><i class="text-danger">*</i> 客户类型:</span>
<select class="layui-select customer_type" name="customer_type">
<option value="">请选择</option>
<option value="1">终端</option>
<option value="2">贸易商</option>
<option value="3">大学</option>
<option value="4">个人</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<span><i class="text-danger">*</i> 终端英文名称:</span>
<input type="text" class="customer_en" name="customer_en" value="">
<a href="https://translate.google.cn/" target="_blank">谷歌翻译</a>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<span><i class="text-danger">*</i> 产品用途:</span>
<select class="layui-select product_use_classone_sn" name="product_use_classone_sn">
<option value="">请选择</option>
</select>
<select class="layui-select product_use_classtwo_sn" name="product_use_classtwo_sn"></select>
</div>
</div>
</div>
</div>
</div>
</div>
......@@ -247,7 +294,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/%E8%81%94%E8%90%A5%E8%AE%A2%E5%8D%95%E6%89%B9%E9%87%8F%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.csv">联营物料模板下载</a>
<a class="btn btn-info" href="http://img.ichunt.com/doc/excel/template/%E8%81%94%E8%90%A5%E6%89%B9%E9%87%8F%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.csv">联营物料模板下载</a>
</div>
</div>
</div>
......@@ -406,6 +453,36 @@
var sale_id = "{{$sale_id}}";
var URL_api = "{{Config('website.api_domain')}}";
var role = "{{ $role }}";
window.api_dgk_url_text ="<?php echo $api_dgk_url;?>"
setTimeout( function(){
$.get(window.api_dgk_url_text,function(data){
window.data = data.data.data
console.log(window.data)
var product = Object.keys(window.data); // 获取一级分类
var product_len = Object.keys(window.data).length
for(var i = 0; i < product_len; i++){
$('.product_use_classone_sn').append('<option value="'+i+'">'+product[i]+'</option>')
}
},'json')
}, 10)
$(document).on('change','.product_use_classone_sn',function(data){
var select_key = $('.product_use_classone_sn option:selected').text();
$('.product_use_classtwo_sn').html('');
for(let key in window.data){
if(key == select_key){
// console.log(window.data[key])
for(var i = 0; i < window.data[key].length; i++){
$('.product_use_classtwo_sn').append('<option value="'+i+'">'+window.data[key][i]+'</option>')
}
}
}
})
$.lie.add_order.lyorder();
</script>
\ No newline at end of file
<style>
#addGoodsNoSkuid{ display: none; }
#addGoodsNoSkuid, #addGoodsNoSkuid .skuid-info { display: none; }
#addGoodsNoSkuid input { width: 280px; height: 35px; }
#addGoodsNoSkuid textarea { width: 280px; }
</style>
......@@ -21,7 +21,13 @@
<div class="form-group">
<label for="inputEmail3" class="col-sm-4 control-label"><i class="error">*</i> 供应商</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="add_supplier_name" value="" placeholder="请输入供应商">
<input class="form-control add_supplier_name" type="text" name="add_supplier_name" value="" placeholder="请输入供应商">
</div>
</div>
<div class="form-group skuid-info">
<label for="inputEmail3" class="col-sm-4 control-label"><i class="error">*</i> SKUID</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="add_goods_id" value="" placeholder="请输入商品SKUID">
</div>
</div>
<div class="form-group">
......
......@@ -463,6 +463,7 @@
<th>商品名</th>
<th>型号</th>
@else
<th>商品ID</th>
<th>商品名</th>
@endif
......@@ -529,6 +530,7 @@
<td><a href="{{Config('website.main_url').'item/'.$v['goods_id'].'.html?ptag=order'}}" target="_blank">{{$v['goods_name']}}</a></td>
<td>{{ App\Http\Controllers\getGoodsName($v['goods_id']) }}</td>
@else
<td>{{$v['goods_id']}}</td>
<td><a href="{{Config('website.main_url').'goods_'.$v['goods_id'].'.html?ptag=order'}}" target="_blank">{{$v['goods_name']}}</a></td>
@endif
......
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