12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace addons\csmadmin\library;
- use addons\csmadmin\library\service\AdminService;
- use addons\csmadmin\library\service\CsmAdminService;
- abstract class ACsmadmin
- {
- protected static function getAdminsByDepartId($depart_id){
- $dao = new \app\admin\model\csmadmin\Depart2user();
- $ll = $dao->where('csmadmin_depart_id','=',$depart_id)->where('status','=','normal')->select();
- $admin_ids = [];
- foreach($ll as $item){
- $admin_ids[] = $item->faadmin_id;
- }
- return $admin_ids;
- }
- protected static function getMsgtplchannels($tplrow_id)
- {
- $tplchanneldao = new \app\admin\model\csmadmin\Msgtplchannel();
- return $tplchanneldao->where("csmadmin_msgtpl_id", "=", $tplrow_id)
- ->where('status', '=', 'normal')
- ->select();
- }
- protected static function getMsgtpl($msgtplcode)
- {
- $tpldao = new \app\admin\model\csmadmin\Msgtpl();
- return $tpldao->where('code', '=', $msgtplcode)
- ->where('status', '=', 'normal')
- ->find();
- }
- protected static function getAdminById($admin_id)
- {
- $service = new AdminService();
- return $service->getRowById($admin_id);
- }
- protected static function getCsmAdminById($admin_id)
- {
- $csmservice = new CsmAdminService();
- return $csmservice->getRowByAdminId($admin_id);
- }
- // 记录渠道日志
- protected static function _insertChannellog($logdao, $tplrow, $channelrow, $msgtitle,$msgcontent)
- {
- $logdao->create([
- 'csmadmin_msgtpl_id' => $tplrow->id,
- 'csmadmin_msgtplchannel_id' => $channelrow->id,
- 'channel' => $channelrow->channel,
- 'msgtitle' => $msgtitle,
- 'msgcontent' => $msgcontent,
- 'createtime' => time()
- ]);
- return $logdao->getLastInsID();
- }
- // 记录渠道日志
- protected static function _updateChannellogResult($logdao, $logid, $errmsg)
- {
- $logdao->where('id', '=', $logid)->update([
- 'issuccess' => ($errmsg == null || $errmsg == '') ? "Y" : "N",
- 'errormsg' => $errmsg
- ]);
- }
- protected static function error($msg)
- {
- return array(
- 'code' => 1,
- 'data' => [],
- 'msg' => $msg
- );
- }
- protected static function success($data=[])
- {
- return array(
- 'code' => 0,
- 'data' => $data,
- 'msg' => ''
- );
- }
- protected static function _evalstring($template, $data)
- {
- foreach ($data as $k => $v) {
- $$k = $v;
- }
- return eval('return "' . $template . '";');
- }
- }
|