Receivable.php
3.19 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
88
89
90
91
92
93
94
95
96
<?php
namespace app\admin\controller\antis\customer;
use app\admin\controller\antis\Base;
use think\Db;
use think\Exception;
/**
*
* 应收款
*/
class Receivable extends Base
{
protected $model = null;
public function _initialize()
{
parent::_initialize();
}
/**
* 查看
*/
public function index()
{
if ($this->request->isAjax()) {
$params = $this->request->param();
// halt($params);
$data = \addons\qingdong\model\Contract::with(['business','customer'])->where(function($query)use($params){
if(!empty($params['main_fabhjb'])){
$query->whereLike('main_fabhjb',"%{$params['main_fabhjb']}%");
}else{
$query->whereLike('main_fabhjb','');
}
//项目名称不是合同名称
if(!empty($params['name'])){
$ids = \addons\qingdong\model\Business::whereLike('name',"%{$params['name']}%")->column('id');
$query->whereIn('business_id',$ids);
}else{
$query->where('business_id','');
}
if(!empty($params['num'])){
$query->whereLike('num',"%{$params['num']}%");
}else{
$query->whereLike('num','');
}
})->find();
// halt($data);
// $data = ['12','344'];
if(empty($data)){
$this->error('暂无数据','');
}
$data = $data->toArray();
$business = \addons\qingdong\model\Business::where('id',$data['business']['id'])->find();
if($business){
$business = $business->toArray();
$business['technical_id'] = \addons\qingdong\model\Staff::where('id',$business['technical_id'])->value('name');
}
$data['business']['technical_id'] = $business['technical_id'];
// halt($data['business']);
$this->success('查询成功','',$data);
}
return $this->view->fetch();
}
public function getGoodsSales()
{
$id = 98;
$ids = Db::name('tmrxyo')->where('status','2')->where('contract_id',$id??0)->column('id');
// halt($ids);
$sales_ids = Db::name('amodel_goods')->whereIn('tmrxyo_id',$ids)->column('sales_id');
$list = Db::name('kuerp_goods_sales')->whereIn('id',$sales_ids)->order('createtime desc')->paginate()->each(function($item){
$item['createtime'] = date('Y-m-d',$item['createtime']);
return $item;
});
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
}
public function getHk()
{
$model = new \addons\antis\model\Receivables();
$where = [];
$list = $model->where($where)->with(['customer', 'contract','ownerStaff'])->order('createtime desc')->paginate();
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
}
}