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
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
22 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;
use
App\Http\Error
;
use
App\Model\UserMainModel
;
use
App\Model\OrderModel
;
use
App\Model\CrmModel
;
use
App\Model\CmsModel
;
use
Excel
;
Class
AddOrderController
extends
Controller
...
...
@@ -97,10 +99,8 @@ Class AddOrderController extends Controller
$UserMainModel
=
new
UserMainModel
;
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
();
}
else
{
if
(
preg_match
(
'/@/'
,
$mobile
))
{
$user
=
$UserMainModel
->
where
(
'email'
,
$mobile
)
->
select
(
'user_id'
,
'email'
,
'is_test'
)
->
orderBy
(
'create_time'
,
'desc'
)
->
first
();
}
else
{
...
...
@@ -108,16 +108,27 @@ Class AddOrderController extends Controller
}
}
if
(
empty
(
$user
))
return
[
'errcode'
=>
-
1
,
'errmsg'
=>
'未找用户信息'
];
// $perm = new PermController;
// $role = $perm->getUserRole($request); // 用户角色
if
(
!
empty
(
$user
))
{
$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
(
$goods_type
==
1
||
(
$goods_type
==
2
&&
!
in_array
(
$role
,
[
1
,
10
,
11
])))
{
// 自营管理员、主管、主管助理可以帮客服下单
$last_sale_id
=
$this
->
findLastSaleId
(
$user
->
user_id
);
// if ($last_sale_id && $operator_id != $last_sale_id) return ['errcode' => -1, 'errmsg' => '暂不能跟进该客户,请联系主管重新指派'];
// }
if
(
$last_sale_id
&&
$operator_id
!=
$last_sale_id
)
return
[
'errcode'
=>
-
1
,
'errmsg'
=>
'暂不能跟进该客户,请联系主管重新指派'
];
if
(
strpos
(
$_SERVER
[
'HTTP_HOST'
],
'sz'
)
===
false
)
{
// 非测试环境下执行
// 若用户已分配,则判断当前登录客服是否能给用户下单,若没分配,按之前流程,订单生成时分配给当前登录客服
$CrmModel
=
new
CrmModel
();
$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
.
' 跟进,请联系主管重新指派'
];
}
}
$address
=
DB
::
connection
(
'order'
)
->
table
(
'lie_user_address'
)
->
where
(
'user_id'
,
$user
->
user_id
)
->
get
();
// 收货地址
...
...
@@ -126,29 +137,24 @@ Class AddOrderController extends Controller
$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
)
{
$OrderModel
=
new
OrderModel
;
//
public function findLastSaleId($user_id)
//
{
//
$OrderModel = new OrderModel;
$map
[
'user_id'
]
=
$user_id
;
$map
[
'is_type'
]
=
0
;
// 过滤尽调数据
$map
[]
=
[
'sale_id'
,
'>'
,
0
];
//
$map['user_id'] = $user_id;
//
$map['is_type'] = 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
)
...
...
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 [
'prefix'
=>
''
,
'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'
=>
[
'driver'
=>
'mysql'
,
'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