WxTplMsg.php
2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
defined('IN_IA') or exit('Access Denied');
require_once IA_ROOT . '/addons/zh_cjdianc/inc/wxlib/WxTpl.php';
class WxTplMsg
{
/**
* @param $uniacId
* @param $tplId
* @param $orderArr
* @param string $phrase3
* @param string $page
* @return mixed|null
*/
private static function orderNormalMsg($uniacId, $tplId, $orderArr, $phrase3 = '提示', $page = '')
{
$message = pdo_get('cjdc_message', array('uniacid' => $uniacId));
$user = pdo_get('cjdc_user', array('id' => $orderArr['user_id']));
$store = pdo_get('cjdc_store', array('id' => $orderArr['store_id']));
$ddxx = '订单';
if (1 == $orderArr['order_type']) {
$ddxx = "外卖订单";
} elseif (2 == $orderArr['order_type']) {
$ddxx = "自提订单";
}
if (empty($page)) {
$page = "zh_cjdianc/pages/Liar/loginindex";
}
$postData = [
'{touser}' => $user["openid"] ,
'{template_id}' => $message["jd_tid"],
'{page}' => $page,
'{phrase3}' => $phrase3,
'{character_string2}' => $orderArr['order_num'],
'{thing1}' => $store['name'],
'{amount4}' => $orderArr['money'],
'{phrase7}' => $ddxx
];
return WxTpl::onceSubscribe($uniacId, $postData, $tplId);
}
/**
* 接单信息
* @param $uniacId
* @param $orderArr
* @param string $phrase3
* @param string $page
* @return mixed|null
*/
static function sendPickOrderMsg($uniacId, $orderArr)
{
return self::orderNormalMsg($uniacId, WxTpl::NORMAL_ORDER, $orderArr, '已接单');
}
/**
* @param $uniacId
* @param $postData
* @return mixed|null
*/
static function sendRejectOrderMsg($uniacId, $orderArr)
{
return self::orderNormalMsg($uniacId, WxTpl::NORMAL_ORDER, $orderArr, '已拒绝', '');
}
/**
* @param $uniacId
* @param $orderArr
* @return mixed|null
*/
static function orderRefundMsg($uniacId, $orderArr)
{
$message = pdo_get('cjdc_message', array('uniacid' => $uniacId));
$user = pdo_get('cjdc_user', array('id' => $orderArr['user_id']));
$store = pdo_get('cjdc_store', array('id' => $orderArr['store_id']));
$page = "zh_cjdianc/pages/Liar/loginindex";
$tplId = WxTpl::REFUND_ORDER;
$postData = [
'{touser}' => $user["openid"] ,
'{template_id}' => $message["jd_tid"],
'{page}' => $page,
'{character_string1}' => $orderArr['order_num'],
'{thing8}' => $store['name'],
'{amount5}' => $orderArr['money'],
'{date2}' => date('Y-m-d H:i:s')
];
return WxTpl::onceSubscribe($uniacId, $postData, $tplId);
}
}