123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <?php
- namespace app\cxinv\controller;
- use app\cxinv\model\FinancialManager;
- use app\cxinv\model\ProductFz;
- use app\cxinv\model\ProductSeal;use think\App;
- class FinancialSeal extends Base{
- public function __construct(App $app) {
- parent::__construct($app);
- $this->model = new \app\cxinv\model\ProductFz();
- }
- // 列表
- public function list(){
- $params = $this->request->param(["page"=>1,"size"=>10,"company_code"=>"","status"=>"","fz_date"=>""],"post","trim");
- $where=[];
- if($params['company_code']!=''){
- $where[]=['company_code','=',$params['company_code']];
- }
- if($params['status']!=''){
- $where[]=['status','=',$params['status']];
- }
- if($params['fz_date']!=''){
- $where[]=['fz_date','=',$params['fz_date']];
- }
- $list = $this->model->where($where)->order('id desc')->paginate(['list_rows'=>$params['size'],'page'=>$params['page']]);
- return success('获取成功',['list'=>$list->items(),'count'=>$list->total()]);
- }
- public function getQuery(){
- $params = $this->request->param(['company_code'=>'','status'=>''],'post','trim');
- $where=[];
- if($params['company_code']!='') $where[]=['company_code','=',$params['company_code']];
- if($params['status']!='') $where[]=['status','=',$params['status']];
- $list=$this->model->where($where)->select();
- return success('获取成功',$list);
- }
- //0解封 1封账中 2 封账完成 3 封账失败
- public function status(){
- $params = $this->request->param(["id"=>"","status"=>""],"post","trim");
- $valid=$this->validate($params,[
- 'id'=>'require',
- 'status'=>'require|in:0,1,2,3'
- ]);
- if($valid!==true) return error($valid);
- $row = $this->model->findOrEmpty($params['id']);
- if($row->isEmpty()) return error('数据不存在');
- $getLastMonth= date("Y-m",strtotime("-1 month"));
- if($row['fz_date']!=$getLastMonth && $params['status']==0) return error('非上月数据不可解封');
- if($params['status']==1){
- $montah = date('Y-m',strtotime('-1 month',strtotime($row['fz_date'])));
- $lasMonth= $this->model->where('fz_date',$montah)->where('company_code',$row->company_code)->findOrEmpty();
- if(!$lasMonth->isEmpty()&& $lasMonth['status']!=2) return error($montah.'数据未封账');
- $mamger= FinancialManager::where(function($query) use($row){
- $query->whereOr([
- [['buyer_code','=',$row['company_code']],['type','in',[1,3]]],
- [['seller_code','=',$row['company_code']],['type','in',[2,4]]]
- ]);
- })->where(["status"=>1,"fz_date"=>$row['fz_date']])->findOrEmpty();
- if(!$mamger->isEmpty()) return error(FinancialManager::$ManagerType[$mamger['type']]."【{$mamger['id']}】未处理");
- }
- $row->status=$params['status'];
- $row->apply_id=$this->uid;
- $row->apply_name=$this->uname;
- $as = $row->save();
- if($as==false) return error('操作失败');
- return success('操作成功');
- }
- public function FzList(){
- $params = $this->request->param(["page"=>1,"size"=>10,"company_code"=>"","skuCode"=>"",'product_id'=>"","fz_date"=>""],"post","trim");
- $where=[];
- if($params['company_code']!=''){
- $where[]=['company_code','=',$params['company_code']];
- }
- if($params['product_id']!=''){
- $where[]=['product_id','=',$params['product_id']];
- }
- if($params['skuCode']!='') $where[]=['skuCode','like','%'.$params];
- if($params['fz_date']!=''){
- $where[]=['fz_date','=',$params['fz_date']];
- }
- $list = ProductSeal::with(["PorductFz",'Porduct'])->withJoin(["PorductFz"],"left")->where($where)->order('product_seal.id desc')->paginate(['list_rows'=>$params['size'],'page'=>$params['page']]);
- return success('获取成功',['list'=>$list->items(),'count'=>$list->total()]);
- }
- public function Export(){
- $params = $this->request->param(['company_code'=>'','status'=>'','fz_date'=>''],'post','trim');
- $where=[];
- if($params['company_code']!=''){
- $where[]=['company_code','=',$params['company_code']];
- }
- if($params['status']!=''){
- $where[]=['status','=',$params['status']];
- }
- if($params['fz_date']!=''){
- $where[]=['fz_date','=',$params['fz_date']];
- }
- $list = ProductSeal::with(["PorductFz",'Porduct'])->withJoin(['PorductFz'],'left')->where($where)->order('product_seal.id desc')->select();
- return success('获取成功',$list);
- }
- }
|