weixinAction.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. //保存打卡记录等
  3. class weixinClassAction extends apiAction{
  4. /**
  5. * 获取jssdk签名
  6. */
  7. public function getsignAction()
  8. {
  9. $num = 'weixin_corpid';
  10. $isqywx = false;
  11. $appId = $this->option->getval($num);
  12. if(isempt($appId) || $this->rock->isqywx){
  13. $isqywx = true;
  14. $num = 'weixinqy_corpid';
  15. }
  16. if(isempt($this->option->getval($num))){
  17. $arr['appId'] = '';
  18. }else{
  19. $url = $this->getvals('url');
  20. if($isqywx){
  21. $agentid = $this->rock->post('agentid', $this->getsession('wxqyagentid'));
  22. $arr = m('weixinqy:signjssdk')->getsignsdk($url, $agentid);
  23. }else{
  24. $arr = m('weixin:signjssdk')->getsignsdk($url);
  25. }
  26. }
  27. $this->showreturn($arr);
  28. }
  29. public function addlocationAction()
  30. {
  31. $fileid = (int)$this->post('fileid','0');
  32. $ispz = (int)$this->post('ispz','0');
  33. $imgpath = m('file')->getmou('filepath', $fileid);
  34. $now = $this->rock->now;
  35. $uid = $this->adminid;
  36. $comid = m('admin')->getcompanyid($uid);
  37. $type = (int)$this->post('type');
  38. if($type==1 && $ispz==1 && isempt($imgpath))return returnerror('请先拍照才能打卡');
  39. $arr['location_x'] = $this->post('location_x');
  40. $arr['location_y'] = $this->post('location_y');
  41. $arr['scale'] = (int)$this->post('scale');
  42. $arr['precision'] = (int)$this->post('precision');
  43. $arr['label'] = $this->rock->iconvsql($this->getvals('label'));
  44. $arr['explain'] = $this->rock->xssrepstr($this->getvals('sm'));
  45. $arr['optdt'] = $now;
  46. $arr['uid'] = $uid;
  47. $arr['comid'] = $comid;
  48. $arr['imgpath'] = $imgpath;
  49. m('location')->insert($arr);
  50. if($type==1){
  51. $dkdt = $now;
  52. $ip = $this->rock->ip;
  53. $this->db->record('[Q]kqdkjl',array(
  54. 'dkdt' => $dkdt,
  55. 'uid' => $uid,
  56. 'optdt' => $now,
  57. 'imgpath' => $imgpath,
  58. 'address' => $arr['label'],
  59. 'comid' => $comid,
  60. 'lat'=> $arr['location_x'],
  61. 'lng'=> $arr['location_y'],
  62. 'accuracy'=> $arr['precision'],
  63. 'explain'=> $arr['explain'],
  64. 'ip' => $ip,
  65. 'type' => 2
  66. ));
  67. $dt = substr($dkdt, 0, 10);
  68. m('kaoqin')->kqanay($uid, $dt);
  69. }
  70. $this->showreturn(array('now'=>$now));
  71. }
  72. /**
  73. * 获取媒体文件
  74. */
  75. public function getmediaAction()
  76. {
  77. $media_id = $this->post('media_id');
  78. $type = $this->post('type');
  79. $barr = m('weixinqy:media')->downmedia($media_id, $type);
  80. if($barr['errcode']!=0)return returnerror($barr['msg']);
  81. return returnsuccess($barr);
  82. }
  83. }
粤ICP备19079148号