weixinAction.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. if(isempt($agentid)){
  23. $arr['appId'] = '';
  24. }else{
  25. $arr = m('weixinqy:signjssdk')->getsignsdk($url, $agentid);
  26. }
  27. }else{
  28. $arr = m('weixin:signjssdk')->getsignsdk($url);
  29. }
  30. }
  31. $this->showreturn($arr);
  32. }
  33. public function addlocationAction()
  34. {
  35. $fileid = (int)$this->post('fileid','0');
  36. $ispz = (int)$this->post('ispz','0');
  37. $imgpath = m('file')->getmou('filepath', $fileid);
  38. $now = $this->rock->now;
  39. $uid = $this->adminid;
  40. $comid = m('admin')->getcompanyid($uid);
  41. $type = (int)$this->post('type');
  42. if($type==1 && $ispz==1 && isempt($imgpath))return returnerror('请先拍照才能打卡');
  43. $arr['location_x'] = $this->post('location_x');
  44. $arr['location_y'] = $this->post('location_y');
  45. $arr['scale'] = (int)$this->post('scale');
  46. $arr['precision'] = (int)$this->post('precision');
  47. $arr['label'] = $this->getvals('label');
  48. $arr['explain'] = $this->getvals('sm');
  49. $arr['optdt'] = $now;
  50. $arr['uid'] = $uid;
  51. $arr['comid'] = $comid;
  52. $arr['imgpath'] = $imgpath;
  53. m('location')->insert($arr);
  54. if($type==1){
  55. $dkdt = $now;
  56. $ip = $this->rock->ip;
  57. $this->db->record('[Q]kqdkjl',array(
  58. 'dkdt' => $dkdt,
  59. 'uid' => $uid,
  60. 'optdt' => $now,
  61. 'imgpath' => $imgpath,
  62. 'address' => $arr['label'],
  63. 'comid' => $comid,
  64. 'lat'=> $arr['location_x'],
  65. 'lng'=> $arr['location_y'],
  66. 'accuracy'=> $arr['precision'],
  67. 'explain'=> $arr['explain'],
  68. 'ip' => $ip,
  69. 'type' => 2
  70. ));
  71. $dt = substr($dkdt, 0, 10);
  72. m('kaoqin')->kqanay($uid, $dt);
  73. }
  74. $this->showreturn(array('now'=>$now));
  75. }
  76. /**
  77. * 获取媒体文件
  78. */
  79. public function getmediaAction()
  80. {
  81. $media_id = $this->post('media_id');
  82. $type = $this->post('type');
  83. $barr = m('weixinqy:media')->downmedia($media_id, $type);
  84. if($barr['errcode']!=0)return returnerror($barr['msg']);
  85. return returnsuccess($barr);
  86. }
  87. }