dever 3 years ago
parent
commit
61ab0c8a1b
2 changed files with 39 additions and 5 deletions
  1. 30 5
      service/option/lib/Agreement.php
  2. 9 0
      service/option/src/My.php

+ 30 - 5
service/option/lib/Agreement.php

@@ -23,7 +23,7 @@ class Agreement
         if ($source == 2) {
             # 获取当前登录的uid
             $aid = Dever::load('passport/user')->check(false);
-            $aid = 18;
+            $aid = 1;
             if (!$aid || $aid <= 0) {
                 Dever::alert('请先登录');
             }
@@ -57,6 +57,13 @@ class Agreement
             Dever::alert('您没有权限查看');
         }
 
+        if (isset($p['ids'])) {
+            $info['jiaofu_id'] = $p['ids'];
+        }
+        if (isset($p['total'])) {
+            $info['jiaofu_total'] = $p['total'];
+        }
+
         $method = 'pdf_' . $agreement['type'];
         return $this->$method($agreement, $info);
     }
@@ -73,8 +80,14 @@ class Agreement
     }
 
     # 合同名称
-    public function name($agreement, $info, $status = -1, $source = 1)
+    public function name($agreement, $info, $status = -1, $source = 1, $ids = false, $total = false)
     {
+        if (!$agreement) {
+            $agreement = Dever::db('setting/agreement')->find(array('type' => 6));
+            if (!$agreement) {
+                Dever::alert('协议模板不存在');
+            }
+        }
         if (is_numeric($agreement)) {
             $agreement = Dever::db('setting/agreement')->find($agreement);
         }
@@ -97,6 +110,12 @@ class Agreement
             $param['status'] = $status;
             $param['id'] = $info['id'];
             $param['agreement_id'] = $agreement['id'];
+            if ($ids) {
+                $param['ids'] = $ids;
+            }
+            if ($total) {
+                $param['total'] = $total;
+            }
             $param = Dever::encode(Dever::json_encode($param));
             $link = Dever::url('option/lib/agreement.show?p=' . $param);
             if ($source == 1) {
@@ -392,9 +411,15 @@ class Agreement
     {
         $base = Dever::db('setting/base')->find();
 
-        $jiaofu_id = explode(',', $info['jiaofu_id']);
-        $jiaofu = Dever::db('option/bill_jiaofu')->find($jiaofu_id[0]);
-        $info['jiaofu_date'] = date("Y年m月d日", $jiaofu['cdate']);
+        if (isset($info['jiaofu_id'])) {
+            $jiaofu_id = explode(',', $info['jiaofu_id']);
+            $jiaofu = Dever::db('option/bill_jiaofu')->find($jiaofu_id[0]);
+            $info['jiaofu_date'] = date("Y年m月d日", $jiaofu['cdate']);
+        } else {
+            $info['jiaofu_total'] = '0.00';
+            $info['jiaofu_date'] = date("Y年m月d日");
+        }
+        
 
         if (isset($info['qdate']) && $info['qdate']) {
             $qdate = date('Y年m月d日', $info['qdate']);

+ 9 - 0
service/option/src/My.php

@@ -62,8 +62,12 @@ class My extends Core
             'status' => 1,
             'desc' => '',
         );
+        $ids = array();
+        $total = 0;
         if ($this->data['list']) {
             foreach ($this->data['list'] as $k => $v) {
+                $ids[] = $v['id'];
+                $total += $v['cash'];
                 if ($v['audit'] == 4) {
                     $audit['status'] = 4;
                     $audit['desc'] = $v['audit_desc'];
@@ -74,9 +78,14 @@ class My extends Core
                 }
             }
         }
+        $total = number_format($total, 2, '.', '');
+        $ids = implode(',', $ids);
 
         $this->data['audit'] = $audit;
 
+        $name = Dever::load('option/lib/agreement')->name(false, $this->user, 1, 2, $ids, $total);
+        $this->data['agreement_link'] = $name[1];
+
         return $this->data;
     }