openmodhetongAction.php 2.8 KB

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