Commit 4693c3ea by 朱继来

调整关联关系

parent 99fe26b1
......@@ -520,7 +520,7 @@ class ApiController extends Controller
$com_id = 0;
$user_id = 0;
$inv_com_name && $com_id = DB::connection('order')->table('lie_invoice_company')->where('com_name', $inv_com_name)->value('id');
$inv_com_name && $com_id = DB::connection('crm')->table('invoice_company')->where('com_name', $inv_com_name)->value('id');
if ($account) {
$field = preg_match('/@/', $account) ? 'email' : 'mobile';
......@@ -538,7 +538,8 @@ class ApiController extends Controller
$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');
$id = DB::connection('crm')->table('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]);
......@@ -553,7 +554,8 @@ class ApiController extends Controller
$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');
$uid = DB::connection('crm')->table('invoice_com_user')->where($map)->value('user_id');
if (!$uid) $this->Export(-1, '当前公司未绑定联系人');
$UserMainModel = new UserMainModel;
......@@ -566,20 +568,18 @@ class ApiController extends Controller
// 公司不存在,联系方式存在
if (!$user_id) $this->Export(-1, '当前联系方式不存在');
// 判断会员是否与当前登录账号绑定
if (strpos($_SERVER['HTTP_HOST'], 'sz') === false) { // 非测试环境下执行
// 若用户已分配,则判断当前登录客服是否能给用户下单,若没分配,按之前流程,订单生成时分配给当前登录客服
$CrmModel = new CrmModel();
$sale_id = $CrmModel->getSaleId($user_id);
if ($sale_id && $sale_id != $request->user->userId) {
$CmsModel = new CmsModel();
$sale_name = $CmsModel->getUserName($sale_id);
$this->Export(-1, '该客户由 '.$sale_name.' 跟进,请联系主管重新指派');
}
}
// 判断当前用户和登录用户是否存在于关联表
$map = [];
$map['user_id'] = $user_id;
$map['sale_id'] = $request->user->userId;
$map['status'] = 0;
$com_id = DB::connection('crm')->table('invoice_com_user')->where($map)->value('com_id');
if (!$com_id) $this->Export(-1, '当前登录用户未绑定该联系人');
$com_name = DB::connection('crm')->table('invoice_company')->where('id', $com_id)->value('com_name');
$this->Export(0, '', ['com_id'=>'', 'user_id'=>$user_id, 'account'=>$account]);
$this->Export(0, '', ['com_id'=>$com_id, 'com_name'=>$com_name, 'user_id'=>$user_id, 'account'=>$account]);
}
// 获取用户绑定客服、发票
......@@ -596,7 +596,7 @@ class ApiController extends Controller
// 个人发票
if ($invoice_type == 2) {
$where = [];
$where['user_id'] = $user_id;
$where['user_id'] = $user_id;
$where['inv_type'] = 2;
$tax_info = DB::connection('order')->table('lie_taxinfo')->where($where)->select('tax_title', 'tax_id')->get();
......@@ -606,25 +606,26 @@ class ApiController extends Controller
if (!$com_id) $this->Export(-1, '未填写当前发票/公司');
$com_name = DB::connection('order')->table('lie_invoice_company')->where('id', $com_id)->value('com_name');
if (!$com_name) $this->Export(-1, '当前公司不存在');
$com_info = DB::connection('crm')->table('invoice_company')->where('id', $com_id)->first();
if (!$com_info) $this->Export(-1, '当前公司不存在');
$map = [];
$map['tax_title'] = $com_name;
$map['tax_title'] = $com_info->com_name;
$map['user_id'] = $user_id;
$map['inv_type'] = $invoice_type;
$invoice = DB::connection('order')->table('lie_taxinfo')->where($map)->first();
if (!$invoice) $this->Export(-1, '未找到发票信息');
$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 : '';
$tax_info['tax_no'] = isset($com_info) ? $com_info->com_tax_registration : '';
if ($invoice_type == 4) $this->Export(0, '', $tax_info); // 增值税普票
$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['com_addr'] = isset($com_info) ? $com_info->com_addr : '';
$tax_info['com_tel'] = isset($com_info) ? $com_info->com_tel : '';
$tax_info['com_bank'] = isset($com_info) ? $com_info->com_bank : '';
$tax_info['com_bank_num'] = isset($com_info) ? $com_info->com_bank_num : '';
$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 : '';
......
......@@ -83,6 +83,7 @@ layui.config({
}
$('.inv_com_id').val(resp.data.com_id);
resp.data.com_name && $('.inv_com_name').val(resp.data.com_name);
$('.user_id').val(resp.data.user_id);
$('.account').val(resp.data.account);
......
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