|
@@ -48,25 +48,37 @@ class Pay
|
|
|
|
|
|
# 发消息
|
|
|
$journal = Dever::db('journal/info')->one($order['product_id']);
|
|
|
- Dever::load('message/lib/data')->push(-1, $uid, '购买提醒', '购买成功,您获得了 '.$journal['name'].' 的阅读资格!', $type = 1);
|
|
|
+
|
|
|
+ if (Dever::project('message')) {
|
|
|
+ Dever::load('message/lib/data')->push(-1, $uid, '购买提醒', '购买成功,您获得了 '.$journal['name'].' 的阅读资格!', $type = 1);
|
|
|
+ }
|
|
|
|
|
|
# 发模板消息
|
|
|
- /*
|
|
|
- $send['key'] = 'pay';
|
|
|
- $send['project_id'] = 1;
|
|
|
- $send['touser'] = 'pay';
|
|
|
- $send['page'] = 'page';
|
|
|
- $send['data'] = array
|
|
|
- (
|
|
|
- 'keyword1' => array('value', 1),
|
|
|
- );
|
|
|
- $send['form_id'] = 'pay';
|
|
|
+ $user = Dever::db('passport/user')->one($uid);
|
|
|
+ $wechat = Dever::db('passport/wechat')->one(array('uid' => $uid));
|
|
|
+ if ($wechat && Dever::project('wechat_applet')) {
|
|
|
+ $send['key'] = 'buy_journal';
|
|
|
+ $send['project_id'] = 1;
|
|
|
+ $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['form_id'] = Dever::load('act/lib/form')->get($this->data['uid'], 2);
|
|
|
|
|
|
- Dever::load('wechat_applet/msg.send', $send);
|
|
|
- */
|
|
|
+ if ($send['form_id']) {
|
|
|
+ Dever::load('wechat_applet/msg.send', $send);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
# 发短信
|
|
|
-
|
|
|
+ if (isset($user['mobile']) && $user['mobile'] && Dever::project('sms')) {
|
|
|
+ $send = array();
|
|
|
+ $send['name'] = $journal['name'];
|
|
|
+ Dever::load('sms/api.send', 'buy_journal', $user['mobile'], $send);
|
|
|
+ }
|
|
|
|
|
|
} else {
|
|
|
Dever::db('journal/order')->update(array('where_id' => $order['id'], 'status' => 3));
|