appointmentlogic.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. namespace app\index\logic;
  3. use app\index\model\appointmentmodel;
  4. use app\index\model\wxusermodel;
  5. /**
  6. * 登记记录表
  7. *
  8. * @author wj
  9. * @date 2022-07-22
  10. */
  11. class appointmentlogic extends baselogic
  12. {
  13. /**
  14. * 设置请求数据规则
  15. * 20220107
  16. * wj
  17. */
  18. protected function setrules()
  19. {
  20. $list = [
  21. 'getlastinfo' => [
  22. ['name' => 'sfzid', 'title' => '身份证', 'require' => true, 'type' => 'string'],
  23. ],
  24. 'newinfo' => [
  25. ['name' => 'wid', 'title' => '用户id', 'require' => true, 'type' => 'numeric'],
  26. ['name' => 'gps_lng', 'title' => '经度', 'require' => false, 'type' => 'numeric', 'default' => ''],
  27. ['name' => 'gps_lat', 'title' => '纬度', 'require' => false, 'type' => 'numeric', 'default' => ''],
  28. ['name' => 'signurl', 'title' => '签名', 'require' => true, 'type' => 'string'],
  29. ],
  30. ];
  31. return $list;
  32. }
  33. /**
  34. * 获取用户当日申请最后一条数据
  35. *
  36. * @param [type] $arr
  37. * @return void
  38. * @author wj
  39. * @date 2022-07-22
  40. */
  41. public function getlastinfo($arr)
  42. {
  43. $result = $this->checkparam(__FUNCTION__, $arr);
  44. if (1 != $result['status']) {
  45. return $result;
  46. }
  47. $data = $result['data'];
  48. $m_a = new appointmentmodel();
  49. $info = $m_a->getlastinfo($data);
  50. if (empty($info)) {
  51. return backarr(0, "无申请数据");
  52. }
  53. return backarr(1, "查询成功", $info);
  54. }
  55. /**
  56. * 新建用户申请数据
  57. *
  58. * @param [type] $arr
  59. * @return void
  60. * @author wj
  61. * @date 2022-07-22
  62. */
  63. public function newinfo($arr)
  64. {
  65. $result = $this->checkparam(__FUNCTION__, $arr);
  66. if (1 != $result['status']) {
  67. return $result;
  68. }
  69. $data = $result['data'];
  70. $wid = $data['wid'];
  71. $gps_lng = $data['gps_lng'];
  72. $gps_lat = $data['gps_lat'];
  73. $m_a = new appointmentmodel();
  74. $m_u = new wxusermodel();
  75. $info = $m_u->getinfobyid($wid, '*');
  76. if (empty($info)) {
  77. return backarr(0, "无用户数据");
  78. }
  79. $insertData = [
  80. 'wid' => $info['id'],
  81. 'openid' => $info['openid'],
  82. 'name' => $info['real_name'],
  83. 'sfzid' => $info['sfzid'],
  84. 'telno' => $info['telno'],
  85. 'oprdate' => date('Y-m-d H:i:s'),
  86. 'isuse' => 0,
  87. 'ispay' => 0,
  88. ];
  89. if (empty($gps_lng) && is_numeric($gps_lng)) {
  90. $insertData['gps_lng'] = $gps_lng;
  91. }
  92. if (empty($gps_lat) && is_numeric($gps_lat)) {
  93. $insertData['gps_lat'] = $gps_lat;
  94. }
  95. $id = $m_a->insertData($insertData);
  96. if (empty($id)) {
  97. return backarr(0, "添加失败");
  98. }
  99. return backarr(1, "添加成功", ['id' => $id]);
  100. }
  101. }