FinancialSeal.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. //0解封 1封账中 2 封账完成
  26. public function status(){
  27. $params = $this->request->param(["id"=>"","status"=>""],"post","trim");
  28. $row = $this->model->findOrEmpty($params['id']);
  29. if($row->isEmpty()) return error('数据不存在');
  30. $getLastMonth= date("Ym",strtotime("-1 month"));
  31. if($row['fz_date']!=$getLastMonth && $params['status']==0) return error('非上月数据不可解封');
  32. if($params['status']==1){
  33. $montah = strtotime('-1 month',strtotime($row['fz_date']));
  34. $lasMonth= $this->model->where('fz_date',$montah)->where('company_code',$row->company_code)->findOrEmpty();
  35. if(!$lasMonth->isEmpty()&& $lasMonth['status']!=2) return error($montah.'数据未封账');
  36. }
  37. $row->status=$params['status'];
  38. $row->apply_id=$this->uid;
  39. $row->apply_name=$this->uname;
  40. $as = $row->save();
  41. if($as==false) return error('操作失败');
  42. return success('操作成功');
  43. }
  44. public function FzList(){
  45. $params = $this->request->param(["page"=>1,"size"=>10,"company_code"=>"","status"=>"","fz_date"=>""],"post","trim");
  46. $where=[];
  47. if($params['company_code']!=''){
  48. $where[]=['company_code','=',$params['company_code']];
  49. }
  50. if($params['status']!=''){
  51. $where[]=['status','=',$params['status']];
  52. }
  53. if($params['fz_date']!=''){
  54. $where[]=['fz_date','=',$params['fz_date']];
  55. }
  56. $list = ProductSeal::withJoin(["PorductFz"],"left")->where($where)->order('product_seal.id desc')->paginate(['list_rows'=>$params['size'],'page'=>$params['page']]);
  57. return success('获取成功',['list'=>$list->items(),'count'=>$list->total()]);
  58. }
  59. }