格式化代码,调整模板消息发送类型

This commit is contained in:
liaofei 2019-11-19 17:52:35 +08:00
parent 1067d7e776
commit 2762c576b1
2 changed files with 67 additions and 62 deletions

View File

@ -1,4 +1,5 @@
<?php <?php
namespace app\models\routine; namespace app\models\routine;
use crmeb\utils\Template; use crmeb\utils\Template;
@ -71,13 +72,15 @@ class RoutineTemplate
$data['keyword5']['value'] = '已成功退款'; $data['keyword5']['value'] = '已成功退款';
return self::sendOut('ORDER_REFUND_SUCCESS', $order['uid'], $data); return self::sendOut('ORDER_REFUND_SUCCESS', $order['uid'], $data);
} }
/** /**
* 用户申请退款给管理员发送消息 * 用户申请退款给管理员发送消息
* @param array $order * @param array $order
* @param string $refundReasonWap * @param string $refundReasonWap
* @param array $adminList * @param array $adminList
*/ */
public static function sendOrderRefundStatus($order = array(),$refundReasonWap = '',$adminList = array()){ public static function sendOrderRefundStatus($order = array(), $refundReasonWap = '', $adminList = array())
{
$data['keyword1'] = $order['order_id']; $data['keyword1'] = $order['order_id'];
$data['keyword2'] = $refundReasonWap; $data['keyword2'] = $refundReasonWap;
$data['keyword3'] = date('Y-m-d H:i:s', time()); $data['keyword3'] = date('Y-m-d H:i:s', time());
@ -95,7 +98,8 @@ class RoutineTemplate
* @param int $bargainUserId * @param int $bargainUserId
* @return bool * @return bool
*/ */
public static function sendBargainSuccess($bargain = array(),$bargainUser = array(),$bargainUserId = 0){ public static function sendBargainSuccess($bargain = array(), $bargainUser = array(), $bargainUserId = 0)
{
$data['keyword1'] = $bargain['title']; $data['keyword1'] = $bargain['title'];
$data['keyword2'] = $bargainUser['bargain_price']; $data['keyword2'] = $bargainUser['bargain_price'];
$data['keyword3'] = $bargainUser['bargain_price_min']; $data['keyword3'] = $bargainUser['bargain_price_min'];
@ -114,7 +118,8 @@ class RoutineTemplate
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public static function sendOrderSuccess($formId = '',$orderId = ''){ public static function sendOrderSuccess($formId = '', $orderId = '')
{
if ($orderId == '') return; if ($orderId == '') return;
$order = StoreOrder::where('order_id', $orderId)->find(); $order = StoreOrder::where('order_id', $orderId)->find();
$data['keyword1'] = $orderId; $data['keyword1'] = $orderId;

View File

@ -34,7 +34,7 @@ class NoticeRepositories
$openid = $wechatUser['openid']; $openid = $wechatUser['openid'];
$routineOpenid = $wechatUser['routine_openid']; $routineOpenid = $wechatUser['routine_openid'];
try { try {
if ($openid) {//公众号发送模板消息 if ($openid && in_array($order['is_channel'],[0,2])) {//公众号发送模板消息
WechatTemplateService::sendTemplate($openid, WechatTemplateService::ORDER_PAY_SUCCESS, [ WechatTemplateService::sendTemplate($openid, WechatTemplateService::ORDER_PAY_SUCCESS, [
'first' => '亲,您购买的商品已支付成功', 'first' => '亲,您购买的商品已支付成功',
'keyword1' => $order['order_id'], 'keyword1' => $order['order_id'],
@ -51,7 +51,7 @@ class NoticeRepositories
]); ]);
//订单支付成功后给客服发送客服消息 //订单支付成功后给客服发送客服消息
CustomerRepository::sendOrderPaySuccessCustomerService($order, 1); CustomerRepository::sendOrderPaySuccessCustomerService($order, 1);
} else if ($routineOpenid) {//小程序发送模板消息 } else if ($routineOpenid && in_array($order['is_channel'],[1,2])) {//小程序发送模板消息
RoutineTemplate::sendOrderSuccess($formId, $order['order_id']); RoutineTemplate::sendOrderSuccess($formId, $order['order_id']);
//订单支付成功后给客服发送客服消息 //订单支付成功后给客服发送客服消息
CustomerRepository::sendOrderPaySuccessCustomerService($order, 0); CustomerRepository::sendOrderPaySuccessCustomerService($order, 0);