adminAction.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809
  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' and active=1 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, is_block,is_send) values" . $values;
  79. $result = $this->getDbEntity()->insert_sql($sql);
  80. return $result;
  81. }
  82. //导入客户,批量添加客户信息
  83. public function addpl_customer($data){
  84. $sql = "replace into ly_customer(email,uname,country,city,tel,uid,add_time,group_name) values ";
  85. foreach ($data as $k => $v) {
  86. $sql .= "(\"{$v['email']}\",\"{$v['uname']}\",\"{$v['country']}\",\"{$v['city']}\",\"{$v['tel']}\",\"{$v['uid']}\",\"{$v['add_time']}\",\"{$v['group_name']}\"),";
  87. }
  88. $sql = substr($sql,0,-1);
  89. $sql .= ";";
  90. $result = $this->getDbEntity()->insert_sql($sql);
  91. return $result;
  92. }
  93. //导入黑名单,添加黑名单信息
  94. public function add_blacklist($data){
  95. $sql = "insert into ly_blacklist(email,add_time) values
  96. ('{$data['email']}','{$data['add_time']}')";
  97. $result = $this->getDbEntity()->insert_sql($sql);
  98. return $result;
  99. }
  100. public function importBlacklist($values){
  101. $sql = "replace into ly_blacklist(email, add_time) values" . $values;
  102. $result = $this->getDbEntity()->insert_sql($sql);
  103. return $result;
  104. }
  105. public function selectCustomerCount($where){
  106. $sql = "select count(*) as count from ly_customer $where ";
  107. $result = $this->getDbEntity()->query($sql);
  108. return $result[0]['count'];
  109. }
  110. public function selectSmsCustomerCount($where){
  111. $sql = "select count(*) as count from ly_sms_customer $where ";
  112. $result = $this->getDbEntity()->query($sql);
  113. return $result[0]['count'];
  114. }
  115. public function selectBlacklistCount($where){
  116. $sql = "select count(*) as count from ly_blacklist $where ";
  117. $result = $this->getDbEntity()->query($sql);
  118. return $result[0]['count'];
  119. }
  120. //查询所有客户
  121. public function selesctCustomer($where,$limit){
  122. if(!empty($limit)){
  123. $sql = "select * from ly_customer $where order by id desc limit $limit ";
  124. }else{
  125. $sql = "select * from ly_customer $where order by id desc ";
  126. }
  127. $result = $this->getDbEntity()->query($sql);
  128. return $result;
  129. }
  130. public function selesctSmsCustomer($where,$limit=0){
  131. if(!empty($limit)){
  132. $sql = "select * from ly_sms_customer $where order by id desc limit $limit ";
  133. }else{
  134. $sql = "select * from ly_sms_customer $where order by id desc ";
  135. }
  136. $result = $this->getDbEntity()->query($sql);
  137. return $result;
  138. }
  139. public function selectSmsBlackList() {
  140. $sql = "select tel from ly_sms_customer where is_block=1 order by id desc ";
  141. $result = $this->getDbEntity()->query($sql);
  142. return $result;
  143. }
  144. public function getAllSmsBlacklist() {
  145. $sql = "select uname, tel, country, group_name from ly_sms_customer where is_block=1 order by id desc ";
  146. $result = $this->getDbEntity()->query($sql);
  147. return $result;
  148. }
  149. //查询UID下所有客户Email
  150. public function selesctCustomerByUid($uid){
  151. $sql = "select email from ly_customer where 1=1 and uid = $uid ";
  152. $result = $this->getDbEntity()->query($sql);
  153. return $result;
  154. }
  155. //查询所有黑名单
  156. public function selesctBlacklist($where = '', $limit = 100){
  157. if(!empty($limit)){
  158. $sql = "select * from ly_blacklist $where order by id desc limit $limit ";
  159. }else{
  160. $sql = "select * from ly_blacklist $where order by id desc ";
  161. }
  162. $result = $this->getDbEntity()->query($sql);
  163. return $result;
  164. }
  165. public function selectAllBlack(){
  166. $sql = "select email from ly_blacklist";
  167. $result = $this->getDbEntity()->query($sql);
  168. return $result;
  169. }
  170. //查询客户信息
  171. public function selectOneCustomer($id){
  172. $sql = "select * from ly_customer where id='$id' ";
  173. $result = $this->getDbEntity()->query($sql);
  174. return $result[0];
  175. }
  176. //根据手机号查询客户信息
  177. public function selectOneCustomerBymobile($id){
  178. $sql = "select * from ly_sms_customer where tel='$id' ";
  179. $result = $this->getDbEntity()->query($sql);
  180. return $result[0];
  181. }
  182. public function selectOneSmsCustomer($id){
  183. $sql = "select * from ly_sms_customer where id='$id' ";
  184. $result = $this->getDbEntity()->query($sql);
  185. return $result[0];
  186. }
  187. //查询黑名单信息
  188. public function selectOneBlack($id){
  189. $sql = "select * from ly_blacklist where id='$id' ";
  190. $result = $this->getDbEntity()->query($sql);
  191. return $result[0];
  192. }
  193. //根据邮箱查询客户信息
  194. public function selectCustomerByEmail($email,$uid){
  195. $sql = "select * from ly_customer where email='$email' and uid='$uid' ";
  196. $result = $this->getDbEntity()->query($sql);
  197. return $result[0];
  198. }
  199. public function selectCustomerByTel($tel, $uid){
  200. $sql = "select * from ly_sms_customer where tel='$tel' and uid='$uid' ";
  201. $result = $this->getDbEntity()->query($sql);
  202. return $result[0];
  203. }
  204. //根据邮箱查询H黑名单信息
  205. public function selectBlackByEmail($email){
  206. $sql = "select * from ly_blacklist where email='$email' ";
  207. $result = $this->getDbEntity()->query($sql);
  208. return $result[0];
  209. }
  210. //编辑客户信息
  211. public function updateCustomer($data,$id){
  212. $sql = "update ly_customer set email='{$data['email']}',uname='{$data['uname']}',group_name='{$data['group_name']}',
  213. country = '{$data['country']}',city = '{$data['city']}',tel='{$data['tel']}'
  214. where id='$id'";
  215. $result = $this->getDbEntity()->execute_sql($sql);
  216. return $result;
  217. }
  218. public function updateSmsCustomerBlcak($data){
  219. $sql = "update ly_sms_customer set is_block=1
  220. where id={$data['id']}";
  221. $result = $this->getDbEntity()->execute_sql($sql);
  222. return $result;
  223. }
  224. public function updateSmsCustomer($data,$id){
  225. $sql = "update ly_sms_customer set uname='{$data['uname']}',group_name='{$data['group_name']}',
  226. country = '{$data['country']}',tel='{$data['tel']}'
  227. where id='$id'";
  228. $result = $this->getDbEntity()->execute_sql($sql);
  229. return $result;
  230. }
  231. //编辑黑名单信息
  232. public function updateBlack($data,$id){
  233. $sql = "update ly_blacklist set email='{$data['email']}'
  234. where id='$id'";
  235. $result = $this->getDbEntity()->execute_sql($sql);
  236. return $result;
  237. }
  238. //编辑客户信息
  239. public function updateCustomerByEmail($data){
  240. $sql = "update ly_customer set uname='{$data['uname']}',group_name='{$data['group_name']}',
  241. country = '{$data['country']}',city = '{$data['city']}',tel='{$data['tel']}'
  242. where uid='{$data['uid']}' and email='{$data['email']}'";
  243. $result = $this->getDbEntity()->execute_sql($sql);
  244. return $result;
  245. }
  246. //批量更新客户用户组信息
  247. public function updateCustomerGroupByEmail($data){
  248. $sql = "insert into ly_im_data_tmp (sql_content) values ";
  249. foreach ($data as $k => $v) {
  250. $sql_content['tabname'] = "ly_customer";
  251. $sql_content['exc'] = " update";
  252. $sql_content['data'] = $v;
  253. $sql .= "('".addslashes(serialize($sql_content))."'),";
  254. }
  255. $sql = substr($sql,0,-1);
  256. $sql .= ";";
  257. $result = $this->getDbEntity()->execute_sql($sql);
  258. return $result;
  259. }
  260. //删除客户信息
  261. public function deleteCustomer($id,$uid){
  262. $sql = "delete from ly_customer where id='$id' and uid='$uid' ";
  263. $result = $this->getDbEntity()->query($sql);
  264. return $result;
  265. }
  266. public function deleteSmsCustomer($id, $uid){
  267. $sql = "delete from ly_sms_customer where id='$id' and uid='$uid' ";
  268. $result = $this->getDbEntity()->query($sql);
  269. return $result;
  270. }
  271. public function deleteSmsCustomerByExcel($telsStr, $uid){
  272. $sql = "delete from ly_sms_customer where tel in ($telsStr) and uid='$uid' ";
  273. $result = $this->getDbEntity()->query($sql);
  274. return $result;
  275. }
  276. public function deleteSmsCustomerByTel($telsStr){
  277. $sql = "delete from ly_sms_customer where tel in ($telsStr) ";
  278. $result = $this->getDbEntity()->query($sql);
  279. return $result;
  280. }
  281. //删除黑名单
  282. public function deleteBlack($id){
  283. $sql = "delete from ly_blacklist where id='$id' ";
  284. $result = $this->getDbEntity()->query($sql);
  285. return $result;
  286. }
  287. //按客户分组删除客户信息
  288. public function deleteCustomerByGroup($group_name,$uid){
  289. $sql = "delete from ly_customer where group_name='$group_name' and uid='$uid' ";
  290. $result = $this->getDbEntity()->query($sql);
  291. return $result;
  292. }
  293. public function deleteSmsCustomerByGroup($group_name, $uid){
  294. $sql = "delete from ly_sms_customer where group_name='$group_name' and uid='$uid' ";
  295. $result = $this->getDbEntity()->query($sql);
  296. return $result;
  297. }
  298. //删除多个分组的客户信息
  299. public function deleteBatchCus($group_name,$uid){
  300. $sql = "delete from ly_customer where group_name in ($group_name) and uid='$uid' ";
  301. $result = $this->getDbEntity()->query($sql);
  302. return $result;
  303. }
  304. //批量删除客户信息
  305. public function deleteBatchCustomer($id_array,$uid){
  306. $sql = "delete from ly_customer where id in ($id_array) and uid='$uid' ";
  307. $result = $this->getDbEntity()->query($sql);
  308. return $result;
  309. }
  310. public function deleteBatchSmsCustomer($id_array, $uid){
  311. $sql = "delete from ly_sms_customer where id in ($id_array) and uid='$uid' ";
  312. $result = $this->getDbEntity()->query($sql);
  313. return $result;
  314. }
  315. //批量删除黑名单
  316. public function deleteBatchBlack($id_array){
  317. $sql = "delete from ly_blacklist where id in ($id_array) ";
  318. $result = $this->getDbEntity()->query($sql);
  319. return $result;
  320. }
  321. //批量删除用户分组
  322. public function deleteBatchUserGroup($id_array,$uid){
  323. $sql = "delete from ly_user_group where id in ($id_array) and uid='$uid' ";
  324. $result = $this->getDbEntity()->query($sql);
  325. return $result;
  326. }
  327. public function deleteBatchSmsUserGroup($id_array,$uid){
  328. $sql = "delete from ly_sms_user_group where id in ($id_array) and uid='$uid' ";
  329. $result = $this->getDbEntity()->query($sql);
  330. return $result;
  331. }
  332. //普通发送插入日志表 普通邮件发送日志表
  333. public function inserEmail1Log($data){
  334. $sql = "insert into ly_send_email1_log(to_user,subject,content,replay_to,`time`,message,uid) values
  335. ('{$data['to']}','{$data['subject']}','{$data['html']}','{$data['replyto']}','{$data['time']}','{$data['message']}','{$data['uid']}')";
  336. $result = $this->getDbEntity()->insert_sql($sql);
  337. return $result;
  338. }
  339. public function deleteBatchCustomerByEmail($id_array,$uid){
  340. $sql = "delete from ly_customer where email in ($id_array) and uid='$uid' ";
  341. $result = $this->getDbEntity()->query($sql);
  342. return $result;
  343. }
  344. //邮件模板列表
  345. public function select_msg_list($where,$limit){
  346. if(!empty($limit)){
  347. $sql = "select * from ly_email_template $where order by status asc,id desc limit $limit";
  348. }else{
  349. $sql = "select * from ly_email_template $where order by status asc,id desc";
  350. }
  351. $result = $this->getDbEntity()->query($sql);
  352. return $result;
  353. }
  354. //短信模板列表
  355. public function select_smstm_list($where,$limit=0){
  356. if(!empty($limit)){
  357. $sql = "select * from ly_sms_template $where order by status asc,id desc limit $limit";
  358. }else{
  359. $sql = "select * from ly_sms_template $where order by status asc,id desc";
  360. }
  361. $result = $this->getDbEntity()->query($sql);
  362. return $result;
  363. }
  364. //短信发送列表
  365. public function select_smslog_list($where,$limit=0){
  366. if(!empty($limit)){
  367. $sql = "select * from ly_send_sms_log_count $where order by sendtime desc,log_id desc limit $limit";
  368. }else{
  369. $sql = "select * from ly_send_sms_log_count $where order by sendtime desc,log_id desc ";
  370. }
  371. $result = $this->getDbEntity()->query($sql);
  372. return $result;
  373. }
  374. //短信发送列表
  375. public function select_smslog_list_query($where,$limit=0){
  376. if(!empty($limit)){
  377. $sql = "select a.* ,b.params_json from ly_send_sms_log_count as a inner join ly_sms_data_tmp_new as b on a.log_id=b.fid $where order by a.sendtime desc,a.log_id desc limit $limit";
  378. }else{
  379. $sql = "select a.* from ly_send_sms_log_count as a inner join ly_sms_data_tmp_new as b on a.log_id=b.fid $where order by a.sendtime desc,a.log_id desc ";
  380. }
  381. $result = $this->getDbEntity()->query($sql);
  382. return $result;
  383. }
  384. //查询邮件模板数量
  385. public function select_msg_count($where){
  386. $sql = "select count(*) as count from ly_email_template $where ";
  387. $result = $this->getDbEntity()->query($sql);
  388. return $result[0]['count'];
  389. }
  390. //查询短信模板数量
  391. public function select_smstm_count($where){
  392. $sql = "select count(*) as count from ly_sms_template $where ";
  393. $result = $this->getDbEntity()->query($sql);
  394. return $result[0]['count'];
  395. }
  396. //查询短信发送数量
  397. public function select_smslog_count($where){
  398. $sql = "select count(*) as count from ly_send_sms_log_count $where ";
  399. $result = $this->getDbEntity()->query($sql);
  400. return $result[0]['count'];
  401. }
  402. //查询短信发送数量
  403. public function select_smslog_count_query($where){
  404. $sql = "select count(*) as count from ly_send_sms_log_count as a inner join ly_sms_data_tmp_new as b on a.log_id=b.fid $where ";
  405. $result = $this->getDbEntity()->query($sql);
  406. return $result[0]['count'];
  407. }
  408. //删除短信发送
  409. public function delete_smslog($id,$totals){
  410. $sql1 = "DELETE FROM `ly_sms_data_tmp_new` WHERE `fid`='{$id}' ";
  411. $this->getDbEntity()->query($sql1);
  412. $sql2 = "update ly_send_sms_log_count set status=1,nosend='{$totals}' WHERE `log_id`='{$id}'";
  413. $this->getDbEntity()->query($sql2);
  414. return true;
  415. }
  416. //添加邮件模板
  417. public function add_email_msg($data){
  418. $sql = "insert into ly_email_template(msg_title,msg_content,status,add_time,`update_time`,uid,`type`) values
  419. ('{$data['msg_title']}','{$data['msg_content']}','{$data['status']}','{$data['add_time']}','{$data['update_time']}','{$data['uid']}','{$data['type']}')";
  420. $result = $this->getDbEntity()->insert_sql($sql);
  421. return $result;
  422. }
  423. //添加短信模板
  424. public function add_smstm_msg($data){
  425. $sql = "insert into ly_sms_template(msg_title,msg_content,status,add_time,`update_time`,uid,`type`) values
  426. ('{$data['msg_title']}','{$data['msg_content']}','{$data['status']}','{$data['add_time']}','{$data['update_time']}','{$data['uid']}','{$data['type']}')";
  427. $result = $this->getDbEntity()->insert_sql($sql);
  428. return $result;
  429. }
  430. //查询某一个邮件模板
  431. public function select_one_template($id){
  432. $sql = "select * from ly_email_template where id='$id' ";
  433. $result = $this->getDbEntity()->query($sql);
  434. return $result[0];
  435. }
  436. //查询某一个短信模板
  437. public function select_onesms_template($id){
  438. $sql = "select * from ly_sms_template where id='$id' ";
  439. $result = $this->getDbEntity()->query($sql);
  440. return $result[0];
  441. }
  442. //修改邮件模板
  443. public function update_email_msg($data,$id,$uid){
  444. $sql = "update ly_email_template set msg_title='{$data['msg_title']}',msg_content='{$data['msg_content']}',
  445. status = '{$data['status']}',update_time = '{$data['update_time']}'
  446. where id='$id' and uid='$uid'";
  447. $result = $this->getDbEntity()->execute_sql($sql);
  448. return $result;
  449. }
  450. //修改短信模板
  451. public function update_smstm_msg($data,$id,$uid){
  452. $sql = "update ly_sms_template set msg_title='{$data['msg_title']}',msg_content='{$data['msg_content']}',
  453. status = '{$data['status']}',update_time = '{$data['update_time']}'
  454. where id='$id' and uid='$uid'";
  455. $result = $this->getDbEntity()->execute_sql($sql);
  456. return $result;
  457. }
  458. //禁用邮件模板
  459. public function deleteEmailTemplate($status,$id,$uid){
  460. $sql = "update ly_email_template set status='{$status}'
  461. where id='$id' and uid='$uid'";
  462. $result = $this->getDbEntity()->execute_sql($sql);
  463. return $result;
  464. }
  465. //禁用短信模板
  466. public function deleteSmsTemplate($status,$id,$uid){
  467. $sql = "update ly_sms_template set status='{$status}'
  468. where id='$id' and uid='$uid'";
  469. $result = $this->getDbEntity()->execute_sql($sql);
  470. return $result;
  471. }
  472. //查询所有用户分组
  473. public function select_user_group($where){
  474. $sql = "select * from ly_user_group $where order by position desc, id desc";
  475. $result = $this->getDbEntity()->query($sql);
  476. return $result;
  477. }
  478. //查询所有用户分组
  479. public function select_sms_user_group($where){
  480. $sql = "select * from ly_sms_user_group $where order by position desc, id desc";
  481. $result = $this->getDbEntity()->query($sql);
  482. return $result;
  483. }
  484. //添加用户分组
  485. public function add_user_group($data){
  486. $sql = "insert into ly_user_group(uid,`name`,add_time,update_time)
  487. values('{$data['uid']}','{$data['name']}','{$data['add_time']}','{$data['update_time']}')";
  488. $result = $this->getDbEntity()->insert_sql($sql);
  489. return $result;
  490. }
  491. public function add_sms_user_group($data){
  492. $sql = "insert into ly_sms_user_group(uid,`name`)
  493. values('{$data['uid']}','{$data['name']}')";
  494. $result = $this->getDbEntity()->insert_sql($sql);
  495. return $result;
  496. }
  497. //查询某个用户分组
  498. public function select_one_user_group($id,$uid){
  499. $sql = "select * from ly_user_group where id='$id' and uid='$uid'";
  500. $result = $this->getDbEntity()->query($sql);
  501. return $result[0];
  502. }
  503. //查询多个用户分组
  504. public function select_batch_user_group($in_array,$uid){
  505. $sql = "select * from ly_user_group where id in ($in_array) and uid='$uid'";
  506. $result = $this->getDbEntity()->query($sql);
  507. return $result;
  508. }
  509. public function select_batch_sms_group($in_array, $uid){
  510. $sql = "select * from ly_sms_user_group where id in ($in_array) and uid='$uid'";
  511. $result = $this->getDbEntity()->query($sql);
  512. return $result;
  513. }
  514. //判断客户分组
  515. public function select_group_byName($group_name,$uid){
  516. $sql = "select * from ly_user_group where name='$group_name' and uid='$uid'";
  517. $result = $this->getDbEntity()->query($sql);
  518. return $result[0];
  519. }
  520. public function select_usergroup_byName($group_name,$uid){
  521. $sql = "select * from ly_sms_user_group where name='$group_name' and uid='$uid'";
  522. $result = $this->getDbEntity()->query($sql);
  523. return $result[0];
  524. }
  525. public function select_usergroup_byId($id, $uid){
  526. $sql = "select * from ly_sms_user_group where id='$id' and uid='$uid'";
  527. $result = $this->getDbEntity()->query($sql);
  528. return $result[0];
  529. }
  530. //修改用户分组
  531. public function update_user_group($data, $id,$uid){
  532. $sql = "update ly_user_group set
  533. `name` = '{$data['name']}',
  534. `position` = '{$data['position']}',
  535. update_time = '{$data['update_time']}'
  536. where id='{$id}' and uid='$uid'";
  537. $result = $this->getDbEntity()->execute_sql($sql);
  538. return $result;
  539. }
  540. public function update_sms_user_group($data, $id, $uid){
  541. $sql = "update ly_sms_user_group set
  542. `name` = '{$data['name']}',
  543. `position` = '{$data['position']}'
  544. where id='{$id}' and uid='$uid'";
  545. $result = $this->getDbEntity()->execute_sql($sql);
  546. return $result;
  547. }
  548. //查询分组用户的数量
  549. public function select_usergroup_count($where){
  550. $sql = "select count(*) as count from ly_customer $where";
  551. $result = $this->getDbEntity()->query($sql);
  552. return $result[0];
  553. }
  554. //查询用户分组里的所有用户
  555. public function select_usergroup_info($where,$limit){
  556. if(!empty($limit)){
  557. $sql = "select * from ly_customer $where order by add_time desc limit $limit";
  558. }else{
  559. $sql = "select * from ly_customer $where order by add_time desc";
  560. }
  561. $result = $this->getDbEntity()->query($sql);
  562. return $result;
  563. }
  564. //删除用户分组
  565. public function deleteUserGroupMsg($where){
  566. $sql = " delete from ly_user_group where $where";
  567. $result = $this->getDbEntity()->query($sql);
  568. return $result;
  569. }
  570. public function deleteSmsUserGroupMsg($where){
  571. $sql = " delete from ly_sms_user_group where $where";
  572. $result = $this->getDbEntity()->query($sql);
  573. return $result;
  574. }
  575. //查询退信用户是否存在
  576. public function select_ndr_user($where,$email){
  577. $sql = " select email from ly_ndr_user where $where and email='$email'";
  578. $result = $this->getDbEntity()->query($sql);
  579. return $result;
  580. }
  581. //查询所有退信用户
  582. public function selectAllNdrUser($uid){
  583. $sql = "select email from ly_ndr_user where uid=$uid";
  584. $result = $this->getDbEntity()->query($sql);
  585. return $result;
  586. }
  587. //插入退信用户
  588. public function insert_ndr_user($data){
  589. $sql = "insert into ly_ndr_user(uid,email)
  590. values('{$data['uid']}','{$data['email']}')";
  591. $result = $this->getDbEntity()->insert_sql($sql);
  592. return $result;
  593. }
  594. //查询临时表数据
  595. public function select_tmp_data(){
  596. $sql = " select id from ly_im_data_tmp ";
  597. $result = $this->getDbEntity()->query($sql);
  598. return $result;
  599. }
  600. //插入待发送邮件参数数据
  601. public function add_email_data_queue($data, $datetime){
  602. $sql = 'INSERT INTO `ly_email_data_tmp` (`params_json`, `schedule_time`) VALUES ';
  603. $params_json = '';
  604. foreach($data as $value){
  605. $params_json = serialize($value);
  606. $sql .= "('{$params_json}', '{$datetime}'),";
  607. }
  608. $sql = trim($sql, ',').';';
  609. $result = $this->getDbEntity()->insert_sql($sql);
  610. return $result;
  611. }
  612. //插入待发送短信总记录
  613. public function add_sms_data_logs($uid,$uname,$group_name,$content,$count,$send_type,$showtime,$datetime,$apid,$apsecret){
  614. $times=date('Y-m-d H:i:d');
  615. $sql = 'INSERT INTO `ly_send_sms_log_count` (`uid`,`uname`,`group_name`,`template_body`,`count`,`send_type`,`sendtime`,`showtime`,`apid`,`apsecret`,`addtime`) VALUES ';
  616. $sql .= "('{$uid}','{$uname}','{$group_name}','{$content}','{$count}','{$send_type}','{$datetime}','{$showtime}','{$apid}','{$apsecret}','{$times}'),";
  617. $sql = trim($sql, ',').';';
  618. $result = $this->getDbEntity()->insert_sql($sql);
  619. return $result;
  620. }
  621. //插入待发送短信参数数据
  622. public function add_sms_data_queue($data,$showtime,$datetime){
  623. $sql = 'INSERT INTO `ly_sms_data_tmp` (`params_json`,`sendtime`,`showtime`) VALUES ';
  624. foreach($data as $value){
  625. $params_json = serialize($value);
  626. $sql .= "('{$params_json}','{$datetime}','{$showtime}'),";
  627. }
  628. $sql = trim($sql, ',').';';
  629. $result = $this->getDbEntity()->insert_sql($sql);
  630. return $result;
  631. }
  632. //插入待发送短信参数数据--牛信云
  633. public function add_sms_data_queue_new($data,$showtime,$datetime,$fid,$uid){
  634. $sql = 'INSERT INTO `ly_sms_data_tmp_new` (`params_json`,`sendtime`,`showtime`,`fid`,`uid`) VALUES ';
  635. foreach($data as $value){
  636. $params_json = serialize($value);
  637. $sql .= "('{$params_json}','{$datetime}','{$showtime}','{$fid}','{$uid}'),";
  638. }
  639. $sql = trim($sql, ',').';';
  640. $result = $this->getDbEntity()->insert_sql($sql);
  641. return $result;
  642. }
  643. //查询代发邮件数量
  644. public function selectEmailTmpData(){
  645. $sql = 'SELECT COUNT(`id`) AS `ct` FROM `ly_email_data_tmp`;';
  646. $result = $this->getDbEntity()->query($sql);
  647. return $result;
  648. }
  649. //查询待发短信数量
  650. public function selectSmsTmpData(){
  651. $sql = 'SELECT COUNT(`id`) AS `ct` FROM `ly_sms_data_tmp`;';
  652. $result = $this->getDbEntity()->query($sql);
  653. return $result;
  654. }
  655. //查询美加州区号
  656. public function selectCityCode(){
  657. $sql = "select code from ly_country_code ";
  658. $result = $this->getDbEntity()->query($sql);
  659. return $result;
  660. }
  661. //更改美加州区号用户状态
  662. public function upCodeSmsCustomer($is_send,$id,$tel){
  663. $sql = "update ly_sms_customer set is_send='{$is_send}',tel='{$tel}' where id='{$id}'";
  664. $result = $this->getDbEntity()->execute_sql($sql);
  665. return $result;
  666. }
  667. //添加短信回执记录
  668. public function addDrLog($data){
  669. $times=date('Y-m-d H:i:s');
  670. $sql = "insert into ly_send_sms_log_dr(mobile,dr_id,group_dr_id,status,result,addtime) values
  671. ('{$data['phone']}','{$data['messageid']}','{$data['group_dr_id']}','{$data['status']}','{$data['result']}','{$times}')";
  672. $result = $this->getDbEntity()->execute_sql($sql);
  673. return $result;
  674. }
  675. //根据$messageid 查询牛信云发送日志
  676. public function select_smslog_new_query($where){
  677. $sql = "select * from ly_send_sms_log_new $where LIMIT 1 ";
  678. $result = $this->getDbEntity()->query($sql);
  679. return $result;
  680. }
  681. //$uid 查询牛信云待发送日志
  682. public function select_sms_data_tmp_new($where){
  683. $sql = "select * from ly_sms_data_tmp_new $where ";
  684. $result = $this->getDbEntity()->query($sql);
  685. return $result;
  686. }
  687. //失败过高删除短信发送
  688. public function delete_smslog_dr($uid,$fid,$count){
  689. $sql1 = "DELETE FROM `ly_sms_data_tmp_new` WHERE `uid`='{$uid}' ";
  690. $this->getDbEntity()->query($sql1);
  691. $sql2 = "update ly_send_sms_log_count set status=1,nosend='{$count}' WHERE `log_id`='{$fid}'";
  692. $this->getDbEntity()->query($sql2);
  693. return true;
  694. }
  695. //end
  696. }