diff --git a/app/Service/v3/Implementations/MiniprogramService.php b/app/Service/v3/Implementations/MiniprogramService.php index bb7b66c..4996a93 100644 --- a/app/Service/v3/Implementations/MiniprogramService.php +++ b/app/Service/v3/Implementations/MiniprogramService.php @@ -124,16 +124,7 @@ class MiniprogramService implements MiniprogramServiceInterface 'remark' => '感谢您的使用!' ]; - // $ret_store = $this->sendTempMsg($store['openid'], 'lxVbC6PVpKbiO44bYqLmacl-BaME70D47Q0jn2Link0',$data_store); - $ret_store = $this->sendTempMsg( - $store['openid'], - 'b9SR_3j6GhJvVjuIoYlil4-m09plcjNnI5lls1wHfpo', - $data_store, - true, - '/pages/orderDetail/orderDetail?global_order_id='.$globalOrderId, - '1461', - $item['money'] - ); + $ret_store = $this->sendTempMsg($store['openid'], 'lxVbC6PVpKbiO44bYqLmacl-BaME70D47Q0jn2Link0',$data_store); } } @@ -161,7 +152,7 @@ class MiniprogramService implements MiniprogramServiceInterface /** * @inheritDoc */ - public function sendTempMsg($openid, $template_id, $data, $isApplet = false, $redirect_url = '', $appletFormId = '', $appletEmKeyword = '', $applet_config = ['appid' => '', 'pagepath' => '']) + public function sendTempMsg($openid, $template_id, $data, $redirect_url = '', $applet_config = ['appid' => '', 'pagepath' => '']) { if (empty($openid) || empty($template_id) || empty($data)) { return ; @@ -177,15 +168,6 @@ class MiniprogramService implements MiniprogramServiceInterface ] ]; - if ($isApplet) { - $template['weapp_template_msg'] = [ - 'template_id' => $template_id, - 'page' => $redirect_url, - 'form_id' => $appletFormId, - 'emphasis_keyword' => $appletEmKeyword, - ]; - } - // 看看有没有小程序跳转的要求 $template['mp_template_msg']['miniprogram'] = $applet_config; @@ -194,47 +176,32 @@ class MiniprogramService implements MiniprogramServiceInterface return false; } - if ( !$isApplet ) { - if (is_array($data['first'])) { - $template['mp_template_msg']['data']['first']['value'] = $data['first'][0] ?? ''; - $template['mp_template_msg']['data']['first']['color'] = $data['first'][1] ?? ''; - } else { - $template['mp_template_msg']['data']['first']['value'] = $data['first']; - } - - if (isset($data['keyword'])&&is_array($data['keyword'])) { - foreach ($data['keyword'] as $key => &$keyword) { - $index = $key+1; + if (is_array($data['first'])) { + $template['mp_template_msg']['data']['first']['value'] = $data['first'][0] ?? ''; + $template['mp_template_msg']['data']['first']['color'] = $data['first'][1] ?? ''; + } else { + $template['mp_template_msg']['data']['first']['value'] = $data['first']; + } - if (is_array($keyword)) { - $template['mp_template_msg']['data']['keyword'.$index]['value'] = $keyword[0] ?? ''; - $template['mp_template_msg']['data']['keyword'.$index]['color'] = $keyword[1] ?? ''; - } else { - $template['mp_template_msg']['data']['keyword'.$index]['value'] = $keyword; - } + if (isset($data['keyword'])&&is_array($data['keyword'])) { + foreach ($data['keyword'] as $key => &$keyword) { + $index = $key+1; + if (is_array($keyword)) { + $template['mp_template_msg']['data']['keyword'.$index]['value'] = $keyword[0] ?? ''; + $template['mp_template_msg']['data']['keyword'.$index]['color'] = $keyword[1] ?? ''; + } else { + $template['mp_template_msg']['data']['keyword'.$index]['value'] = $keyword; } - } - if (is_array($data['remark'])) { - $template['mp_template_msg']['data']['remark']['value'] = $data['remark'][0] ?? ''; - $template['mp_template_msg']['data']['remark']['color'] = $data['remark'][1] ?? ''; - } else { - $template['mp_template_msg']['data']['remark']['value'] = $data['remark']; } - } else { - if (isset($data['keyword'])&&is_array($data['keyword'])) { - foreach ($data['keyword'] as $key => &$keyword) { - $index = $key+1; - - if (is_array($keyword)) { - $template['weapp_template_msg']['data']['keyword'.$index]['value'] = $keyword[0] ?? ''; - } else { - $template['weapp_template_msg']['data']['keyword'.$index]['value'] = $keyword; - } + } - } - } + if (is_array($data['remark'])) { + $template['mp_template_msg']['data']['remark']['value'] = $data['remark'][0] ?? ''; + $template['mp_template_msg']['data']['remark']['color'] = $data['remark'][1] ?? ''; + } else { + $template['mp_template_msg']['data']['remark']['value'] = $data['remark']; } $app = Factory::miniProgram(config('wechat.applet')); diff --git a/app/Service/v3/Interfaces/MiniprogramServiceInterface.php b/app/Service/v3/Interfaces/MiniprogramServiceInterface.php index 1521115..9112b83 100644 --- a/app/Service/v3/Interfaces/MiniprogramServiceInterface.php +++ b/app/Service/v3/Interfaces/MiniprogramServiceInterface.php @@ -33,12 +33,9 @@ interface MiniprogramServiceInterface * @param $openid * @param $template_id * @param $data - * @param bool $isApplet * @param string $redirect_url - * @param string $appletFormId - * @param string $appletEmKeyword * @param string[] $applet_config * @return mixed */ - public function sendTempMsg($openid, $template_id, $data, $isApplet = false, $redirect_url = '', $appletFormId = '', $appletEmKeyword = '', $applet_config = ['appid' => '', 'pagepath' => '']); + public function sendTempMsg($openid, $template_id, $data, $redirect_url = '', $applet_config = ['appid' => '', 'pagepath' => '']); } \ No newline at end of file