123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <?php
- namespace ln\services;
- use app\common\repositories\system\config\ConfigValueRepository;
- use ln\services\express\Express;
- use ln\services\product\Product;
- use ln\services\serve\Serve;
- use ln\services\sms\Sms;
- use think\facade\Cache;
- class CrmebServeServices
- {
-
- public function __construct()
- {
- }
-
- public function getConfig(array $config = [])
- {
- return array_merge([
- 'account' => systemConfig('serve_account'),
- 'secret' => systemConfig('serve_token')
- ], $config);
- }
-
- public function sms(array $config = [])
- {
- $account = systemConfig('sms_account');
- if ($account){
- $password = md5($account.systemConfig('sms_token'));
- $res = $this->user()->login($account, $password);
- if($res){
- Cache::set('serve_account', $account);
- $arr = [
- 'serve_account' => $account,
- 'serve_token' => $password,
- ];
- app()->make(ConfigValueRepository::class)->setFormData($arr, 0);
- Cache::delete('sms_account');
- request()->clearCache();
- }
- }
- return app()->make(Sms::class, [$this->getConfig($config)]);
- }
-
- public function copy(array $config = [])
- {
- return app()->make(Product::class, [$this->getConfig($config)]);
- }
-
- public function express(array $config = [])
- {
- return app()->make(Express::class, [$this->getConfig($config)]);
- }
-
- public function user(array $config = [])
- {
- return app()->make(Serve::class, [$this->getConfig($config)]);
- }
-
- public function getSmsTempsList(int $page, int $limit, int $type)
- {
- $list = $this->sms()->temps($page, $limit, $type);
- foreach ($list['data'] as &$item) {
- $item['templateid'] = $item['temp_id'];
- switch ((int)$item['temp_type']) {
- case 1:
- $item['type'] = '验证码';
- break;
- case 2:
- $item['type'] = '通知';
- break;
- case 30:
- $item['type'] = '营销短信';
- break;
- }
- }
- return $list;
- }
- }
|