OrderSalesmanController.php
3.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2019/6/9
* Time: 15:34
*/
namespace app\portal\controller;
use app\portal\model\IndentGoodsModel;
use app\portal\model\IndentModel;
use cmf\controller\WeChatBaseController;
use think\Db;
class OrderSalesmanController extends WeChatBaseController
{
protected $user_id;
public function _initialize(){
$user_id = cmf_get_current_user_id();
$this->user_id = $user_id;
$my_user = Db::name('my_user')->where(['uid'=>$user_id])->find();
if(empty($my_user)){
$this->error('查无此人','','','');
}
if($my_user['status'] != 2){
$this->error('您还不是业务员那','','','');
}
}
public function get_all(){
$param = $this->request->param();
if(!empty($param['is_courier'])){
$where['is_courier'] = ['eq',$param['is_courier']];
}
$user_id = $this->user_id;
$where['salesman_uid'] = ['eq',$user_id];
$where['indent_type'] = ['eq',2];
$where['state'] = ['neq',4];
$indentModel = new IndentModel();
$data = $indentModel->selectData($where);
$indentGoodsModel = new IndentGoodsModel();
foreach($data as $key => $vo){
$indent_goods = $indentGoodsModel->selectData(['indent_id'=>$vo['id']]);
$data[$key]['indent_goods'] = $indent_goods;
}
$school = Db::name('school')->where('uid',$user_id)->order('create_time desc')->select();
$this->assign('school',$school);
$this->assign('data',$data);
return $this->fetch();
}
public function getGradeClass(){
$school_id = $this->request->param('school_id',0,'intval');
if(empty($school_id)){
$this->error('缺少必要参数');
}
$grade = Db::name('grade_class')->where(['school_id'=>$school_id])->select()->toArray();
foreach($grade as $key => $g){
$class = explode('-',$g['class']);
$grade[$key]['start'] = $class[0];
$grade[$key]['end'] = $class[1];
}
$this->success('SUCCESS','',$grade);
}
public function getOrderSalesman(){
$param = $this->request->param();
if(!empty($param['school'])){
$where['school'] = ['eq',$param['school']];
}
if(!empty($param['grade'])){
$where['grade'] = ['eq',$param['grade']];
}
$user_id = $this->user_id;
$where['salesman_uid'] = ['eq',$user_id];
$where['indent_type'] = ['eq',2];
$where['state'] = ['neq',4];
$indentModel = new IndentModel();
$data = $indentModel->selectData($where);
$indentGoodsModel = new IndentGoodsModel();
foreach($data as $key => $vo){
$indent_goods = $indentGoodsModel->selectData(['indent_id'=>$vo['id']]);
$data[$key]['indent_goods'] = $indent_goods;
$dara[$key]['create_time'] = date('Y-m-d H:i:s',$vo['create_time']);
}
$this->success('SUCCESS','',$data);
}
}