Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
朱继来
/
后台订单管理
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f13850ed
authored
Nov 18, 2019
by
朱继来
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'zjl_export_20191106'
parents
0b4be6e3
f11d6917
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
32 deletions
app/Http/Controllers/AddOrderController.php
app/Model/CrmModel.php
config/database.php
app/Http/Controllers/AddOrderController.php
View file @
f13850ed
...
@@ -12,6 +12,8 @@ use App\Http\Controllers\PermController;
...
@@ -12,6 +12,8 @@ use App\Http\Controllers\PermController;
use
App\Http\Error
;
use
App\Http\Error
;
use
App\Model\UserMainModel
;
use
App\Model\UserMainModel
;
use
App\Model\OrderModel
;
use
App\Model\OrderModel
;
use
App\Model\CrmModel
;
use
App\Model\CmsModel
;
use
Excel
;
use
Excel
;
Class
AddOrderController
extends
Controller
Class
AddOrderController
extends
Controller
...
@@ -96,11 +98,9 @@ Class AddOrderController extends Controller
...
@@ -96,11 +98,9 @@ Class AddOrderController extends Controller
$UserMainModel
=
new
UserMainModel
;
$UserMainModel
=
new
UserMainModel
;
if
(
!
empty
(
$user_id
)
&&
strlen
(
$request
->
input
(
'user_id'
))
<
11
){
if
(
!
empty
(
$user_id
)
&&
strlen
(
$request
->
input
(
'user_id'
))
<
11
){
$user
=
$UserMainModel
->
where
(
'user_id'
,
$user_id
)
->
select
(
'user_id'
,
'email'
,
'mobile'
,
'is_test'
)
->
orderBy
(
'create_time'
,
'desc'
)
->
first
();
$user
=
$UserMainModel
->
where
(
'user_id'
,
$user_id
)
->
select
(
'user_id'
,
'email'
,
'mobile'
,
'is_test'
)
->
orderBy
(
'create_time'
,
'desc'
)
->
first
();
}
else
{
}
else
{
if
(
preg_match
(
'/@/'
,
$mobile
))
{
if
(
preg_match
(
'/@/'
,
$mobile
))
{
$user
=
$UserMainModel
->
where
(
'email'
,
$mobile
)
->
select
(
'user_id'
,
'email'
,
'is_test'
)
->
orderBy
(
'create_time'
,
'desc'
)
->
first
();
$user
=
$UserMainModel
->
where
(
'email'
,
$mobile
)
->
select
(
'user_id'
,
'email'
,
'is_test'
)
->
orderBy
(
'create_time'
,
'desc'
)
->
first
();
}
else
{
}
else
{
...
@@ -108,47 +108,53 @@ Class AddOrderController extends Controller
...
@@ -108,47 +108,53 @@ Class AddOrderController extends Controller
}
}
}
}
if
(
empty
(
$user
))
return
[
'errcode'
=>
-
1
,
'errmsg'
=>
'未找用户信息'
];
// $perm = new PermController;
// $role = $perm->getUserRole($request); // 用户角色
// if ($goods_type == 1 || ($goods_type == 2 && !in_array($role, [1, 10, 11]))) { // 自营管理员、主管、主管助理可以帮客服下单
// $last_sale_id = $this->findLastSaleId($user->user_id);
if
(
!
empty
(
$user
))
{
// if ($last_sale_id && $operator_id != $last_sale_id) return ['errcode' => -1, 'errmsg' => '暂不能跟进该客户,请联系主管重新指派'];
$perm
=
new
PermController
;
// }
$role
=
$perm
->
getUserRole
(
$request
);
// 用户角色
if
(
$goods_type
==
1
||
(
$goods_type
==
2
&&
!
in_array
(
$role
,
[
1
,
10
,
11
])))
{
// 自营管理员、主管、主管助理可以帮客服下单
if
(
strpos
(
$_SERVER
[
'HTTP_HOST'
],
'sz'
)
===
false
)
{
// 非测试环境下执行
$last_sale_id
=
$this
->
findLastSaleId
(
$user
->
user_id
);
// 若用户已分配,则判断当前登录客服是否能给用户下单,若没分配,按之前流程,订单生成时分配给当前登录客服
$CrmModel
=
new
CrmModel
();
$sale_id
=
$CrmModel
->
getSaleId
(
$user
->
user_id
);
if
(
$last_sale_id
&&
$operator_id
!=
$last_sale_id
)
return
[
'errcode'
=>
-
1
,
'errmsg'
=>
'暂不能跟进该客户,请联系主管重新指派'
];
if
(
$sale_id
&&
$sale_id
!=
$operator_id
)
{
$CmsModel
=
new
CmsModel
();
$sale_name
=
$CmsModel
->
getUserName
(
$sale_id
);
return
[
'errcode'
=>
-
1
,
'errmsg'
=>
'该客户由 '
.
$sale_name
.
' 跟进,请联系主管重新指派'
];
}
}
}
$address
=
DB
::
connection
(
'order'
)
->
table
(
'lie_user_address'
)
->
where
(
'user_id'
,
$user
->
user_id
)
->
get
();
// 收货地址
$invoice
=
DB
::
connection
(
'order'
)
->
table
(
'lie_taxinfo'
)
->
where
(
'user_id'
,
$user
->
user_id
)
->
get
();
// 发票信息
$info
[
'user'
]
=
$user
;
$info
[
'address'
]
=
$address
;
$info
[
'invoice'
]
=
$invoice
;
$address
=
DB
::
connection
(
'order'
)
->
table
(
'lie_user_address'
)
->
where
(
'user_id'
,
$user
->
user_id
)
->
get
();
// 收货地址
return
[
'errcode'
=>
0
,
'errmsg'
=>
''
,
'data'
=>
$info
];
$invoice
=
DB
::
connection
(
'order'
)
->
table
(
'lie_taxinfo'
)
->
where
(
'user_id'
,
$user
->
user_id
)
->
get
();
// 发票信息
$info
[
'user'
]
=
$user
;
$info
[
'address'
]
=
$address
;
$info
[
'invoice'
]
=
$invoice
;
}
if
(
isset
(
$info
))
{
return
[
'errcode'
=>
0
,
'errmsg'
=>
''
,
'data'
=>
$info
];
}
else
{
return
[
'errcode'
=>
-
1
,
'errmsg'
=>
'未找用户信息'
];
}
}
}
}
}
// 获取用户最近的订单跟进业务员
// 获取用户最近的订单跟进业务员
public
function
findLastSaleId
(
$user_id
)
//
public function findLastSaleId($user_id)
{
//
{
$OrderModel
=
new
OrderModel
;
//
$OrderModel = new OrderModel;
$map
[
'user_id'
]
=
$user_id
;
//
$map['user_id'] = $user_id;
$map
[
'is_type'
]
=
0
;
// 过滤尽调数据
//
$map['is_type'] = 0; // 过滤尽调数据
$map
[]
=
[
'sale_id'
,
'>'
,
0
];
//
$map[] = ['sale_id', '>', 0];
$order
=
$OrderModel
->
where
(
$map
)
->
select
(
'sale_id'
)
->
orderBy
(
'order_id'
,
'desc'
)
->
first
();
//
$order = $OrderModel->where($map)->select('sale_id')->orderBy('order_id', 'desc')->first();
return
$order
?
$order
[
'sale_id'
]
:
0
;
//
return $order ? $order['sale_id'] : 0;
}
//
}
// 选择收货地址
// 选择收货地址
public
function
selectAddr
(
Request
$request
)
public
function
selectAddr
(
Request
$request
)
...
...
app/Model/CrmModel.php
0 → 100644
View file @
f13850ed
<?php
namespace
App\Model
;
use
Illuminate\Database\Eloquent\Model
;
class
CrmModel
extends
Model
{
protected
$connection
=
'crm'
;
protected
$table
=
'user'
;
protected
$primaryKey
=
'user_id'
;
public
$timestamps
=
false
;
// 获取用户绑定的业务员ID
public
function
getSaleId
(
$user_id
)
{
$user
=
$this
->
where
(
'outter_uid'
,
$user_id
)
->
select
(
'user_id'
)
->
first
();
if
(
!
$user
)
return
false
;
$sales
=
$this
->
from
(
'salesman'
)
->
where
(
'user_id'
,
$user
->
user_id
)
->
select
(
'sale_id'
)
->
first
();
return
$sales
?
$sales
->
sale_id
:
0
;
}
}
\ No newline at end of file
config/database.php
View file @
f13850ed
...
@@ -83,6 +83,20 @@ return [
...
@@ -83,6 +83,20 @@ return [
'prefix'
=>
''
,
'prefix'
=>
''
,
'strict'
=>
false
,
'strict'
=>
false
,
],
],
'crm'
=>
[
'driver'
=>
'mysql'
,
'host'
=>
env
(
'DB_HOST_CRM'
,
''
),
'database'
=>
env
(
'DB_DATABASE_CRM'
,
''
),
'username'
=>
env
(
'DB_USERNAME_CRM'
,
''
),
'password'
=>
env
(
'DB_PASSWORD_CRM'
,
''
),
'port'
=>
env
(
'DB_PORT'
,
3306
),
'charset'
=>
'utf8'
,
'collation'
=>
'utf8_unicode_ci'
,
'prefix'
=>
env
(
'DB_PREFIX_CRM'
,
''
),
'strict'
=>
false
,
],
'pcb'
=>
[
'pcb'
=>
[
'driver'
=>
'mysql'
,
'driver'
=>
'mysql'
,
'host'
=>
env
(
'DB_HOST_PCB'
,
''
),
'host'
=>
env
(
'DB_HOST_PCB'
,
''
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment