diff --git a/admin/controllers/base/HomeController.php b/admin/controllers/base/HomeController.php index f86e070..4357377 100644 --- a/admin/controllers/base/HomeController.php +++ b/admin/controllers/base/HomeController.php @@ -73,7 +73,7 @@ class HomeController extends BaseAdminController $admin = \Yii::$app->user->identity; $orderCount = ProductOrder::find()->where(['is_pay' => 1]); $totalPrice = Reconciliation::find()->where(['status' => 1]); - $inventoryWarning = DrugStoreRelations::find()->where(['<', 'stock', 100]); +// $inventoryWarning = DrugStoreRelations::find()->where(['<', 'stock', 100]); $drug = DrugStoreRelations::find(); // 处方订单 $prescriptionCount = Prescription::find()->where(['status' => 1]); @@ -111,7 +111,7 @@ class HomeController extends BaseAdminController if (!empty($where)) { $orderCount->andWhere($where)->andWhere($whereTime); $totalPrice->andWhere($where)->andWhere($whereTime); - $inventoryWarning->andWhere($where)->andWhere($whereTime); +// $inventoryWarning->andWhere($where)->andWhere($whereTime); $drug->where($where)->andWhere($whereTime); $registerCount->andWhere($where)->andWhere($whereTime); $prescriptionCount->andWhere($where)->andWhere($whereTime); @@ -124,7 +124,7 @@ class HomeController extends BaseAdminController return [ 'order' => intval($orderCount->count()), 'total_price' => round($totalPriceArr, 2), - 'inventory_warning' => intval($inventoryWarning->count()), +// 'inventory_warning' => intval($inventoryWarning->count()), 'drug' => intval($drug->count()), 'register' => intval($registerCount->count()), 'prescription' => intval($prescriptionCount->count()), diff --git a/admin/foundation/JsonResponseFormatter.php b/admin/foundation/JsonResponseFormatter.php index 3435840..1249800 100644 --- a/admin/foundation/JsonResponseFormatter.php +++ b/admin/foundation/JsonResponseFormatter.php @@ -13,17 +13,56 @@ use yii\helpers\Json; class JsonResponseFormatter extends \yii\web\JsonResponseFormatter { + private static $arr = [ + 'name', + 'contact', + 'mobile', + 'express_address', + 'clinical_diagnose', + 'drug_name', + 'drug_alias', + 'function', + 'usage', + 'express_mobile', + 'express_name', + 'express_region', + 'doctor', + ]; private $defaultErrorCode = -1; + public static function formatData($data, $errno = 0, $msg = '') { // if(empty($data)) $data = new \stdClass(); - if (empty($data)) $data = []; + if (empty($data)) { + $data = []; + } else { + if (array_key_exists('list', $data)) { + $data['list'] = self::aseEncode($data['list']); + } + } $result['data'] = $data; $result['msg'] = $msg; $result['errcode'] = $errno; return $result; } + + private static function aseEncode($data) { + if (is_array($data)) { + foreach ($data as $key => &$value) { + if (is_array($value)) { + $value = self::aseEncode($value); // 递归处理子数组 + } else { + if (in_array($key, self::$arr)) { + $value = ase_encode($value); // 加密指定键值 + } + } + } + } + return $data; + } + public $encrypt = true; //是不加密 + /** * Formats response data in JSON format. * @param \yii\web\Response $response diff --git a/helpers/helpers.php b/helpers/helpers.php index e90104d..29eb154 100644 --- a/helpers/helpers.php +++ b/helpers/helpers.php @@ -9,4 +9,21 @@ if (!function_exists('ds')) { ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT )); } +} +if (!function_exists('ase_encode')) { + function ase_encode($data) + { + // 获取随机字符串30个 + $random = ''; + for ($i = 0; $i < 30; $i++) { + $random .= chr(mt_rand(32, 126)); + } + return base64_encode($random. base64_encode($data)); + } +} +if (!function_exists('ase_decode')) { + function ase_decode($data) + { + return base64_decode(substr(base64_decode($data), 30)); + } } \ No newline at end of file