Commit dabd08a0 by 朱继来

调整下单

parent 371bfbdc
......@@ -75,7 +75,7 @@ Class AddOrderController extends Controller
$url = Config('website.api_domain').'cart/getDJKConfg';
$info['api_dgk_url'] = ($url.'?k1='.$data['k1']."&".'k2='.$data['k2']);
$info['company'] = (new CmsModel())->getCompany(); // 获取公司组织
// $info['company'] = (new CmsModel())->getCompany(); // 获取公司组织
$info['report_ids'] = $request->input('report_ids', ''); // 询价系统销售报价ID
return view('addOrder', $info);
......
......@@ -22,6 +22,7 @@ use App\Model\UserSampleApplyModel;
use App\Model\OrderActionLogModel;
use App\Model\UserSampleInviteModel;
use App\Model\UserGroupModel;
use App\Model\UserMainModel;
use App\Model\BrandBlackListModel;
use App\Model\PayExtendModel;
use Illuminate\Support\Facades\Redis;
......@@ -514,23 +515,55 @@ class ApiController extends Controller
// 获取用户信息
public function getUserInfo($request)
{
$val = $request->input('val', '');
$type = $request->input('type', 1);
$inv_com_name = $request->input('inv_com_name', '');
$account = $request->input('account', '');
$com_id = 0;
$user_id = 0;
if ($type == 1) {
$com_id = DB::connection('order')->table('lie_invoice_company')->where('com_name', $val)->value('id');
if (!$com_id) $this->Export(-1, '当前公司不存在');
$inv_com_name && $com_id = DB::connection('order')->table('lie_invoice_company')->where('com_name', $inv_com_name)->value('id');
$this->Export(0, '', $com_id);
}
if ($account) {
$field = preg_match('/@/', $account) ? 'email' : 'mobile';
$user_id = DB::connection('order')->table('lie_user_main')->where($field, $account)->value('user_id');
}
if (preg_match('/@/', $val)) {
$field = 'email';
} else {
$field = 'mobile';
// 公司和联系方式都存在
if ($inv_com_name && $account) {
if (!$com_id) $this->Export(-1, '当前公司不存在');
if (!$user_id) $this->Export(-1, '当前联系方式不存在');
// 判断当前公司和登录用户是否存在于关联表
$map = [];
$map['com_id'] = $com_id;
$map['user_id'] = $user_id;
$map['sale_id'] = $request->user->userId;
$map['status'] = 0;
$id = DB::connection('order')->table('lie_invoice_com_user')->where($map)->value('id');
if (!$id) $this->Export(-1, '当前公司、联系方式与客服不存在绑定关系');
$this->Export(0, '', ['com_id'=>$com_id, 'user_id'=>$user_id, 'account'=>$account]);
}
$user_id = DB::connection('order')->table('lie_user_main')->where($field, $val)->value('user_id');
// 公司存在,联系方式不存在
if ($inv_com_name && !$account) {
if (!$com_id) $this->Export(-1, '当前公司不存在');
// 判断当前公司和登录用户是否存在于关联表
$map = [];
$map['com_id'] = $com_id;
$map['sale_id'] = $request->user->userId;
$map['status'] = 0;
$uid = DB::connection('order')->table('lie_invoice_com_user')->where($map)->value('user_id');
if (!$uid) $this->Export(-1, '当前公司未绑定联系人');
$UserMainModel = new UserMainModel;
$user_info = $UserMainModel->getUserAccount($uid);
$user_account = $user_info['mobile'] ? $user_info['mobile'] : $user_info['email'];
$this->Export(0, '', ['com_id'=>$com_id, 'user_id'=>$uid, 'account'=>$user_account]);
}
// 公司不存在,联系方式存在
if (!$user_id) $this->Export(-1, '当前联系方式不存在');
// 判断会员是否与当前登录账号绑定
......@@ -545,8 +578,8 @@ class ApiController extends Controller
$this->Export(-1, '该客户由 '.$sale_name.' 跟进,请联系主管重新指派');
}
}
$this->Export(0, '', $user_id);
$this->Export(0, '', ['com_id'=>'', 'user_id'=>$user_id, 'account'=>$account]);
}
// 获取用户绑定客服、发票
......@@ -573,38 +606,24 @@ class ApiController extends Controller
if (!$com_id) $this->Export(-1, '未填写当前发票/公司');
$map = [];
$map['com_id'] = $com_id;
$map['user_id'] = $user_id;
$map['status'] = 0;
$sale_id = DB::connection('order')->table('lie_invoice_com_user')->where($map)->value('sale_id');
$com_name = DB::connection('order')->table('lie_invoice_company')->where('id', $com_id)->value('com_name');
if (!$com_name) $this->Export(-1, '当前公司不存在');
if ($sale_id && $sale_id != $curr_user_id) {
$CmsModel = new CmsModel();
$sale_name = $CmsModel->getUserName($sale_id);
$this->Export(-1, '当前公司和联系账号由'.$sale_name.'跟进');
}
$invoice = DB::connection('order')->table('lie_taxinfo')->where(['tax_title'=>$com_name, 'inv_type'=>$invoice_type])->first();
$invoice_company = DB::connection('order')->table('lie_invoice_company')->where('id', $com_id)->first();
if (!$invoice_company) $this->Export(-1, '当前公司不存在');
$tax_info['tax_id'] = $invoice_company->tax_id;
$tax_info['tax_title'] = $invoice_company->com_name;
$tax_info['tax_no'] = $invoice_company->com_tax_registration;
$tax_info['tax_id'] = isset($invoice) ? $invoice->tax_id : 0;
$tax_info['tax_title'] = isset($invoice) ? $invoice->tax_title : '';
$tax_info['tax_no'] = isset($invoice) ? $invoice->tax_no : '';
if ($invoice_type == 4) $this->Export(0, '', $tax_info); // 增值税普票
$tax_info['com_addr'] = $invoice_company->com_addr;
$tax_info['com_tel'] = $invoice_company->com_tel;
$tax_info['com_bank'] = $invoice_company->com_bank;
$tax_info['com_bank_num'] = $invoice_company->com_bank_num;
$tax = DB::connection('order')->table('lie_taxinfo')->where('tax_id', $invoice_company->tax_id)->first();
$tax_info['consignee'] = $tax->consignee;
$tax_info['consignee_phone'] = $tax->consignee_phone;
$tax_info['consignee_addr'] = $tax->consignee_address;
$tax_info['com_addr'] = isset($invoice) ? $invoice->company_address : '';
$tax_info['com_tel'] = isset($invoice) ? $invoice->company_phone : '';
$tax_info['com_bank'] = isset($invoice) ? $invoice->bank_name : '';
$tax_info['com_bank_num'] = isset($invoice) ? $invoice->bank_account : '';
$tax_info['consignee'] = isset($invoice) ? $invoice->consignee : '';
$tax_info['consignee_phone'] = isset($invoice) ? $invoice->consignee_phone : '';
$tax_info['consignee_addr'] = isset($invoice) ? $invoice->consignee_address : '';
$this->Export(0, '', $tax_info); // 增值税专票
}
......@@ -663,7 +682,7 @@ class ApiController extends Controller
if ($v['inquiry_number'] <= 0) $this->Export(-3, '导入销售报价明细,商品:'.$v['goods_name'].' 数量不能为0');
$items[$k]['id'] = $v['goods_id'];
$items[$k]['goods_name'] = $v['goods_name'];
$items[$k]['goods_name'] = $v['goods_name_pro'];
$items[$k]['brand_name'] = $v['brand_name'];
$items[$k]['supplier_name'] = $v['supplier_name'];
$items[$k]['num'] = $v['inquiry_number'];
......@@ -691,10 +710,10 @@ class ApiController extends Controller
$data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
// dd($data);
$temp = json_decode(curlApi($url, $data, "POST"), true);
$this->Export($temp['err_code'], $temp['err_msg']);
$this->Export($temp['err_code'], $temp['err_msg'], $delivery_place);
}
}
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class InvoiceComUserModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_invoice_com_user';
protected $guarded = ['id'];
protected $primaryKey = 'id';
public $timestamps = true;
const CREATED_AT = 'create_time';
const UPDATED_AT = 'update_time';
public function fromDateTime($value)
{
return strtotime(parent::fromDateTime($value));
}
}
\ No newline at end of file
......@@ -8,27 +8,51 @@ layui.config({
// 选择发票类型
form.on('radio(invoice_type)', function(data) {
if (!(data.value)) {
var val = data.value;
if (!val) {
$('.tax_id').val('');
$('.invoice-section-2').hide();
$('.invoice-section-3').hide();
$('.invoice-section-4').hide();
$('.inv-com-section').hide();
return false;
}
switch (val) {
case '2':
$('.invoice-section-2').show();
$('.invoice-section-3').hide();
$('.invoice-section-4').hide();
$('.inv-com-section').show();
break;
case '3':
$('.invoice-section-3').show();
$('.invoice-section-2').hide();
$('.invoice-section-4').hide();
$('.inv-com-section').show();
break;
case '4':
$('.invoice-section-4').show();
$('.invoice-section-2').hide();
$('.invoice-section-3').hide();
$('.inv-com-section').show();
break;
}
checkBindUser();
})
// 公司、账号输入后,赋值ID,并检查绑定客服、发票
$('.inv-user-info').blur(function() {
var val = $(this).val();
var type = $(this).data('type'); // 1-公司,2-会员账号
if (!val) return false;
$('.inv-user-info').blur(function() {
if (!($(this).val())) return false;
var datax = {};
datax.val = val;
datax.type = type;
var inv_com_name = $('.inv_com_name').val();
var account = $('.account').val();
var datax = {
inv_com_name: inv_com_name,
account: account,
};
$.ajax({
type: "POST",
......@@ -36,20 +60,22 @@ layui.config({
data: datax,
dataType: "json",
success: function(resp){
var field = type == 1 ? 'inv_com_id' : 'user_id';
if (resp.errcode != 0) {
$('.' + field).val('');
$('.inv_com_id').val('');
$('.user_id').val('');
layer.msg(resp.errmsg);
return false;
}
$('.' + field).val(resp.data);
$('.inv_com_id').val(resp.data.com_id);
$('.user_id').val(resp.data.user_id);
$('.account').val(resp.data.account);
checkBindUser();
if (type == 2 && resp.data && report_ids) { // 会员ID、销售报价ID存在
importGoods(resp.data, report_ids);
if ($('.user_id').val() && resp.data && report_ids) { // 会员ID、销售报价ID存在
importGoods(resp.data.user_id, report_ids);
return false;
}
......@@ -83,9 +109,6 @@ layui.config({
layer.msg(resp.errmsg);
$('.tax_id').val('');
$('.invoice-section-2').hide();
$('.invoice-section-3').hide();
$('.invoice-section-4').hide();
return false;
}
......@@ -98,9 +121,6 @@ layui.config({
str += '<option value="'+data[i].tax_id+'">'+data[i].tax_title+'</option>';
}
$('.invoice-section-2').show();
$('.invoice-section-3').hide();
$('.invoice-section-4').hide();
$('#user_tax_id').empty().append(str);
form.render('select', 'user-tax');
......@@ -116,17 +136,11 @@ layui.config({
$('.consignee_addr').text(data.consignee_addr);
$('.tax_id').val(data.tax_id);
$('.invoice-section-3').show();
$('.invoice-section-2').hide();
$('.invoice-section-4').hide();
} else if (invoice_type == 4) { // 增值税普票
$('.tax_title_1').text(data.tax_title);
$('.tax_no_1').text(data.tax_no);
$('.tax_id').val(data.tax_id);
$('.invoice-section-4').show();
$('.invoice-section-2').hide();
$('.invoice-section-3').hide();
}
},
})
......@@ -151,6 +165,17 @@ layui.config({
}
layer.msg('导入销售报价明细成功');
// 交货地
var currency_sign = resp.data == 1 ? 'RMB' : 'USD';
$('.currency-sign').text(currency_sign);
$('.com_id').val(resp.data);
form.render('select', 'com_id');
$('.delivery_place').val(resp.data);
form.render('select', 'delivery_place');
renderTable();
}
})
......@@ -162,33 +187,45 @@ layui.config({
})
// 选择销售组织
// form.on('select(com_id)', function(data) {
// var val = data.value;
// if (val == '') {
// $('.currency-sign').text('');
// $('.currency-section').hide();
// $('.delivery_place').val('');
// form.render('select', 'delivery_place');
// return false;
// }
// var currency = $(data.elem).find("option:selected").attr('currency');
// var currency_sign = '';
// var delivery_place = 0;
// if (currency == 1) {
// currency_sign = 'RMB';
// delivery_place = 1;
// } else {
// currency_sign = 'USD';
// delivery_place = 2;
// }
// $('.currency-sign').text(currency_sign);
// $('.currency-section').show();
// $('.delivery_place').val(delivery_place);
// form.render('select', 'delivery_place');
// renderTable();
// })
form.on('select(com_id)', function(data) {
var val = data.value;
if (val == '') {
$('.currency-sign').text('');
$('.currency-section').hide();
$('.delivery_place').val('');
form.render('select', 'delivery_place');
return false;
}
var currency = $(data.elem).find("option:selected").attr('currency');
var currency_sign = '';
var delivery_place = 0;
if (currency == 1) {
currency_sign = 'RMB';
delivery_place = 1;
} else {
currency_sign = 'USD';
delivery_place = 2;
}
currency_sign = val == 1 ? 'RMB' : 'USD';
$('.currency-sign').text(currency_sign);
$('.currency-section').show();
$('.delivery_place').val(delivery_place);
$('.delivery_place').val(val);
form.render('select', 'delivery_place');
renderTable();
......
......@@ -24,19 +24,23 @@
<div class="layui-form-item">
<label class="layui-form-label">销售组织:</label>
<div class="layui-input-inline">
<select name="com_id" class="com_id" lay-verify="required" lay-filter="com_id">
<option value=""></option>
@if ($company)
@foreach ($company as $k=>$v)
<option value="{{ $k }}" currency="{{ $v['com_currency'] }}">{{ $v['com_name'] }}</option>
@endforeach
@endif
<div class="layui-input-inline layui-form" lay-filter="com_id">
<select name="com_id" class="com_id" lay-verify="required">
<option value="1">猎芯科技</option>
<option value="2">泽茂</option>
<?php
// if ($company)
// foreach ($company as $k=>$v)
// <option value="{{ $k }}" currency="{{ $v['com_currency'] }}">{{ $v['com_name'] }}</option>
// endforeach
// endif
?>
</select>
</div>
<div class="layui-form-mid layui-word-aux">
<span class="currency-section hide"> 币别:<span class="currency-sign"></span></span>
<span class="currency-section"> 币别:<span class="currency-sign">RMB</span></span>
</div>
</div>
</div>
......@@ -47,7 +51,6 @@
<div class="layui-input-inline layui-form" lay-filter="delivery_place">
<select name="delivery_place" class="delivery_place" disabled>
<option value=""></option>
<option value="1">大陆</option>
<option value="2">香港</option>
</select>
......
<style type="text/css">
.inv-com-section{ display: none; }
.invoice-section-2, .invoice-section-3, .invoice-section-4{ display: none; border: 1px solid #ccc; }
</style>
......@@ -19,36 +20,37 @@
</div>
</div>
<div class="layui-row">
<div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">发票/公司:</label>
<div class="inv-com-section">
<div class="layui-row">
<div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">发票/公司:</label>
<div class="layui-input-inline">
<input type="text" name="com_name" required lay-verify="" placeholder="请输入公司" autocomplete="off" class="layui-input inv_com_name inv-user-info" data-type="1">
<div class="layui-input-inline">
<input type="text" name="com_name" lay-verify="" placeholder="请输入公司" autocomplete="off" class="layui-input inv_com_name inv-user-info"
</div>
</div>
</div>
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
<div class="layui-form-item">
<label class="layui-form-label">联系方式:</label>
<div class="layui-row">
<div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
<div class="layui-form-item">
<label class="layui-form-label">联系方式:</label>
<div class="layui-input-inline">
<input type="text" name="account" required lay-verify="required" placeholder="请输入联系方式" autocomplete="off" class="layui-input inv-user-info" data-type="2">
<div class="layui-input-inline">
<input type="text" name="account" lay-verify="required" placeholder="请输入联系方式" autocomplete="off" class="layui-input account inv-user-info">
</div>
</div>
</div>
</div>
<div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
<div class="layui-form-item">
<label class="layui-form-label">联系人:</label>
<div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
<div class="layui-form-item">
<label class="layui-form-label">联系人:</label>
<div class="layui-input-inline">
<input type="text" name="user_name" required lay-verify="" placeholder="请输入联系人" autocomplete="off" class="layui-input">
<div class="layui-input-inline">
<input type="text" name="user_name" lay-verify="" placeholder="请输入联系人" autocomplete="off" class="layui-input">
</div>
</div>
</div>
</div>
......
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