wugg 2 years ago
parent
commit
cec404b084
3 changed files with 165 additions and 1 deletions
  1. 1 1
      app/admin/controller/Menu.php
  2. 106 0
      app/admin/controller/OrderInv.php
  3. 58 0
      app/admin/controller/sale.php

+ 1 - 1
app/admin/controller/Menu.php

@@ -48,7 +48,7 @@ class Menu extends BaseController{
     * @throws \think\exception\DbException
     */
      public function   MenuAllList(){
-       $data = Db::name("admin_menu")->field("id,menu_name,menu_img,menu_route,menu_url,pid,is_show,is_private,menu_type,status")->order("weight desc,id asc")->select();
+       $data = Db::name("admin_menu")->field("id,menu_name,menu_img,menu_route,menu_url,pid,is_show,is_private,menu_type,status,weight")->order("weight desc,id asc")->select();
         $l= MenuTree($data,0);
         return app_show(0,"获取成功",$l);
     }

+ 106 - 0
app/admin/controller/OrderInv.php

@@ -0,0 +1,106 @@
+<?php
+
+
+namespace app\admin\controller;
+use app\admin\BaseController;
+use think\App;
+use think\facade\Db;
+
+class OrderInv extends BaseController{
+    public function __construct(App $app) {parent::__construct($app);}
+    /**
+     * 新建销售单开票申请
+     */
+   public function create(){
+       $buy_id = isset($this->post['buy_id'])&&$this->post['buy_id']!=='' ? intval($this->post['buy_id']):"";
+       if($buy_id==''){
+           return error_show(1004,"参数 buy_id 不能为空");
+       }
+           $buyinfo =Db::name("customer_invoice")->where(['id'=>$buy_id,"is_del"=>0])->find();
+           if($buyinfo==false){
+                 return error_show(1004,"购买方发票信息未找到");
+           }
+
+        $companyNo = isset($this->post['companyNo'])&&$this->post['companyNo']!=='' ? trim($this->post['companyNo']):"";
+       if($companyNo==''){
+           return error_show(1004,"参数 companyNo 不能为空");
+       }
+        $company = Db::name("company_info")->where(["companyNo"=>$companyNo])->find();
+       if($company==false){
+           return error_show(1004,"销售方信息未找到");
+       }
+        $khNo = isset($this->post['khNo'])&&$this->post['khNo']!=='' ? trim($this->post['khNo']):"";
+       if($khNo==''){
+           return error_show(1004,"参数 khNo 不能为空");
+       }
+       $customer = Db::name("customer_info")->where(["companyNo"=>$khNo])->find();
+       if($customer==false){
+           return error_show(1004,"客户信息未找到");
+       }
+       $invtype = isset($this->post['invtype'])&&$this->post['invtype']!=='' ? intval($this->post['invtype']):"";
+        if($invtype==''){
+           return error_show(1004,"参数 invtype 不能为空");
+       }
+        $email = isset($this->post['email'])&&$this->post['email']!=='' ? trim($this->post['email']):"";
+        $remark = isset($this->post['remark'])&&$this->post['remark']!=='' ? trim($this->post['remark']):"";
+        $orderArr = isset($this->post['orderArr'])&&!empty($this->post['orderArr']) ? $this->post['orderArr']:[];
+        if(empty($orderArr)){
+           return error_show(1004,"参数 orderArr 不能为空");
+        }
+        $temp =[];
+        $invNo=makeNo("INV");
+        $invfee=array_sum(array_column($orderArr,'inv_fee'));
+
+        foreach ($orderArr as $value){
+            if(!isset($value['sequenceNo']) ||$value['sequenceNo']==''){
+                   return error_show(1004,"参数 sequenceNo 不能为空");
+            }
+            $qrd = Db::name("qrd_info")->where(["sequenceNo"=>$value['sequenceNo']])->find();
+            if($qrd['status']==2){
+             return error_show(1004,"确认单{$value['sequenceNo']}不参与对账");
+            }
+            if(!isset($value['inv_fee']) || $value['inv_fee']===''){
+                   return error_show(1004,"参数 inv_fee 不能为空");
+            }
+            if($qrd['winv_fee']<$value['inv_fee']){
+             return error_show(1004,"确认单{$value['sequenceNo']}待开票金额不足");
+            }
+           $ascc=[
+               "assocNo"=>makeNo("AS"),
+               "apply_id"=>$this->uid,
+               "apply_name"=>$this->uname,
+               "type"=>1,
+               "orderCode"=>$value['sequenceNo'],
+               "viceCode"=>$invNo,
+               "order_total"=>$qrd['totalPrice'],
+               "vice_total"=>$invfee,
+               "cancel_fee"=>$value['inv_fee'],
+               "status"=>1,
+                "addtime"=>date("Y-m-d H:i:s"),
+                "updatetime"=>date("Y-m-d H:i:s")
+            ];
+            $temp[]=$ascc;
+        }
+          $inv=[
+            "invNo"=>$invNo,
+            "inv_value"=>$invfee,
+            "inv_out"=> $companyNo,
+            "inv_in"=>$khNo,
+            "apply_id"=>$this->uid,
+            "apply_name"=>$this->uname,
+            "inv_type"=>$invtype,//发票类型  专用 普通 电子专用 电子普通
+            "open_type"=>0, //开票类型 金税开票 金税线下 纯线下
+            "is_ticket"=>$company['out_ticket'], //是否支持金税开票
+            "remark"=>$remark, //申请备注
+            "exam_remark"=>'', //审核备注
+            "ainv_fee"=>0,//已核销金额
+            "winv_fee"=>$invfee,//未核销金额
+            "status"=>0,// 待财务开票/待金税开票   待财务审核 待填写物流 开票完成  开票失败/开票驳回   财务驳回
+            "is_del"=>0,
+            "email"=>$email,
+            "addtime"=>date("Y-m-d H:i:s"),
+            "updatetime"=>date("Y-m-d H:i:s")
+        ];
+
+   }
+}

+ 58 - 0
app/admin/controller/sale.php

@@ -7,6 +7,12 @@ use think\App;
 use think\facade\Db;
 class sale extends BaseController{
     public function __construct(App $app) {parent::__construct($app);}
+    /** 获取列表
+    * @return \think\response\Json|void
+    * @throws \think\db\exception\DataNotFoundException
+    * @throws \think\db\exception\DbException
+    * @throws \think\db\exception\ModelNotFoundException
+     */
     public function list(){
 
         $post =$this->request->param();
@@ -36,7 +42,59 @@ class sale extends BaseController{
         $pay_status =  isset($post['pay_status'])&&$post['pay_status']!==''?intval($post['pay_status']):'';
         if($pay_status!==''){
             $condition[]=["pay_status","=",$pay_status];
+        }
+         $qrdNo =  isset($post['sequenceNo'])&&$post['sequenceNo']!=''?trim($post['sequenceNo']):'';
+        if($qrdNo!==''){
+            $condition[]=["sequenceNo","=",$qrdNo];
+        }
+          $department =  isset($post['department'])&&$post['department']!=''?trim($post['department']):'';
+        if($department!==''){
+            $condition[]=["department","like","%$department%"];
+        }
+        $customerNo =  isset($post['customerNo'])&&$post['customerNo']!=''?trim($post['customerNo']):'';
+        if($customerNo!==''){
+            $condition[]=["customerNo","=",$customerNo];
+        }
+        $customer =  isset($post['customer'])&&$post['customer']!=''?trim($post['customer']):'';
+        if($customer!=''){
+            $condition[]=["customer","like","%$customer%"];
+        }
+       $platName =  isset($post['platName'])&&$post['platName']!=''?trim($post['platName']):'';
+        if($platName!=''){
+            $condition[]=["platName","like","%$platName%"];
         }
         $count =Db::name("qrd_info")->where($condition)->count();
+        $total = ceil($count/$size);
+        $page = $page>$total ? intval($total) : $page;
+        $list =Db::name("qrd_info")->where($condition)->page($page,$size)->select();
+        return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
     }
+   /**
+* 更改销售单状态 是否需要回款 0 未回款对账 1 回款对账 2 无需汇款操作
+ */
+    public function status(){
+     $post =$this->request->only(["sequenceNo"=>'',"status"=>0],"post","trim");
+     if($post['sequenceNo']==''){
+         return error_show(1004,"参数 sequenceNo 不能为空");
+     }
+      if($post['status']===''){
+         return error_show(1004,"参数 status 不能为空");
+     }
+      $qrdinfo =Db::name("qrd_info")->where("sequenceNo","=",$post['sequenceNo'])->findOrEmpty();
+        if(empty($qrdinfo)){
+          return error_show(1004,"未找到确认单信息");
+        }
+       $update=[
+           "status"=>$post['status'],
+           "updatetime"=>date("Y-m-d H:i:s")
+        ];
+        $up =Db::name("qrd_info")->where($qrdinfo)->update($update);
+        if($up){
+            return app_show(0,"更新成功");
+        }else{
+             return app_show(0,"更新失败");
+        }
+    }
+
+
 }