1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace app\allwin\widget;
- use app\common\facade\WechatMp;
- use Exception;
- class Inform{
-
- public static function order(array $param){
- $uid[] = $param['uid'];
-
- $worker = model('StoreWorker')->where(['store_id' => $param['store_id'],'is_cashier' => 1])->field('uid')->select()->toArray();
- if(!empty($worker)){
- $uid = array_merge(array_column($worker,'uid'),$uid);
- }
- $user = model('SystemUser')->where(['id' => $uid])->field('official_uid')->select();
- if(empty($user)){
- return;
- }
-
- $wechat = WechatMp::isTypes($param['miniapp_id']);
- if(empty($wechat)){
- return;
- }
- try {
- $wechat = $wechat->template_message;
- foreach ($user as $value) {
- if(!empty($value['official_uid'])){
- $wechat->send([
- 'touser' => $value['official_uid'],
- 'template_id' => $param['tplmsg'],
- 'data' => [
- 'first' => '微信买单已到账',
- 'keyword1' => $param['order_no'],
- 'keyword2' => ['value'=>'¥'.$param['amount'],'color' => '#FF0000'],
- 'keyword3' => $param['store_name'],
- 'keyword4' => date('Y-m-d H:i:s'),
- ],
- ]);
- }
- }
- }catch (Exception $e) {
- return;
- }
- }
- }
|