adminAction.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. <?php
  2. require_once(ONU_ROOT . 'application/lib/data/Base.class.php');
  3. class AdvertAdminAction extends BaseAction{
  4. //添加用户
  5. public function addUser($uname,$pwd){
  6. $sql = "insert into ly_user(uname,pwd) values('{$uname}','{$pwd}')";
  7. $result = $this->getDbEntity()->insert_sql($sql);
  8. return $result;
  9. }
  10. //登录
  11. public function selectUser($uname,$pwd){
  12. $sql = "select * from ly_user where uname='$uname' and pwd='$pwd' limit 1";
  13. $result = $this->getDbEntity()->query($sql);
  14. return $result[0];
  15. }
  16. //查询用户,通过uname
  17. public function selectUserByName($uname){
  18. $sql = "select * from ly_user where uname='$uname' limit 1";
  19. $result = $this->getDbEntity()->query($sql);
  20. return $result[0];
  21. }
  22. //查询所有用户
  23. public function selectAllUser(){
  24. $sql = "select * from ly_user ";
  25. $result = $this->getDbEntity()->query($sql);
  26. return $result;
  27. }
  28. //查询属于部门领导的用户
  29. public function selectHeaderUser(){
  30. $sql = "select id,uname from ly_user where role=2";
  31. $result = $this->getDbEntity()->query($sql);
  32. return $result;
  33. }
  34. //修改用户密码
  35. public function updateUserPwd($uname,$pwd){
  36. $sql = "update ly_user set pwd='{$pwd}' where uname='{$uname}'";
  37. $result = $this->getDbEntity()->execute_sql($sql);
  38. return $result;
  39. }
  40. //修改用户权限
  41. public function updateUserPersission($uname,$persission){
  42. $sql = "update ly_user set permission='{$persission}' where uname='{$uname}'";
  43. $result = $this->getDbEntity()->execute_sql($sql);
  44. return $result;
  45. }
  46. //修改用户角色及直属领导
  47. public function updateUserRole($data){
  48. $sql = "update ly_user set role='{$data['role']}',header_uid='{$data['header_uid']}' where uname='{$data['uname']}'";
  49. $result = $this->getDbEntity()->execute_sql($sql);
  50. return $result;
  51. }
  52. //删除用户
  53. public function deleteUser($uname){
  54. $sql = "delete from ly_user where uname='{$uname}'";
  55. $result = $this->getDbEntity()->query($sql);
  56. return $result;
  57. }
  58. //查询所有的图片
  59. public function selectAllImages(){
  60. $sql = "select * from ly_smt_images ";
  61. $result = $this->getDbEntity()->query($sql);
  62. return $result;
  63. }
  64. //导入客户,添加客户信息
  65. public function add_customer($data){
  66. $sql = "insert into ly_customer(email,uname,country,city,tel,uid,add_time,group_name) values
  67. ('{$data['email']}','{$data['uname']}','{$data['country']}','{$data['city']}','{$data['tel']}','{$data['uid']}','{$data['add_time']}','{$data['group_name']}')";
  68. $result = $this->getDbEntity()->insert_sql($sql);
  69. return $result;
  70. }
  71. public function add_sms_customer($data){
  72. $sql = "replace into ly_sms_customer(uname, country, tel, uid, group_name) values
  73. ('{$data['uname']}','{$data['country']}','{$data['tel']}','{$data['uid']}','{$data['group_name']}')";
  74. $result = $this->getDbEntity()->insert_sql($sql);
  75. return $result;
  76. }
  77. public function import_sms_customer($values){
  78. $sql = "replace into ly_sms_customer(uname, country, tel, uid, group_name) values" . $values;
  79. echo $sql; exit;
  80. $result = $this->getDbEntity()->insert_sql($sql);
  81. return $result;
  82. }
  83. //导入客户,批量添加客户信息
  84. public function addpl_customer($data){
  85. $sql = "insert into ly_customer(email,uname,country,city,tel,uid,add_time,group_name) values ";
  86. foreach ($data as $k => $v) {
  87. $sql .= "(\"{$v['email']}\",\"{$v['uname']}\",\"{$v['country']}\",\"{$v['city']}\",\"{$v['tel']}\",\"{$v['uid']}\",\"{$v['add_time']}\",\"{$v['group_name']}\"),";
  88. }
  89. $sql = substr($sql,0,-1);
  90. $sql .= ";";
  91. $result = $this->getDbEntity()->insert_sql($sql);
  92. return $result;
  93. }
  94. //导入黑名单,添加黑名单信息
  95. public function add_blacklist($data){
  96. $sql = "insert into ly_blacklist(email,uid,add_time) values
  97. ('{$data['email']}','{$data['uid']}','{$data['add_time']}')";
  98. $result = $this->getDbEntity()->insert_sql($sql);
  99. return $result;
  100. }
  101. public function selectCustomerCount($where){
  102. $sql = "select count(*) as count from ly_customer $where ";
  103. $result = $this->getDbEntity()->query($sql);
  104. return $result[0]['count'];
  105. }
  106. public function selectSmsCustomerCount($where){
  107. $sql = "select count(*) as count from ly_sms_customer $where ";
  108. $result = $this->getDbEntity()->query($sql);
  109. return $result[0]['count'];
  110. }
  111. public function selectBlacklistCount($where){
  112. $sql = "select count(*) as count from ly_blacklist $where ";
  113. $result = $this->getDbEntity()->query($sql);
  114. return $result[0]['count'];
  115. }
  116. //查询所有客户
  117. public function selesctCustomer($where,$limit){
  118. if(!empty($limit)){
  119. $sql = "select * from ly_customer $where order by id desc limit $limit ";
  120. }else{
  121. $sql = "select * from ly_customer $where order by id desc ";
  122. }
  123. $result = $this->getDbEntity()->query($sql);
  124. return $result;
  125. }
  126. public function selesctSmsCustomer($where,$limit){
  127. if(!empty($limit)){
  128. $sql = "select * from ly_sms_customer $where order by id desc limit $limit ";
  129. }else{
  130. $sql = "select * from ly_sms_customer $where order by id desc ";
  131. }
  132. $result = $this->getDbEntity()->query($sql);
  133. return $result;
  134. }
  135. //查询UID下所有客户Email
  136. public function selesctCustomerByUid($uid){
  137. $sql = "select email from ly_customer where 1=1 and uid = $uid ";
  138. $result = $this->getDbEntity()->query($sql);
  139. return $result;
  140. }
  141. //查询所有黑名单
  142. public function selesctBlacklist($where,$limit){
  143. if(!empty($limit)){
  144. $sql = "select * from ly_blacklist $where order by id desc limit $limit ";
  145. }else{
  146. $sql = "select * from ly_blacklist $where order by id desc ";
  147. }
  148. $result = $this->getDbEntity()->query($sql);
  149. return $result;
  150. }
  151. public function selectAllBlack($uid){
  152. $sql = "select email from ly_blacklist where uid=$uid";
  153. $result = $this->getDbEntity()->query($sql);
  154. return $result;
  155. }
  156. //查询客户信息
  157. public function selectOneCustomer($id){
  158. $sql = "select * from ly_customer where id='$id' ";
  159. $result = $this->getDbEntity()->query($sql);
  160. return $result[0];
  161. }
  162. public function selectOneSmsCustomer($id){
  163. $sql = "select * from ly_sms_customer where id='$id' ";
  164. $result = $this->getDbEntity()->query($sql);
  165. return $result[0];
  166. }
  167. //查询黑名单信息
  168. public function selectOneBlack($id){
  169. $sql = "select * from ly_blacklist where id='$id' ";
  170. $result = $this->getDbEntity()->query($sql);
  171. return $result[0];
  172. }
  173. //根据邮箱查询客户信息
  174. public function selectCustomerByEmail($email,$uid){
  175. $sql = "select * from ly_customer where email='$email' and uid='$uid' ";
  176. $result = $this->getDbEntity()->query($sql);
  177. return $result[0];
  178. }
  179. public function selectCustomerByTel($tel, $uid){
  180. $sql = "select * from ly_sms_customer where tel='$tel' and uid='$uid' ";
  181. $result = $this->getDbEntity()->query($sql);
  182. return $result[0];
  183. }
  184. //根据邮箱查询H黑名单信息
  185. public function selectBlackByEmail($email,$uid){
  186. $sql = "select * from ly_blacklist where email='$email' and uid='$uid' ";
  187. $result = $this->getDbEntity()->query($sql);
  188. return $result[0];
  189. }
  190. //编辑客户信息
  191. public function updateCustomer($data,$id){
  192. $sql = "update ly_customer set email='{$data['email']}',uname='{$data['uname']}',group_name='{$data['group_name']}',
  193. country = '{$data['country']}',city = '{$data['city']}',tel='{$data['tel']}'
  194. where id='$id'";
  195. $result = $this->getDbEntity()->execute_sql($sql);
  196. return $result;
  197. }
  198. public function updateSmsCustomer($data,$id){
  199. $sql = "update ly_sms_customer set uname='{$data['uname']}',group_name='{$data['group_name']}',
  200. country = '{$data['country']}',tel='{$data['tel']}'
  201. where id='$id'";
  202. $result = $this->getDbEntity()->execute_sql($sql);
  203. return $result;
  204. }
  205. //编辑黑名单信息
  206. public function updateBlack($data,$id){
  207. $sql = "update ly_blacklist set email='{$data['email']}'
  208. where id='$id'";
  209. $result = $this->getDbEntity()->execute_sql($sql);
  210. return $result;
  211. }
  212. //编辑客户信息
  213. public function updateCustomerByEmail($data){
  214. $sql = "update ly_customer set uname='{$data['uname']}',group_name='{$data['group_name']}',
  215. country = '{$data['country']}',city = '{$data['city']}',tel='{$data['tel']}'
  216. where uid='{$data['uid']}' and email='{$data['email']}'";
  217. $result = $this->getDbEntity()->execute_sql($sql);
  218. return $result;
  219. }
  220. //批量更新客户用户组信息
  221. public function updateCustomerGroupByEmail($data){
  222. $sql = "insert into ly_im_data_tmp (sql_content) values ";
  223. foreach ($data as $k => $v) {
  224. $sql_content['tabname'] = "ly_customer";
  225. $sql_content['exc'] = " update";
  226. $sql_content['data'] = $v;
  227. $sql .= "('".addslashes(serialize($sql_content))."'),";
  228. }
  229. $sql = substr($sql,0,-1);
  230. $sql .= ";";
  231. $result = $this->getDbEntity()->execute_sql($sql);
  232. return $result;
  233. }
  234. //删除客户信息
  235. public function deleteCustomer($id,$uid){
  236. $sql = "delete from ly_customer where id='$id' and uid='$uid' ";
  237. $result = $this->getDbEntity()->query($sql);
  238. return $result;
  239. }
  240. public function deleteSmsCustomer($id, $uid){
  241. $sql = "delete from ly_sms_customer where id='$id' and uid='$uid' ";
  242. $result = $this->getDbEntity()->query($sql);
  243. return $result;
  244. }
  245. //删除黑名单
  246. public function deleteBlack($id,$uid){
  247. $sql = "delete from ly_blacklist where id='$id' and uid='$uid' ";
  248. $result = $this->getDbEntity()->query($sql);
  249. return $result;
  250. }
  251. //按客户分组删除客户信息
  252. public function deleteCustomerByGroup($group_name,$uid){
  253. $sql = "delete from ly_customer where group_name='$group_name' and uid='$uid' ";
  254. $result = $this->getDbEntity()->query($sql);
  255. return $result;
  256. }
  257. //删除多个分组的客户信息
  258. public function deleteBatchCus($group_name,$uid){
  259. $sql = "delete from ly_customer where group_name in ($group_name) and uid='$uid' ";
  260. $result = $this->getDbEntity()->query($sql);
  261. return $result;
  262. }
  263. //批量删除客户信息
  264. public function deleteBatchCustomer($id_array,$uid){
  265. $sql = "delete from ly_customer where id in ($id_array) and uid='$uid' ";
  266. $result = $this->getDbEntity()->query($sql);
  267. return $result;
  268. }
  269. public function deleteBatchSmsCustomer($id_array, $uid){
  270. $sql = "delete from ly_sms_customer where id in ($id_array) and uid='$uid' ";
  271. $result = $this->getDbEntity()->query($sql);
  272. return $result;
  273. }
  274. //批量删除黑名单
  275. public function deleteBatchBlack($id_array,$uid){
  276. $sql = "delete from ly_blacklist where id in ($id_array) and uid='$uid' ";
  277. $result = $this->getDbEntity()->query($sql);
  278. return $result;
  279. }
  280. //批量删除用户分组
  281. public function deleteBatchUserGroup($id_array,$uid){
  282. $sql = "delete from ly_user_group where id in ($id_array) and uid='$uid' ";
  283. $result = $this->getDbEntity()->query($sql);
  284. return $result;
  285. }
  286. public function deleteBatchSmsUserGroup($id_array,$uid){
  287. $sql = "delete from ly_sms_user_group where id in ($id_array) and uid='$uid' ";
  288. $result = $this->getDbEntity()->query($sql);
  289. return $result;
  290. }
  291. //普通发送插入日志表 普通邮件发送日志表
  292. public function inserEmail1Log($data){
  293. $sql = "insert into ly_send_email1_log(to_user,subject,content,replay_to,`time`,message,uid) values
  294. ('{$data['to']}','{$data['subject']}','{$data['html']}','{$data['replyto']}','{$data['time']}','{$data['message']}','{$data['uid']}')";
  295. $result = $this->getDbEntity()->insert_sql($sql);
  296. return $result;
  297. }
  298. public function deleteBatchCustomerByEmail($id_array,$uid){
  299. $sql = "delete from ly_customer where email in ($id_array) and uid='$uid' ";
  300. $result = $this->getDbEntity()->query($sql);
  301. return $result;
  302. }
  303. //邮件模板列表
  304. public function select_msg_list($where,$limit){
  305. if(!empty($limit)){
  306. $sql = "select * from ly_email_template $where order by status asc,id desc limit $limit";
  307. }else{
  308. $sql = "select * from ly_email_template $where order by status asc,id desc";
  309. }
  310. $result = $this->getDbEntity()->query($sql);
  311. return $result;
  312. }
  313. //查询邮件模板数量
  314. public function select_msg_count($where){
  315. $sql = "select count(*) as count from ly_email_template $where ";
  316. $result = $this->getDbEntity()->query($sql);
  317. return $result[0]['count'];
  318. }
  319. //添加邮件模板
  320. public function add_email_msg($data){
  321. $sql = "insert into ly_email_template(msg_title,msg_content,status,add_time,`update_time`,uid,`type`) values
  322. ('{$data['msg_title']}','{$data['msg_content']}','{$data['status']}','{$data['add_time']}','{$data['update_time']}','{$data['uid']}','{$data['type']}')";
  323. $result = $this->getDbEntity()->insert_sql($sql);
  324. return $result;
  325. }
  326. //查询某一个邮件模板
  327. public function select_one_template($id){
  328. $sql = "select * from ly_email_template where id='$id' ";
  329. $result = $this->getDbEntity()->query($sql);
  330. return $result[0];
  331. }
  332. //修改邮件模板
  333. public function update_email_msg($data,$id,$uid){
  334. $sql = "update ly_email_template set msg_title='{$data['msg_title']}',msg_content='{$data['msg_content']}',
  335. status = '{$data['status']}',update_time = '{$data['update_time']}'
  336. where id='$id' and uid='$uid'";
  337. $result = $this->getDbEntity()->execute_sql($sql);
  338. return $result;
  339. }
  340. //禁用邮件模板
  341. public function deleteEmailTemplate($status,$id,$uid){
  342. $sql = "update ly_email_template set status='{$status}'
  343. where id='$id' and uid='$uid'";
  344. $result = $this->getDbEntity()->execute_sql($sql);
  345. return $result;
  346. }
  347. //查询所有用户分组
  348. public function select_user_group($where){
  349. $sql = "select * from ly_user_group $where order by id desc";
  350. $result = $this->getDbEntity()->query($sql);
  351. return $result;
  352. }
  353. //查询所有用户分组
  354. public function select_sms_user_group($where){
  355. $sql = "select * from ly_sms_user_group $where order by id desc";
  356. $result = $this->getDbEntity()->query($sql);
  357. return $result;
  358. }
  359. //添加用户分组
  360. public function add_user_group($data){
  361. $sql = "insert into ly_user_group(uid,`name`,add_time,update_time)
  362. values('{$data['uid']}','{$data['name']}','{$data['add_time']}','{$data['update_time']}')";
  363. $result = $this->getDbEntity()->insert_sql($sql);
  364. return $result;
  365. }
  366. public function add_sms_user_group($data){
  367. $sql = "insert into ly_sms_user_group(uid,`name`)
  368. values('{$data['uid']}','{$data['name']}')";
  369. $result = $this->getDbEntity()->insert_sql($sql);
  370. return $result;
  371. }
  372. //查询某个用户分组
  373. public function select_one_user_group($id,$uid){
  374. $sql = "select * from ly_user_group where id='$id' and uid='$uid'";
  375. $result = $this->getDbEntity()->query($sql);
  376. return $result[0];
  377. }
  378. //查询多个用户分组
  379. public function select_batch_user_group($in_array,$uid){
  380. $sql = "select * from ly_user_group where id in ($in_array) and uid='$uid'";
  381. $result = $this->getDbEntity()->query($sql);
  382. return $result;
  383. }
  384. //判断客户分组
  385. public function select_group_byName($group_name,$uid){
  386. $sql = "select * from ly_user_group where name='$group_name' and uid='$uid'";
  387. $result = $this->getDbEntity()->query($sql);
  388. return $result[0];
  389. }
  390. public function select_usergroup_byName($group_name,$uid){
  391. $sql = "select * from ly_sms_user_group where name='$group_name' and uid='$uid'";
  392. $result = $this->getDbEntity()->query($sql);
  393. return $result[0];
  394. }
  395. //修改用户分组
  396. public function update_user_group($data, $id,$uid){
  397. $sql = "update ly_user_group set
  398. `name` = '{$data['name']}',
  399. update_time = '{$data['update_time']}'
  400. where id='{$id}' and uid='$uid'";
  401. $result = $this->getDbEntity()->execute_sql($sql);
  402. return $result;
  403. }
  404. //查询分组用户的数量
  405. public function select_usergroup_count($where){
  406. $sql = "select count(*) as count from ly_customer $where";
  407. $result = $this->getDbEntity()->query($sql);
  408. return $result[0];
  409. }
  410. //查询用户分组里的所有用户
  411. public function select_usergroup_info($where,$limit){
  412. if(!empty($limit)){
  413. $sql = "select * from ly_customer $where order by add_time desc limit $limit";
  414. }else{
  415. $sql = "select * from ly_customer $where order by add_time desc";
  416. }
  417. $result = $this->getDbEntity()->query($sql);
  418. return $result;
  419. }
  420. //删除用户分组
  421. public function deleteUserGroupMsg($where){
  422. $sql = " delete from ly_user_group where $where";
  423. $result = $this->getDbEntity()->query($sql);
  424. return $result;
  425. }
  426. public function deleteSmsUserGroupMsg($where){
  427. $sql = " delete from ly_sms_user_group where $where";
  428. $result = $this->getDbEntity()->query($sql);
  429. return $result;
  430. }
  431. //查询退信用户是否存在
  432. public function select_ndr_user($where,$email){
  433. $sql = " select email from ly_ndr_user where $where and email='$email'";
  434. $result = $this->getDbEntity()->query($sql);
  435. return $result;
  436. }
  437. //查询所有退信用户
  438. public function selectAllNdrUser($uid){
  439. $sql = "select email from ly_ndr_user where uid=$uid";
  440. $result = $this->getDbEntity()->query($sql);
  441. return $result;
  442. }
  443. //插入退信用户
  444. public function insert_ndr_user($data){
  445. $sql = "insert into ly_ndr_user(uid,email)
  446. values('{$data['uid']}','{$data['email']}')";
  447. $result = $this->getDbEntity()->insert_sql($sql);
  448. return $result;
  449. }
  450. //查询临时表数据
  451. public function select_tmp_data(){
  452. $sql = " select id from ly_im_data_tmp ";
  453. $result = $this->getDbEntity()->query($sql);
  454. return $result;
  455. }
  456. //插入待发送邮件参数数据
  457. public function add_email_data_queue($data){
  458. $sql = 'INSERT INTO `ly_email_data_tmp` (`params_json`) VALUES ';
  459. $params_json = '';
  460. foreach($data as $value){
  461. $params_json = serialize($value);
  462. $sql .= "('{$params_json}'),";
  463. }
  464. $sql = trim($sql, ',').';';
  465. $result = $this->getDbEntity()->insert_sql($sql);
  466. return $result;
  467. }
  468. //查询代发邮件数量
  469. public function selectEmailTmpData(){
  470. $sql = 'SELECT COUNT(`id`) AS `ct` FROM `ly_email_data_tmp`;';
  471. $result = $this->getDbEntity()->query($sql);
  472. return $result;
  473. }
  474. //end
  475. }