adminAction.lijg.20200529.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  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. //导入客户,批量添加客户信息
  72. public function addpl_customer($data){
  73. $sql = "insert into ly_customer(email,uname,country,city,tel,uid,add_time,group_name) values ";
  74. foreach ($data as $k => $v) {
  75. $sql .= "('{$v['email']}','{$v['uname']}','{$v['country']}','{$v['city']}','{$v['tel']}','{$v['uid']}','{$v['add_time']}','{$v['group_name']}'),";
  76. }
  77. $sql = substr($sql,0,-1);
  78. $sql .= ";";
  79. $result = $this->getDbEntity()->insert_sql($sql);
  80. return $result;
  81. }
  82. //导入黑名单,添加黑名单信息
  83. public function add_blacklist($data){
  84. $sql = "insert into ly_blacklist(email,uid,add_time) values
  85. ('{$data['email']}','{$data['uid']}','{$data['add_time']}')";
  86. $result = $this->getDbEntity()->insert_sql($sql);
  87. return $result;
  88. }
  89. public function selectCustomerCount($where){
  90. $sql = "select count(*) as count from ly_customer $where ";
  91. $result = $this->getDbEntity()->query($sql);
  92. return $result[0]['count'];
  93. }
  94. public function selectBlacklistCount($where){
  95. $sql = "select count(*) as count from ly_blacklist $where ";
  96. $result = $this->getDbEntity()->query($sql);
  97. return $result[0]['count'];
  98. }
  99. //查询所有客户
  100. public function selesctCustomer($where,$limit){
  101. if(!empty($limit)){
  102. $sql = "select * from ly_customer $where order by id desc limit $limit ";
  103. }else{
  104. $sql = "select * from ly_customer $where order by id desc ";
  105. }
  106. $result = $this->getDbEntity()->query($sql);
  107. return $result;
  108. }
  109. //查询UID下所有客户Email
  110. public function selesctCustomerByUid($uid){
  111. $sql = "select email from ly_customer where 1=1 and uid = $uid ";
  112. $result = $this->getDbEntity()->query($sql);
  113. return $result;
  114. }
  115. //查询所有黑名单
  116. public function selesctBlacklist($where,$limit){
  117. if(!empty($limit)){
  118. $sql = "select * from ly_blacklist $where order by id desc limit $limit ";
  119. }else{
  120. $sql = "select * from ly_blacklist $where order by id desc ";
  121. }
  122. $result = $this->getDbEntity()->query($sql);
  123. return $result;
  124. }
  125. public function selectAllBlack($uid){
  126. $sql = "select email from ly_blacklist where uid=$uid";
  127. $result = $this->getDbEntity()->query($sql);
  128. return $result;
  129. }
  130. //查询客户信息
  131. public function selectOneCustomer($id){
  132. $sql = "select * from ly_customer where id='$id' ";
  133. $result = $this->getDbEntity()->query($sql);
  134. return $result[0];
  135. }
  136. //查询黑名单信息
  137. public function selectOneBlack($id){
  138. $sql = "select * from ly_blacklist where id='$id' ";
  139. $result = $this->getDbEntity()->query($sql);
  140. return $result[0];
  141. }
  142. //根据邮箱查询客户信息
  143. public function selectCustomerByEmail($email,$uid){
  144. $sql = "select * from ly_customer where email='$email' and uid='$uid' ";
  145. $result = $this->getDbEntity()->query($sql);
  146. return $result[0];
  147. }
  148. //根据邮箱查询H黑名单信息
  149. public function selectBlackByEmail($email,$uid){
  150. $sql = "select * from ly_blacklist where email='$email' and uid='$uid' ";
  151. $result = $this->getDbEntity()->query($sql);
  152. return $result[0];
  153. }
  154. //编辑客户信息
  155. public function updateCustomer($data,$id){
  156. $sql = "update ly_customer set email='{$data['email']}',uname='{$data['uname']}',group_name='{$data['group_name']}',
  157. country = '{$data['country']}',city = '{$data['city']}',tel='{$data['tel']}'
  158. where id='$id'";
  159. $result = $this->getDbEntity()->execute_sql($sql);
  160. return $result;
  161. }
  162. //编辑黑名单信息
  163. public function updateBlack($data,$id){
  164. $sql = "update ly_blacklist set email='{$data['email']}'
  165. where id='$id'";
  166. $result = $this->getDbEntity()->execute_sql($sql);
  167. return $result;
  168. }
  169. //编辑客户信息
  170. public function updateCustomerByEmail($data){
  171. $sql = "update ly_customer set uname='{$data['uname']}',group_name='{$data['group_name']}',
  172. country = '{$data['country']}',city = '{$data['city']}',tel='{$data['tel']}'
  173. where uid='{$data['uid']}' and email='{$data['email']}'";
  174. $result = $this->getDbEntity()->execute_sql($sql);
  175. return $result;
  176. }
  177. //批量更新客户用户组信息
  178. public function updateCustomerGroupByEmail($data){
  179. $sql = "insert into ly_im_data_tmp (sql_content) values ";
  180. foreach ($data as $k => $v) {
  181. $sql_content['tabname'] = "ly_customer";
  182. $sql_content['exc'] = " update";
  183. $sql_content['data'] = $v;
  184. $sql .= "('".addslashes(serialize($sql_content))."'),";
  185. }
  186. $sql = substr($sql,0,-1);
  187. $sql .= ";";
  188. $result = $this->getDbEntity()->execute_sql($sql);
  189. return $result;
  190. }
  191. //删除客户信息
  192. public function deleteCustomer($id,$uid){
  193. $sql = "delete from ly_customer where id='$id' and uid='$uid' ";
  194. $result = $this->getDbEntity()->query($sql);
  195. return $result;
  196. }
  197. //删除黑名单
  198. public function deleteBlack($id,$uid){
  199. $sql = "delete from ly_blacklist where id='$id' and uid='$uid' ";
  200. $result = $this->getDbEntity()->query($sql);
  201. return $result;
  202. }
  203. //按客户分组删除客户信息
  204. public function deleteCustomerByGroup($group_name,$uid){
  205. $sql = "delete from ly_customer where group_name='$group_name' and uid='$uid' ";
  206. $result = $this->getDbEntity()->query($sql);
  207. return $result;
  208. }
  209. //删除多个分组的客户信息
  210. public function deleteBatchCus($group_name,$uid){
  211. $sql = "delete from ly_customer where group_name in ($group_name) and uid='$uid' ";
  212. $result = $this->getDbEntity()->query($sql);
  213. return $result;
  214. }
  215. //批量删除客户信息
  216. public function deleteBatchCustomer($id_array,$uid){
  217. $sql = "delete from ly_customer where id in ($id_array) and uid='$uid' ";
  218. $result = $this->getDbEntity()->query($sql);
  219. return $result;
  220. }
  221. //批量删除黑名单
  222. public function deleteBatchBlack($id_array,$uid){
  223. $sql = "delete from ly_blacklist where id in ($id_array) and uid='$uid' ";
  224. $result = $this->getDbEntity()->query($sql);
  225. return $result;
  226. }
  227. //批量删除用户分组
  228. public function deleteBatchUserGroup($id_array,$uid){
  229. $sql = "delete from ly_user_group where id in ($id_array) and uid='$uid' ";
  230. $result = $this->getDbEntity()->query($sql);
  231. return $result;
  232. }
  233. //普通发送插入日志表 普通邮件发送日志表
  234. public function inserEmail1Log($data){
  235. $sql = "insert into ly_send_email1_log(to_user,subject,content,replay_to,`time`,message,uid) values
  236. ('{$data['to']}','{$data['subject']}','{$data['html']}','{$data['replyto']}','{$data['time']}','{$data['message']}','{$data['uid']}')";
  237. $result = $this->getDbEntity()->insert_sql($sql);
  238. return $result;
  239. }
  240. //邮件模板列表
  241. public function select_msg_list($where,$limit){
  242. if(!empty($limit)){
  243. $sql = "select * from ly_email_template $where order by status asc,id desc limit $limit";
  244. }else{
  245. $sql = "select * from ly_email_template $where order by status asc,id desc";
  246. }
  247. $result = $this->getDbEntity()->query($sql);
  248. return $result;
  249. }
  250. //查询邮件模板数量
  251. public function select_msg_count($where){
  252. $sql = "select count(*) as count from ly_email_template $where ";
  253. $result = $this->getDbEntity()->query($sql);
  254. return $result[0]['count'];
  255. }
  256. //添加邮件模板
  257. public function add_email_msg($data){
  258. $sql = "insert into ly_email_template(msg_title,msg_content,status,add_time,`update_time`,uid,`type`) values
  259. ('{$data['msg_title']}','{$data['msg_content']}','{$data['status']}','{$data['add_time']}','{$data['update_time']}','{$data['uid']}','{$data['type']}')";
  260. $result = $this->getDbEntity()->insert_sql($sql);
  261. return $result;
  262. }
  263. //查询某一个邮件模板
  264. public function select_one_template($id){
  265. $sql = "select * from ly_email_template where id='$id' ";
  266. $result = $this->getDbEntity()->query($sql);
  267. return $result[0];
  268. }
  269. //修改邮件模板
  270. public function update_email_msg($data,$id,$uid){
  271. $sql = "update ly_email_template set msg_title='{$data['msg_title']}',msg_content='{$data['msg_content']}',
  272. status = '{$data['status']}',update_time = '{$data['update_time']}'
  273. where id='$id' and uid='$uid'";
  274. $result = $this->getDbEntity()->execute_sql($sql);
  275. return $result;
  276. }
  277. //禁用邮件模板
  278. public function deleteEmailTemplate($status,$id,$uid){
  279. $sql = "update ly_email_template set status='{$status}'
  280. where id='$id' and uid='$uid'";
  281. $result = $this->getDbEntity()->execute_sql($sql);
  282. return $result;
  283. }
  284. //查询所有用户分组
  285. public function select_user_group($where){
  286. $sql = "select * from ly_user_group $where order by id desc";
  287. $result = $this->getDbEntity()->query($sql);
  288. return $result;
  289. }
  290. //添加用户分组
  291. public function add_user_group($data){
  292. $sql = "insert into ly_user_group(uid,`name`,add_time,update_time)
  293. values('{$data['uid']}','{$data['name']}','{$data['add_time']}','{$data['update_time']}')";
  294. $result = $this->getDbEntity()->insert_sql($sql);
  295. return $result;
  296. }
  297. //查询某个用户分组
  298. public function select_one_user_group($id,$uid){
  299. $sql = "select * from ly_user_group where id='$id' and uid='$uid'";
  300. $result = $this->getDbEntity()->query($sql);
  301. return $result[0];
  302. }
  303. //查询多个用户分组
  304. public function select_batch_user_group($in_array,$uid){
  305. $sql = "select * from ly_user_group where id in ($in_array) and uid='$uid'";
  306. $result = $this->getDbEntity()->query($sql);
  307. return $result;
  308. }
  309. //判断客户分组
  310. public function select_group_byName($group_name,$uid){
  311. $sql = "select * from ly_user_group where name='$group_name' and uid='$uid'";
  312. $result = $this->getDbEntity()->query($sql);
  313. return $result[0];
  314. }
  315. //修改用户分组
  316. public function update_user_group($data, $id,$uid){
  317. $sql = "update ly_user_group set
  318. `name` = '{$data['name']}',
  319. update_time = '{$data['update_time']}'
  320. where id='{$id}' and uid='$uid'";
  321. $result = $this->getDbEntity()->execute_sql($sql);
  322. return $result;
  323. }
  324. //查询分组用户的数量
  325. public function select_usergroup_count($where){
  326. $sql = "select count(*) as count from ly_customer $where";
  327. $result = $this->getDbEntity()->query($sql);
  328. return $result[0];
  329. }
  330. //查询用户分组里的所有用户
  331. public function select_usergroup_info($where,$limit){
  332. if(!empty($limit)){
  333. $sql = "select * from ly_customer $where order by add_time desc limit $limit";
  334. }else{
  335. $sql = "select * from ly_customer $where order by add_time desc";
  336. }
  337. $result = $this->getDbEntity()->query($sql);
  338. return $result;
  339. }
  340. //删除用户分组
  341. public function deleteUserGroupMsg($where){
  342. $sql = " delete from ly_user_group where $where";
  343. $result = $this->getDbEntity()->query($sql);
  344. return $result;
  345. }
  346. //查询退信用户是否存在
  347. public function select_ndr_user($where,$email){
  348. $sql = " select email from ly_ndr_user where $where and email='$email'";
  349. $result = $this->getDbEntity()->query($sql);
  350. return $result;
  351. }
  352. //查询所有退信用户
  353. public function selectAllNdrUser($uid){
  354. $sql = "select email from ly_ndr_user where uid=$uid";
  355. $result = $this->getDbEntity()->query($sql);
  356. return $result;
  357. }
  358. //插入退信用户
  359. public function insert_ndr_user($data){
  360. $sql = "insert into ly_ndr_user(uid,email)
  361. values('{$data['uid']}','{$data['email']}')";
  362. $result = $this->getDbEntity()->insert_sql($sql);
  363. return $result;
  364. }
  365. //查询临时表数据
  366. public function select_tmp_data(){
  367. $sql = " select id from ly_im_data_tmp ";
  368. $result = $this->getDbEntity()->query($sql);
  369. return $result;
  370. }
  371. //end
  372. }