adminAction.php 31 KB

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