123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <?php
- namespace app\services\serve;
- use app\services\BaseServices;
- use crmeb\services\express\Express;
- use crmeb\services\FormBuilder;
- use crmeb\services\product\Product;
- use crmeb\services\serve\Serve;
- use crmeb\services\sms\Sms;
- class ServeServices extends BaseServices
- {
-
- protected $builder;
-
- public function __construct(FormBuilder $builder)
- {
- $this->builder = $builder;
- }
-
- public function getConfig(array $config = [])
- {
- return array_merge([
- 'account' => sys_config('sms_account'),
- 'secret' => sys_config('sms_token')
- ], $config);
- }
-
- public function sms(array $config = [])
- {
- 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;
- }
-
- public function createSmsTemplateForm()
- {
- $field = [
- $this->builder->input('title', '模板名称')->placeholder('模板名称,如:订单支付成功'),
- $this->builder->input('content', '模板内容')->type('textarea')->placeholder('模板内容,如:您购买的商品已支付成功,支付金额{$pay_price}元,订单号{$order_id},感谢您的光临!(注:模板内容不用添加短信签名,可在一号通主页单独修改签名)')->rows(3),
- $this->builder->radio('type', '模板类型', 1)->options([['label' => '验证码', 'value' => 1], ['label' => '通知', 'value' => 2], ['label' => '推广', 'value' => 3]])
- ];
- return $field;
- }
-
- public function getSmsTemplateForm()
- {
- return create_form('申请短信模板', $this->createSmsTemplateForm(), $this->url('/notify/sms/temp'), 'POST');
- }
- }
|