dever 5 jaren geleden
bovenliggende
commit
88b8fb82e2
4 gewijzigde bestanden met toevoegingen van 30 en 2 verwijderingen
  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', '<'),
                 'type' => 'yes',
                 'uid' => 'yes',
+                'cate_id' => 'yes',
                 'cdate' => array($time, '<='),
                 'state' => 1,
             ),
@@ -135,6 +136,7 @@ return array
             'option' => array
             (
                 'type' => 'yes',
+                'cate_id' => 'yes',
                 'cdate' => array($time, '<='),
                 'state' => 1,
             ),

+ 1 - 0
act/database/live_note.php

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

+ 2 - 1
act/lib/Form.php

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

+ 25 - 1
journal/lib/Pay.php

@@ -93,7 +93,7 @@ class Pay
                         'keyword2' => array('value' => '购买成功,您获得了 '.$journal['name'].' 的阅读资格!'),
                     );
                     $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']) {
                         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);
+            }
+        }
+    }
 }