ACsmadmin.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace addons\csmadmin\library;
  3. use addons\csmadmin\library\service\AdminService;
  4. use addons\csmadmin\library\service\CsmAdminService;
  5. abstract class ACsmadmin
  6. {
  7. protected static function getAdminsByDepartId($depart_id){
  8. $dao = new \app\admin\model\csmadmin\Depart2user();
  9. $ll = $dao->where('csmadmin_depart_id','=',$depart_id)->where('status','=','normal')->select();
  10. $admin_ids = [];
  11. foreach($ll as $item){
  12. $admin_ids[] = $item->faadmin_id;
  13. }
  14. return $admin_ids;
  15. }
  16. protected static function getMsgtplchannels($tplrow_id)
  17. {
  18. $tplchanneldao = new \app\admin\model\csmadmin\Msgtplchannel();
  19. return $tplchanneldao->where("csmadmin_msgtpl_id", "=", $tplrow_id)
  20. ->where('status', '=', 'normal')
  21. ->select();
  22. }
  23. protected static function getMsgtpl($msgtplcode)
  24. {
  25. $tpldao = new \app\admin\model\csmadmin\Msgtpl();
  26. return $tpldao->where('code', '=', $msgtplcode)
  27. ->where('status', '=', 'normal')
  28. ->find();
  29. }
  30. protected static function getAdminById($admin_id)
  31. {
  32. $service = new AdminService();
  33. return $service->getRowById($admin_id);
  34. }
  35. protected static function getCsmAdminById($admin_id)
  36. {
  37. $csmservice = new CsmAdminService();
  38. return $csmservice->getRowByAdminId($admin_id);
  39. }
  40. // 记录渠道日志
  41. protected static function _insertChannellog($logdao, $tplrow, $channelrow, $msgtitle,$msgcontent)
  42. {
  43. $logdao->create([
  44. 'csmadmin_msgtpl_id' => $tplrow->id,
  45. 'csmadmin_msgtplchannel_id' => $channelrow->id,
  46. 'channel' => $channelrow->channel,
  47. 'msgtitle' => $msgtitle,
  48. 'msgcontent' => $msgcontent,
  49. 'createtime' => time()
  50. ]);
  51. return $logdao->getLastInsID();
  52. }
  53. // 记录渠道日志
  54. protected static function _updateChannellogResult($logdao, $logid, $errmsg)
  55. {
  56. $logdao->where('id', '=', $logid)->update([
  57. 'issuccess' => ($errmsg == null || $errmsg == '') ? "Y" : "N",
  58. 'errormsg' => $errmsg
  59. ]);
  60. }
  61. protected static function error($msg)
  62. {
  63. return array(
  64. 'code' => 1,
  65. 'data' => [],
  66. 'msg' => $msg
  67. );
  68. }
  69. protected static function success($data=[])
  70. {
  71. return array(
  72. 'code' => 0,
  73. 'data' => $data,
  74. 'msg' => ''
  75. );
  76. }
  77. protected static function _evalstring($template, $data)
  78. {
  79. foreach ($data as $k => $v) {
  80. $$k = $v;
  81. }
  82. return eval('return "' . $template . '";');
  83. }
  84. }