FinancialSeal.php 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. namespace app\cxinv\controller;
  3. use app\cxinv\model\ProductSeal;use think\App;
  4. class FinancialSeal extends Base{
  5. public function __construct(App $app) {
  6. parent::__construct($app);
  7. $this->model = new \app\cxinv\model\ProductFz();
  8. }
  9. // 列表
  10. public function list(){
  11. $params = $this->request->param(["page"=>1,"size"=>10,"company_code"=>"","status"=>"","fz_date"=>""],"post","trim");
  12. $where=[];
  13. if($params['company_code']!=''){
  14. $where[]=['company_code','=',$params['company_code']];
  15. }
  16. if($params['status']!=''){
  17. $where[]=['status','=',$params['status']];
  18. }
  19. if($params['fz_date']!=''){
  20. $where[]=['fz_date','=',$params['fz_date']];
  21. }
  22. $list = $this->model->where($where)->order('id desc')->paginate(['list_rows'=>$params['size'],'page'=>$params['page']]);
  23. return success('获取成功',['list'=>$list->items(),'count'=>$list->total()]);
  24. }
  25. public function getQuery(){
  26. $params = $this->request->param(['company_code'=>'','status'=>''],'post','trim');
  27. $where=[];
  28. if($params['company_code']!='') $where[]=['company_code','=',$params['company_code']];
  29. if($params['status']!='') $where[]=['status','=',$params['status']];
  30. $list=$this->model->where($where)->select();
  31. return success('获取成功',$list);
  32. }
  33. //0解封 1封账中 2 封账完成 3 封账失败
  34. public function status(){
  35. $params = $this->request->param(["id"=>"","status"=>""],"post","trim");
  36. $valid=$this->validate($params,[
  37. 'id'=>'require',
  38. 'status'=>'require|in:0,1'
  39. ]);
  40. if($valid!==true) return error($valid);
  41. $row = $this->model->findOrEmpty($params['id']);
  42. if($row->isEmpty()) return error('数据不存在');
  43. $getLastMonth= date("Y-m",strtotime("-1 month"));
  44. if($row['fz_date']!=$getLastMonth && $params['status']==0) return error('非上月数据不可解封');
  45. if($params['status']==1){
  46. $montah = date('Y-m',strtotime('-1 month',strtotime($row['fz_date'])));
  47. $lasMonth= $this->model->where('fz_date',$montah)->where('company_code',$row->company_code)->findOrEmpty();
  48. if(!$lasMonth->isEmpty()&& $lasMonth['status']!=2) return error($montah.'数据未封账');
  49. }
  50. $row->status=$params['status'];
  51. $row->apply_id=$this->uid;
  52. $row->apply_name=$this->uname;
  53. $as = $row->save();
  54. if($as==false) return error('操作失败');
  55. return success('操作成功');
  56. }
  57. public function FzList(){
  58. $params = $this->request->param(["page"=>1,"size"=>10,"company_code"=>"","skuCode"=>"",'product_id'=>"","fz_date"=>""],"post","trim");
  59. $where=[];
  60. if($params['company_code']!=''){
  61. $where[]=['company_code','=',$params['company_code']];
  62. }
  63. if($params['product_id']!=''){
  64. $where[]=['product_id','=',$params['product_id']];
  65. }
  66. if($params['skuCode']!='') $where[]=['skuCode','like','%'.$params];
  67. if($params['fz_date']!=''){
  68. $where[]=['fz_date','=',$params['fz_date']];
  69. }
  70. $list = ProductSeal::withJoin(["PorductFz"],"left")->where($where)->order('product_seal.id desc')->paginate(['list_rows'=>$params['size'],'page'=>$params['page']]);
  71. return success('获取成功',['list'=>$list->items(),'count'=>$list->total()]);
  72. }
  73. public function Export(){
  74. $params = $this->request->param(['company_code'=>'','status'=>'','fz_date'=>''],'post','trim');
  75. $where=[];
  76. if($params['company_code']!=''){
  77. $where[]=['company_code','=',$params['company_code']];
  78. }
  79. if($params['status']!=''){
  80. $where[]=['status','=',$params['status']];
  81. }
  82. if($params['fz_date']!=''){
  83. $where[]=['fz_date','=',$params['fz_date']];
  84. }
  85. $list = ProductSeal::withJoin(['PorductFz'],'left')->where($where)->order('product_seal.id desc')->select();
  86. return success('获取成功',$list);
  87. }
  88. }