diff --git a/app/Service/v3/Implementations/FeiePrintService.php b/app/Service/v3/Implementations/FeiePrintService.php index fbfae9d..aa18929 100644 --- a/app/Service/v3/Implementations/FeiePrintService.php +++ b/app/Service/v3/Implementations/FeiePrintService.php @@ -8,6 +8,7 @@ use App\Libs\FeiePrintClient; use App\Model\v3\Feprint; use App\Model\v3\OrderMain; use App\Service\v3\Interfaces\FeiePrintServiceInterface; +use App\Service\v3\Interfaces\HelperServiceInterface; use Hyperf\DbConnection\Db; use Hyperf\Di\Annotation\Inject; @@ -20,6 +21,12 @@ class FeiePrintService implements FeiePrintServiceInterface */ protected $log; + /** + * @Inject + * @var HelperServiceInterface + */ + protected $helperService; + // *必填*:飞鹅云后台注册账号 const USER = '13161443713@163.com'; // *必填*: 飞鹅云后台注册账号后生成的UKEY 【备注:这不是填打印机的KEY】 @@ -130,6 +137,8 @@ class FeiePrintService implements FeiePrintServiceInterface //$shopnum 当前为第几个店铺 $shopnum = 0; //循环处理子订单 + $arr->name = $this->helperService->filterEmoji($arr->name); + $arr->address = $this->helperService->filterEmoji($arr->address); foreach ($arr->orders as $k5 => $order) { $orderInfo .= '
'; $shopnum++; diff --git a/app/Service/v3/Implementations/HelperService.php b/app/Service/v3/Implementations/HelperService.php index 1b8e5db..473c23c 100644 --- a/app/Service/v3/Implementations/HelperService.php +++ b/app/Service/v3/Implementations/HelperService.php @@ -36,4 +36,16 @@ class HelperService implements HelperServiceInterface && $var != 'false' ); } + + public function filterEmoji($str) + { + $str = preg_replace_callback( + '/./u', + function (array $match) { + return strlen($match[0]) >= 4 ? '' : $match[0]; + }, + $str); + + return $str; + } } \ No newline at end of file diff --git a/app/Service/v3/Interfaces/HelperServiceInterface.php b/app/Service/v3/Interfaces/HelperServiceInterface.php index 4c0088c..88395e1 100644 --- a/app/Service/v3/Interfaces/HelperServiceInterface.php +++ b/app/Service/v3/Interfaces/HelperServiceInterface.php @@ -5,4 +5,6 @@ namespace App\Service\v3\Interfaces; interface HelperServiceInterface { public function makeNumCode($length); + public function nonempty($var); + public function filterEmoji($str); } \ No newline at end of file