dever 5 years ago
parent
commit
88b8fb82e2
4 changed files with 30 additions and 2 deletions
  1. 2 0
      act/database/form_id.php
  2. 1 0
      act/database/live_note.php
  3. 2 1
      act/lib/Form.php
  4. 25 1
      journal/lib/Pay.php

+ 2 - 0
act/database/form_id.php

@@ -120,6 +120,7 @@ return array
                 'num' => array('yes', '<'),
                 'num' => array('yes', '<'),
                 'type' => 'yes',
                 'type' => 'yes',
                 'uid' => 'yes',
                 'uid' => 'yes',
+                'cate_id' => 'yes',
                 'cdate' => array($time, '<='),
                 'cdate' => array($time, '<='),
                 'state' => 1,
                 'state' => 1,
             ),
             ),
@@ -135,6 +136,7 @@ return array
             'option' => array
             'option' => array
             (
             (
                 'type' => 'yes',
                 'type' => 'yes',
+                'cate_id' => 'yes',
                 'cdate' => array($time, '<='),
                 'cdate' => array($time, '<='),
                 'state' => 1,
                 'state' => 1,
             ),
             ),

+ 1 - 0
act/database/live_note.php

@@ -131,6 +131,7 @@ return array
             # 匹配的正则或函数 选填项
             # 匹配的正则或函数 选填项
             'option' => array
             'option' => array
             (
             (
+                'cate_id' => 'yes',
                 'uid' => 'yes',
                 'uid' => 'yes',
                 'note' => 1,
                 'note' => 1,
                 'state' => 1,
                 'state' => 1,

+ 2 - 1
act/lib/Form.php

@@ -7,7 +7,7 @@ use Dever;
 class Form
 class Form
 {
 {
     # 获取当前可用的formid
     # 获取当前可用的formid
-    public function get($uid, $type = 1)
+    public function get($uid, $type = 1, $system = 1)
     {
     {
         $where['uid'] = $uid;
         $where['uid'] = $uid;
         if ($type > 0) {
         if ($type > 0) {
@@ -20,6 +20,7 @@ class Form
         		$where['num'] = 1;
         		$where['num'] = 1;
         	}
         	}
         }
         }
+        $where['cate_id'] = $system;
         $info = Dever::db('act/form_id')->getAll($where);
         $info = Dever::db('act/form_id')->getAll($where);
 
 
         if ($info) {
         if ($info) {

+ 25 - 1
journal/lib/Pay.php

@@ -93,7 +93,7 @@ class Pay
                         'keyword2' => array('value' => '购买成功,您获得了 '.$journal['name'].' 的阅读资格!'),
                         'keyword2' => array('value' => '购买成功,您获得了 '.$journal['name'].' 的阅读资格!'),
                     );
                     );
                     $send['data'] = json_encode($send['data']);
                     $send['data'] = json_encode($send['data']);
-                    $send['form_id'] = Dever::load('act/lib/form')->get($uid, 2);
+                    $send['form_id'] = Dever::load('act/lib/form')->get($uid, 2, $order['cate_id']);
 
 
                     if ($send['form_id']) {
                     if ($send['form_id']) {
                         Dever::load('wechat_applet/msg.send', $send);
                         Dever::load('wechat_applet/msg.send', $send);
@@ -105,4 +105,28 @@ class Pay
             }
             }
         }
         }
 	}
 	}
+
+    public function send_api()
+    {
+        $uid = Dever::input('uid', 8);
+        # 发模板消息
+        $wechat = Dever::db('passport/wechat')->one(array('uid' => $uid));
+        if ($wechat && Dever::project('wechat_applet')) {
+            $send['key'] = 'buy_journal';
+            $send['project_id'] = 2;
+            $send['touser'] = $wechat['openid'];
+            $send['page'] = Dever::config('base')->applet_index . '?scene=' . Dever::login($uid) . ',' . '4,' . $order['product_id'];
+            $send['data'] = array
+            (
+                'keyword1' => array('value' => date('Y年m月d日 H:i', $order['cdate'])),
+                'keyword2' => array('value' => '购买成功,您获得了 '.$journal['name'].' 的阅读资格!'),
+            );
+            $send['data'] = json_encode($send['data']);
+            $send['form_id'] = Dever::load('act/lib/form')->get($uid, 2, $order['cate_id']);
+
+            if ($send['form_id']) {
+                Dever::load('wechat_applet/msg.send', $send);
+            }
+        }
+    }
 }
 }