123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <?php
- defined('InShopNC') or exit('Access Invalid!');
- require_once(BASE_ROOT_PATH . '/helper/algorithm.php');
- require_once(BASE_ROOT_PATH . '/helper/account_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/sms_helper.php');
- class oper_smsControl extends SystemControl
- {
- public function __construct()
- {
- parent::__construct();
- }
- public function indexOp()
- {
- $sms_template = Model('sms_template');
- $template_list = $sms_template->select();
- Tpl::output('template_list', $template_list);
- Tpl::showpage('oper_sms');
- }
- public function sms_addOp()
- {
- $sms_title = trim($_POST['sms_title']);
- $yuntx_id = intval(trim($_POST['yuntx_id']));
- $sms_content = trim($_POST['sms_content']);
- if (empty($sms_title) || $yuntx_id <= 0 || empty($sms_content)) {
- return showMessage("参数错误", 'index.php?act=oper_sms&op=index', '', 'error');
- }
- $sms_template = Model('sms_template');
- $data = array('yuntx_id' => $yuntx_id, 'title' => $sms_title, 'content' => $sms_content);
- $ret = $sms_template->insert($data);
- if ($ret != false) {
- showMessage(Language::get('nc_common_save_succ'), 'index.php?act=oper_sms&op=index');
- } else {
- showMessage("存入数据库失败", 'index.php?act=oper_sms&op=index', '', 'error');
- }
- }
- private function add_params($input, &$err)
- {
- $params = [];
- $params['member']['input_type'] = $input['input_type'];
- if (empty($input['members'])) {
- $err = "手机号码或者SQL语句为空";
- return false;
- } else {
- $params['member']['data'] = $input['members'];
- }
- $params['member']['ex_brand'] = $input['ex_brand'] == 'on' ? true : false;
- $params['member']['ex_lrlz'] = $input['ex_lrlz'] == 'on' ? true : false;
- if($input['operatetype'] == 'sms')
- {
- $tmpid = $input['sms_template'];
- if ($tmpid <= 0) {
- $err = "错误的短信模版";
- return false;
- }
- $params['send']['type'] = 'sms';
- $params['send']['data'] = $tmpid;
- }
- else
- {
- if(empty($input['pushcontet'])) {
- $err = "push 内容不能为空";
- return false;
- } else {
- $params['send']['type'] = 'push';
- $params['send']['data'] = $input['pushcontet'];
- }
- }
- return $params;
- }
- public function send_sms_pushOp()
- {
- if (chksubmit())
- {
- $params = $this->add_params($_POST,$error);
- if($params == false) {
- showMessage($error,'index.php?act=person_bonus&op=add','','error');
- } else {
- QueueClient::push('sendPushOrSMS',$params);
- showMessage("成功放入推送队列", 'index.php?act=oper_sms&op=index');
- }
- }
- else
- {
- $items = Model()->table('sms_template')->where(array('disable' => 0))->field('yuntx_id,title,content')->select();
- Tpl::output('sms_tpls',$items);
- Tpl::showpage('oper_send.smspush');
- }
- }
- }
|