shish преди 5 години
родител
ревизия
7dda1758bf
променени са 3 файла, в които са добавени 41 реда и са изтрити 0 реда
  1. 7 0
      app/mall/controllers/TestController.php
  2. 20 0
      common/components/noticeUtil.php
  3. 14 0
      common/components/stringUtil.php

+ 7 - 0
app/mall/controllers/TestController.php

@@ -5,10 +5,17 @@ namespace mall\controllers;
 use biz\merchant\services\MerchantService;
 use biz\message\services\InformAdminService;
 use biz\order\services\OrderService;
+use common\components\notice;
 use common\components\util;
 use Yii;
 
 class TestController extends BaseController
 {
 
+	public function index()
+	{
+		echo 'ok';
+		notice::push();
+	}
+
 }

+ 20 - 0
common/components/noticeUtil.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace common\components;
+
+//通知系统
+use Yii;
+class notice
+{
+
+	public static function push()
+	{
+		$url = "https://oapi.dingtalk.com/robot/send?access_token=0856d031e07890f1902496747a0576a49c3df51dcf1e16427168cce12892bedb";
+		$curl = new curl\Curl();
+		$data = array ('msgtype' => 'text','text' => array ('content' => '【花卉宝】错误提示'));
+		$result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
+		$result = Json::decode($result);
+		print_r($result);
+	}
+
+}

+ 14 - 0
common/components/stringUtil.php

@@ -432,4 +432,18 @@ class stringUtil
         return uniqid($id);
     }
 
+	//参数格式化,错误提示查看友好 shish 2021.01.04
+	public static function paramsFriend($params)
+	{
+		$str = "[";
+		if (!empty($params) && is_array($params)) {
+			foreach ($params as $name => $item) {
+				$item = is_array($item) ? json_encode($item) : $item;
+				$str .= "\n{$name}=>{$item}";
+			}
+		}
+		$str .= "\n]";
+		return $str;
+	}
+ 
 }