| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
- // +----------------------------------------------------------------------
- // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
- // +----------------------------------------------------------------------
- // | Author: CRMEB Team <admin@crmeb.com>
- // +----------------------------------------------------------------------
- namespace app\services\message;
- use app\jobs\notice\EnterpriseWechatJob;
- use app\jobs\notice\PrintJob;
- use app\services\BaseServices;
- use app\services\order\StoreOrderCartInfoServices;
- use crmeb\exceptions\AdminException;
- use crmeb\services\CacheService;
- /**
- * 站内信services类
- * Class MessageSystemServices
- */
- class NoticeService extends BaseServices
- {
- /**
- * 发送消息类型
- * @var array
- */
- // protected $type = [
- // 'is_sms' => SmsService::class,
- // 'is_system' => SystemSendServices::class,
- // 'is_wechat' => WechatTemplateService::class,
- // 'is_routine' => RoutineTemplateServices::class,
- // 'is_ent_wechat' => EntWechatServices::class,
- // ];
- /**
- * @var array
- */
- protected $notceinfo;
- /**
- * @var string
- */
- protected $event;
- /**
- * @param string $event
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function setEvent(string $event)
- {
- if ($this->event != $event) {
- $this->notceinfo = CacheService::get('NOTCE_' . $event);
- if (!$this->notceinfo) {
- /** @var SystemNotificationServices $services */
- $services = app()->make(SystemNotificationServices::class);
- $notceinfo = $services->getOneNotce(['mark' => $event]);
- $this->notceinfo = $notceinfo ? $notceinfo->toArray() : [];
- CacheService::set('NOTCE_' . $event, $this->notceinfo);
- }
- $this->event = $event;
- }
- return $this;
- }
- /**
- * 打印订单
- * @param $order
- * @param array $cartId
- */
- public function orderPrint($order)
- {
- /** @var StoreOrderCartInfoServices $cartServices */
- $cartServices = app()->make(StoreOrderCartInfoServices::class);
- $product = $cartServices->getCartInfoPrintProduct($order['id']);
- if (!$product) {
- throw new AdminException(400463);
- }
- $switch = (bool)sys_config('pay_success_printing_switch');
- if (!$switch) {
- throw new AdminException(400464);
- }
- if (sys_config('print_type', 1) == 1) {
- $name = 'yi_lian_yun';
- $configData = [
- 'clientId' => sys_config('printing_client_id', ''),
- 'apiKey' => sys_config('printing_api_key', ''),
- 'partner' => sys_config('develop_id', ''),
- 'terminal' => sys_config('terminal_number', '')
- ];
- if (!$configData['clientId'] || !$configData['apiKey'] || !$configData['partner'] || !$configData['terminal']) {
- throw new AdminException(400465);
- }
- } else {
- $name = 'fei_e_yun';
- $configData = [
- 'feyUser' => sys_config('fey_user', ''),
- 'feyUkey' => sys_config('fey_ukey', ''),
- 'feySn' => sys_config('fey_sn', '')
- ];
- if (!$configData['feyUser'] || !$configData['feyUkey'] || !$configData['feySn']) {
- throw new AdminException(400465);
- }
- }
- PrintJob::dispatch('doJob', [$name, $configData, $order, $product]);
- }
- }
|