SettingsController.class.php 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <?php
  2. /**
  3. * 小梦科技资源nanodreamtech.com
  4. *
  5. * ==========================================================================
  6. * @link https://www.nanodreamtech.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license https://www.nanodreamtech.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Seller\Controller;
  15. class SettingsController extends CommonController{
  16. protected function _initialize(){
  17. parent::_initialize();
  18. $this->breadcrumb1='系统';
  19. $this->breadcrumb2='站点设置';
  20. }
  21. function other(){
  22. $this->breadcrumb2='其他选项';
  23. $this->other=$this->get_config_by_group('other');
  24. $this->display();
  25. }
  26. function image(){
  27. $this->breadcrumb2='图片尺寸';
  28. $this->image=$this->get_config_by_group('image');
  29. $this->display();
  30. }
  31. function general(){
  32. $this->breadcrumb2='站点设置';
  33. $this->site=$this->get_config_by_group('site');
  34. $this->display();
  35. }
  36. function wxprogram()
  37. {
  38. $this->breadcrumb2='微信小程序配置';
  39. $this->site=$this->get_config_by_group('weixin');
  40. $this->type = 1;
  41. $this->display();
  42. }
  43. function wxprogram_template()
  44. {
  45. $this->breadcrumb2='微信小程序配置';
  46. $this->site=$this->get_config_by_group('weixin');
  47. $this->type = 2;
  48. $this->display();
  49. }
  50. function wxtempmsg()
  51. {
  52. $this->breadcrumb2='微信模板消息';
  53. $this->site=$this->get_config_by_group('weixin');
  54. $this->type = 1;
  55. $this->display();
  56. }
  57. function sendallwxmsg()
  58. {
  59. $this->breadcrumb2='微信模板消息';
  60. $this->type = 2;
  61. $this->display();
  62. }
  63. function sendallcuswxmsg()
  64. {
  65. $this->breadcrumb3='微信客服消息';
  66. $this->type = 3;
  67. $this->display();
  68. }
  69. function clearuserqrcode()
  70. {
  71. $result = array('code' =>1);
  72. $sql = "update ".C('DB_PREFIX')."member_common set qrcode_img ='' where member_id>0 ";
  73. M()->execute($sql);
  74. $sql = "update ".C('DB_PREFIX')."member set wepro_qrcode ='' where member_id>0 ";
  75. M()->execute($sql);
  76. echo json_encode($result);
  77. die();
  78. }
  79. function sendallcuswxmsg_save()
  80. {
  81. $data = I('post.');
  82. @set_time_limit(0);
  83. $template_data = array();
  84. if( empty($data['title']) )
  85. {
  86. $this->error('请填写标题');
  87. }
  88. if( empty($data['image']) )
  89. {
  90. $this->error('请上传封面图片');
  91. }
  92. if( empty($data['url_link']) )
  93. {
  94. $this->error('请填写链接');
  95. }
  96. $data['image'] = C('SITE_URL').'/Uploads/image/'.$data['image'];
  97. $template_data['title'] = $data['title'];
  98. $template_data['image'] = $data['image'];
  99. $template_data['descript'] = $data['descript'];
  100. $user_list = M('member')->select();
  101. foreach($user_list as $user)
  102. {
  103. if(empty($user['openid']))
  104. {
  105. continue;
  106. }
  107. $msg_order = array();
  108. $msg_order['template_data'] = serialize($template_data);
  109. $msg_order['url'] = $data['url_link'];
  110. $msg_order['type'] = 1;
  111. $msg_order['open_id'] = $user['openid'];
  112. $msg_order['template_id'] = 8888;
  113. $msg_order['state'] = 0;
  114. $msg_order['addtime'] = time();
  115. M('template_msg_order')->add($msg_order);
  116. }
  117. $this->success('保存成功,客服消息将会陆续发出!');
  118. }
  119. /**
  120. 群发自定义模板消息
  121. **/
  122. function sendallmodifywxmsg()
  123. {
  124. $this->type =4;
  125. $this->display();
  126. }
  127. /**
  128. 分析模板消息模板
  129. **/
  130. function sendallmodifywxmsg_analys()
  131. {
  132. $this->type =4;
  133. $moban = I('post.moban');
  134. $str = str_replace(array("\r\n", "\r", "\n"), "", $moban);
  135. preg_match_all('/{{(.*?)}}/',$str,$contain_arr);
  136. $data = $contain_arr[1];
  137. if(empty($data))
  138. {
  139. $this->error('模板格式错误');
  140. }
  141. $this->moban = $moban;
  142. $this->data = $data;
  143. $this->display();
  144. }
  145. /**
  146. 自定义模板消息保存
  147. **/
  148. public function sendallmodifywxmsg_save()
  149. {
  150. @set_time_limit(0);
  151. $data = I('post.');
  152. $url_link = $data['url_link'];
  153. $moban_id = $data['moban_id'];
  154. unset($data['url_link']);
  155. unset($data['moban_id']);
  156. $template_data = array();
  157. $page = empty($data['page']) ? 1: intval($data['page']);
  158. unset($data['page']);
  159. $per_count = 100;
  160. $offset = ($page-1)*$per_count;
  161. $total_count = M('member')->count();
  162. foreach($data as $key => $val)
  163. {
  164. if( strpos($key,'_color') === false )
  165. {
  166. $real_key = explode('_',$key);
  167. $tp_key = $real_key[0];
  168. $tp_color = empty($data[$key.'_color']) ? '#173177': trim($data[$key.'_color']);
  169. $template_data[$tp_key] = array('value' => ($val), 'color' => $tp_color);
  170. }
  171. }
  172. $template_id = $moban_id;
  173. $has_next = ( $total_count > ($offset+$per_count) ) ? 1:0;
  174. $del_count = $total_count - ($offset+$per_count);
  175. $user_list = M('member')->order('member_id asc')->limit($offset,$per_count)->select();
  176. foreach($user_list as $user)
  177. {
  178. if(empty($user['openid']))
  179. {
  180. continue;
  181. }
  182. $member_formid_info = M('member_formid')->where( array('state' =>0, 'member_id' =>$user['member_id']) )->find();
  183. if(!empty($member_formid_info))
  184. {
  185. $msg_order = array();
  186. $msg_order['template_data'] = serialize($template_data);
  187. $msg_order['url'] = $url_link;
  188. $msg_order['open_id'] = $user['we_openid'];
  189. $msg_order['template_id'] = $template_id;
  190. $msg_order['type'] = 2;
  191. $msg_order['state'] = 0;
  192. $msg_order['addtime'] = time();
  193. M('template_msg_order')->add($msg_order);
  194. }
  195. }
  196. $result = array();
  197. $result['code'] = 1;
  198. $result['has_next'] = $has_next;
  199. $result['del_count'] = $del_count;
  200. $result['offset'] = $offset;
  201. $result['per_count'] = $per_count;
  202. echo json_encode($result);
  203. die();
  204. //$this->success('保存成功,消息将会陆续发出!','/Settings/sendallmodifywxmsg');
  205. }
  206. function sendallwxmsg_save()
  207. {
  208. $data = I('post.');
  209. @set_time_limit(0);
  210. $title_color = empty($data['title_color']) ? '#173177':trim($data['title_color']);
  211. $goods_name_color = empty($data['goods_name_color']) ? '#173177':trim($data['goods_name_color']);
  212. $lian_man_color = empty($data['lian_man_color']) ? '#173177':trim($data['lian_man_color']);
  213. $lian_mobile_color = empty($data['lian_mobile_color']) ? '#173177':trim($data['lian_mobile_color']);
  214. $qv_address_color = empty($data['qv_address_color']) ? '#173177':trim($data['qv_address_color']);
  215. $description_color = empty($data['description_color']) ? '#173177':trim($data['description_color']);
  216. $template_data = array();
  217. $template_data['first'] = array('value' => ($data['title']), 'color' => $title_color);
  218. $template_data['keyword1'] = array('value' => ($data['goods_name']), 'color' => $goods_name_color);
  219. $template_data['keyword2'] = array('value' => ($data['lian_man']), 'color' => $lian_man_color);
  220. $template_data['keyword3'] = array('value' => ($data['lian_mobile']), 'color' => $lian_mobile_color);
  221. $template_data['keyword4'] = array('value' => ($data['qv_address']), 'color' => $qv_address_color);
  222. $template_data['remark'] = array('value' => ($data['description']), 'color' => $description_color);
  223. $url = $data['url_link'];
  224. $config = M('config')->where( array('name' => 'GoodsOnNoticeId') )->find();
  225. $template_id = $config['value'];
  226. $user_list = M('member')->select();
  227. foreach($user_list as $user)
  228. {
  229. if(empty($user['openid']))
  230. {
  231. continue;
  232. }
  233. $msg_order = array();
  234. $msg_order['template_data'] = serialize($template_data);
  235. $msg_order['url'] = $url;
  236. $msg_order['open_id'] = $user['openid'];
  237. $msg_order['template_id'] = $template_id;
  238. $msg_order['state'] = 0;
  239. $msg_order['addtime'] = time();
  240. M('template_msg_order')->add($msg_order);
  241. }
  242. $this->success('保存成功,消息将会陆续发出!');
  243. }
  244. function smtp_mail(){
  245. $this->breadcrumb2='邮件配置';
  246. $this->smtp=$this->get_config_by_group('smtp');
  247. $this->display();
  248. }
  249. function get_config_by_group($group){
  250. $list=M('config')->where(array('config_group'=>$group))->select();
  251. if(isset($list)){
  252. foreach ($list as $k => $v) {
  253. $config[$v['name']]=$v;
  254. }
  255. }
  256. return $config;
  257. }
  258. function save(){
  259. if(IS_POST){
  260. $config=I('post.');
  261. if($config && is_array($config)){
  262. $c=M('Config');
  263. foreach ($config as $name => $value) {
  264. $map = array('name' => $name);
  265. $c->where($map)->setField('value', $value);
  266. }
  267. }
  268. S('DB_CONFIG_DATA',null);
  269. $this->success('保存成功!');
  270. }
  271. }
  272. }
  273. ?>