Commit 1b12633c by 朱继来

Merge branch 'zjl_inquiry_order_20210311'

parents 5d618527 cac76ba0
......@@ -180,13 +180,16 @@ Class AddOrderController extends Controller
if (strpos($_SERVER['HTTP_HOST'], 'sz') === false) { // 非测试环境下执行
// 若用户已分配,则判断当前登录客服是否能给用户下单,若没分配,按之前流程,订单生成时分配给当前登录客服
$CrmModel = new CrmModel();
$sale_id = $CrmModel->getSaleId($user->user_id);
//$sale_id = $CrmModel->getSaleId($user->user_id);
if ($sale_id && $sale_id != $operator_id) {
$CmsModel = new CmsModel();
$sale_name = $CmsModel->getUserName($sale_id);
return ['errcode' => -1, 'errmsg' => '该客户由 '.$sale_name.' 跟进,请联系主管重新指派'];
}
//if ($sale_id && $sale_id != $operator_id) {
// $CmsModel = new CmsModel();
// $sale_name = $CmsModel->getUserName($sale_id);
// return ['errcode' => -1, 'errmsg' => '该客户由 '.$sale_name.' 跟进,请联系主管重新指派'];
//}
$res = $CrmModel->isBind($user->user_id, $operator_id);
if (!$res) return ['errcode'=>-1, 'errmsg'=>'当前用户与登录客服无绑定关系'];
}
$address = DB::connection('order')->table('lie_user_address')->where('user_id', $user->user_id)->select('address_id', 'consignee')->get(); // 收货地址
......
......@@ -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 : '';
......
......@@ -18,7 +18,19 @@ class CrmModel extends Model
$sales = $this->from('salesman')->where('user_id', $user->user_id)->select('sale_id')->first();
return $sales ? $sales->sale_id : 0;
return $sales ? $sales->sale_id : 0;
}
// 判断用户与客服是否存在关联关系
public function isBind($user_id, $sale_id)
{
$map = [];
$map['user_id'] = $user_id;
$map['sale_id'] = $sale_id;
$map['status'] = 0;
return $this->from('invoice_com_user')->where($map)->value('id');
}
}
\ No newline at end of file
......@@ -24,8 +24,12 @@ layui.config({
form.on('radio(invoice_type)', function(data) {
var val = data.value;
$('.tax_id').val('');
$('.inv-user-info').val('');
$('.user_id').val('');
$('.inv_com_id').val('');
if (!val) {
$('.tax_id').val('');
$('.invoice-section-2').hide();
$('.invoice-section-3').hide();
$('.invoice-section-4').hide();
......@@ -83,6 +87,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