openmodhetongAction.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * 电子合同小程序用的接口
  4. */
  5. class openmodhetongClassAction extends openapiAction
  6. {
  7. /**
  8. * 首页返回数据
  9. */
  10. public function dataAction()
  11. {
  12. $mobile = $this->get('mobile');
  13. $xcytype = $this->get('xcytype');
  14. $openid = $this->get('openid');
  15. $nickName = $this->jm->base64decode($this->get('nickName'));
  16. $htdata = array();
  17. $db = m('wxxcyus');
  18. $uarr['mobile'] = $mobile;
  19. $uarr['xcytype'] = $xcytype;
  20. $uarr['openid'] = $openid;
  21. $uarr['nickName'] = $nickName;
  22. $uarr['province'] = $this->get('province');
  23. $uarr['city'] = $this->get('city');
  24. $uarr['gender'] = $this->get('gender');
  25. $uarr['dingyue'] = $this->get('dingyue');
  26. $uarr['avatarUrl'] = $this->jm->base64decode($this->get('avatarUrl'));
  27. $where = "`openid`='$openid'";
  28. if($db->rows($where)==0){
  29. $uarr['adddt'] = $this->now;
  30. $where='';
  31. }else{
  32. $uarr['optdt'] = $this->now;
  33. }
  34. $db->record($uarr, $where);
  35. $custid = '0'; //客户id
  36. $rows = m('customer')->getall("`mobile`='$mobile' and `status`=1",'id');
  37. foreach($rows as $k=>$rs)$custid.=','.$rs['id'].'';
  38. if($custid!='0'){
  39. $htrows = m('custract')->getall('custid in('.$custid.')','custid,custname,id,startdt,enddt,signdt,type,money,num','id desc');
  40. $dt = $this->rock->date;
  41. foreach($htrows as $k=>$rs){
  42. if($rs['startdt']>$dt){
  43. $statustext='待生效';
  44. $statuscolor='blue';
  45. }else if($rs['startdt']<=$dt && $rs['enddt']>=$dt){
  46. $statustext='生效中';
  47. $statuscolor='green';
  48. }else if($rs['enddt']<$dt){
  49. $statustext='已过期';
  50. $statuscolor='gray';
  51. }
  52. $htdata[] = array(
  53. 'id' => $rs['id'],
  54. 'name' => $rs['custname'],
  55. 'modenum' => 'custract',
  56. 'explain' => '金额:'.$rs['money'].',编号:'.$rs['num'].',有效期:'.$rs['startdt'].'→'.$rs['enddt'].'',
  57. 'statustext'=>$statustext,
  58. 'statuscolor'=>$statuscolor,
  59. );
  60. }
  61. }
  62. return returnsuccess(array(
  63. 'htdata' => $htdata,
  64. ));
  65. }
  66. /**
  67. * 获取客户数据
  68. */
  69. public function customerAction()
  70. {
  71. $mobile = $this->get('mobile');
  72. $xcytype = $this->get('xcytype');
  73. $openid = $this->get('openid');
  74. $sql = "select a.id,a.name,a.unitname,b.name as yewuname from [Q]customer a left join [Q]admin b on a.uid=b.id where a.`mobile`='$mobile' and a.`status`=1";
  75. $rows = $this->db->getall($sql);
  76. $custdata = array();
  77. foreach($rows as $k=>$rs){
  78. $custdata[] = array(
  79. 'id' => $rs['id'],
  80. 'name' => $rs['name'],
  81. 'modenum' => 'customer',
  82. 'explain' => '业务员:'.$rs['yewuname'].'',
  83. );
  84. }
  85. return returnsuccess(array(
  86. 'custdata' => $custdata,
  87. ));
  88. }
  89. }
粤ICP备19079148号