|
@@ -5,6 +5,7 @@ namespace app\admin\controller;
|
|
|
|
|
|
|
|
|
use app\account\model\CompanyItem;
|
|
|
+use app\admin\model\AccountInvTips;
|
|
|
use app\admin\model\CompanyInvTips;
|
|
|
use app\admin\model\CompanyTips;
|
|
|
use app\admin\model\DepartTips;
|
|
@@ -244,4 +245,76 @@ class Tips extends Auth{
|
|
|
(new CompanyInvTips)->saveAll($list);
|
|
|
$this->success("导入成功");
|
|
|
}
|
|
|
+
|
|
|
+ //开票指标
|
|
|
+ public function account_inv_list(){
|
|
|
+ $params = $this->request->param(["uid"=>"","month"=>"","year"=>"","page"=>1,"size"=>15],"post","trim");
|
|
|
+ $where=[];
|
|
|
+ if ($params["uid"]!=="") $where[]=["uid","=",$params["uid"]];
|
|
|
+ if ($params["month"]!=="") $where[]=["month","=",$params["month"]];
|
|
|
+ if ($params["year"]!=="") $where[]=["year","=",$params["year"]];
|
|
|
+ $data = AccountInvTips::where($where)->order("id desc")->paginate(["page"=>$params['page'],"list_rows"=>$params['size']]);
|
|
|
+ $this->success("获取成功",["list"=>$data->items(),"count"=>$data->total()]);
|
|
|
+ }
|
|
|
+ public function account_inv_create(){
|
|
|
+ $params = $this->request->param(["uid"=>"","month"=>"","year"=>"","inv_tips"=>"","cost_tips"=>""],"post","trim");
|
|
|
+ $valid = Validate::rule([
|
|
|
+ "uid|用户id"=>"require|number",
|
|
|
+ "month|月份"=>"require|max:255|unique:app\admin\model\AccountInvTips,uid^month^year",
|
|
|
+ "year|年份"=>"require|max:255",
|
|
|
+ "inv_tips|开票指标"=>"require|float",
|
|
|
+ "cost_tips|毛利指标"=>"require|float",
|
|
|
+ ]);
|
|
|
+ if (!$valid->check($params)) $this->error($valid->getError(),1004);
|
|
|
+ $params["creater"] = $this->uname;
|
|
|
+ $params['uname'] = \app\account\model\User::where('account_id',$params['uid'])->value('nickname','');
|
|
|
+ AccountInvTips::create($params);
|
|
|
+ $this->success("添加成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ public function account_inv_update(){
|
|
|
+ $params = $this->request->param(["id"=>"","inv_tips"=>"","cost_tips"=>""],"post","trim");
|
|
|
+ $valid = Validate::rule([
|
|
|
+ "id|id"=>"require|integer",
|
|
|
+ "inv_tips|开票指标"=>"require|float",
|
|
|
+ "cost_tips|毛利指标"=>"require|float",
|
|
|
+ ]);
|
|
|
+ if (!$valid->check($params)) $this->error($valid->getError(),1004);
|
|
|
+ $info = AccountInvTips::where(["id"=>$params['id']])->findOrEmpty();
|
|
|
+ if ($info->isEmpty()) $this->error('数据不存在');
|
|
|
+ $info->save($params);
|
|
|
+ $this->success("修改成功");
|
|
|
+ }
|
|
|
+ public function account_inv_delete(){
|
|
|
+ $params = $this->request->param(["id"=>""],"post","trim");
|
|
|
+ $valid = Validate::rule([
|
|
|
+ "id|id"=>"require|integer",
|
|
|
+ ]);
|
|
|
+ if (!$valid->check($params)) $this->error($valid->getError(),1004);
|
|
|
+ $info = AccountInvTips::where(["id"=>$params['id']])->findOrEmpty();
|
|
|
+ if ($info->isEmpty()) $this->error('数据不存在');
|
|
|
+ $info->delete();
|
|
|
+ $this->success("删除成功");
|
|
|
+ }
|
|
|
+ public function account_inv_import(){
|
|
|
+ $list = $this->request->param("list",'post','trim');
|
|
|
+ $valid = Validate::rule([
|
|
|
+ "list|数据"=>"require|array",
|
|
|
+ ]);
|
|
|
+ if (!$valid->check($list)) $this->error($valid->getError(),1004);
|
|
|
+ $valids = Validate::rule([
|
|
|
+ 'uid|用户id'=>'require|number',
|
|
|
+ 'month|月份'=>'require|max:255|unique:app\admin\model\AccountInvTips,uid^month^year',
|
|
|
+ 'year|年份'=>'require|max:255',
|
|
|
+ 'inv_tips|开票指标'=>'require|float',
|
|
|
+ 'cost_tips|毛利指标'=>'require|float',
|
|
|
+ ]);
|
|
|
+ foreach ($list as &$item){
|
|
|
+ if (!$valids->check($item)) $this->error($valids->getError(),1004);
|
|
|
+ $item['creater'] = $this->uname;
|
|
|
+ $item['companyName'] = \app\account\model\User::where("account_id",$item['uid'])->value('nickname','');
|
|
|
+ }
|
|
|
+ (new AccountInvTips)->saveAll($list);
|
|
|
+ $this->success("导入成功");
|
|
|
+ }
|
|
|
}
|