wang jun 2 lat temu
rodzic
commit
1a9ec16616

+ 1 - 1
application/common.php

@@ -220,7 +220,7 @@ function isMoblid($tel)
     }
 }
 //获取httpsurl
-function getselfurl($name)
+function getselfurl($name = null)
 {
     $env = config('env');
     $sellurl = config('selfurl');

+ 23 - 26
application/index/controller/Appointment.php

@@ -11,9 +11,7 @@ namespace app\index\controller;
 use app\index\logic\appointmentlogic;
 use app\index\logic\paylogic;
 use app\index\logic\wechatlogic;
-use app\index\logic\wxuserlogic;
 use think\Controller;
-use think\Db;
 use think\Log;
 
 class Appointment extends Base
@@ -28,31 +26,30 @@ class Appointment extends Base
     public function newinfo()
     {
         $param = request()->post();
-        Db::startTrans();
-        try {
-            $l_wu = new wxuserlogic();
-            $result = $l_wu->saveinfo($param);
-            if ($result['status']) {
-                throw new \Exception($result['msg']);
-            }
-            $wudata = $result['data'];
-            $wid = $wudata['id'];
-            $param['wid'] = $wid;
-            $l_a = new appointmentlogic();
-            $result = $l_a->newinfo($param);
-            if (!$result['status']) {
-                throw new \Exception($result['msg']);
-            }
-            $adata = $result['data'];
-            $returnData = [
-                'aid' => $adata['id'],
-            ];
-            Db::commit();
-            return backjson(1, $returnData);
-        } catch (\Exception $e) {
-            Db::rollback();
-            return backjson(0, $e->getMessage());
+        $l_a = new appointmentlogic();
+        $result = $l_a->newinfo($param);
+        if (!$result['status']) {
+            return backjson(0, $result['msg']);
+        }
+        return backjson(1, $result['data']);
+    }
+    /**
+     * 获取用户可用数据
+     *
+     * @param  [type] $arr
+     * @return void
+     * @author wj
+     * @date 2022-07-25
+     */
+    public function getuseablelist()
+    {
+        $param = request()->post();
+        $l_a = new appointmentlogic();
+        $result = $l_a->getuseablelist($param);
+        if (!$result['status']) {
+            return backjson(0, $result['msg']);
         }
+        return backjson(1, $result['data']);
     }
     /**
      * 支付核酸检测费用 仅小程序支付

+ 79 - 0
application/index/controller/Fileoper.php

@@ -0,0 +1,79 @@
+<?php
+
+/**
+ * Created by PhpStorm.
+ * User: sicilon_IT
+ * Date: 2020/1/5
+ * Time: 9:49
+ */
+
+namespace app\index\controller;
+
+use think\Controller;
+use think\facade\Log;
+use think\Request;
+
+class Fileoper extends Controller
+{
+    private function filterfiletype($usefile = "file")
+    {
+        $filetype = $_FILES[$usefile]['type'];
+        $types = [
+            'image',
+            'excel',
+        ];
+        $filetypeuse = "*" . $filetype;
+        $iscanupload = false;
+        foreach ($types as $key => $value) {
+            if (strpos($filetypeuse, $value)) {
+                $iscanupload = true;
+            }
+        }
+        if (!$iscanupload) {
+            log::info($_FILES);
+            $msg = "file type error: " . $filetype;
+            log::info($msg);
+            $this->error($msg);
+        }
+    }
+    /**
+     * 指定文件位置上传
+     *
+     * @return void
+     */
+    public function uploadfilebydir()
+    {
+        Log::info($_FILES);
+        $this->filterfiletype();
+        // 获取表单上传文件
+        $file = request()->file('file');
+        if (empty($file)) {
+            $this->error('请选择上传文件');
+        }
+        $dir = request()->param('dir', 'appointment');
+        if (!preg_match("/^[a-z]{5,30}$/", $dir)) {
+            $this->error('请求错误');
+        }
+        $dir = 'Uploads' . '/' . $dir;
+        $domainpath = getselfurl() . '/' . $dir . '/';
+        // 移动到框架应用根目录/public/uploads/ 目录下
+        $info = $file->move(ROOT_PATH . 'public' . '/' . $dir);
+
+        //如果不清楚文件上传的具体键名,可以直接打印$info来查看
+        //获取文件(文件名),$info->getFilename()  ***********不同之处,笔记笔记哦
+        //获取文件(日期/文件名),$info->getSaveName()  **********不同之处,笔记笔记哦
+        $filename = $info->getSaveName(); //在测试的时候也可以直接打印文件名称来查看
+        $filename = str_replace(DS, "/", $filename);
+        if ($filename) {
+            //$this->success('文件上传成功!');
+            $imageUrl = $domainpath . $filename;
+            $r_upload['code'] = '200';
+            $r_upload['resultData'] = $imageUrl;
+            //不转义反斜杠
+            return json_encode($r_upload, 320);
+        } else {
+            // 上传失败获取错误信息
+            $this->error($file->getError());
+        }
+    }
+}

+ 24 - 33
application/index/logic/appointmentlogic.php

@@ -2,7 +2,6 @@
 namespace app\index\logic;
 
 use app\index\model\appointmentmodel;
-use app\index\model\wxusermodel;
 
 /**
  * 登记记录表
@@ -20,39 +19,47 @@ class appointmentlogic extends baselogic
     protected function setrules()
     {
         $list = [
-            'getlastinfo' => [
-                ['name' => 'sfzid', 'title' => '身份证', 'require' => true, 'type' => 'string'],
+            'getuseablelist' => [
+                ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
             ],
             'newinfo' => [
-                ['name' => 'wid', 'title' => '用户id', 'require' => true, 'type' => 'numeric'],
-                ['name' => 'gps_lng', 'title' => '经度', 'require' => false, 'type' => 'numeric', 'default' => ''],
-                ['name' => 'gps_lat', 'title' => '纬度', 'require' => false, 'type' => 'numeric', 'default' => ''],
+                ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
+                ['name' => 'sfzid', 'title' => '身份证号', 'require' => true, 'type' => 'string'],
+                ['name' => 'name', 'title' => '姓名', 'require' => true, 'type' => 'string'],
+                ['name' => 'telno', 'title' => '手机号', 'require' => false, 'type' => 'string'],
                 ['name' => 'signurl', 'title' => '签名', 'require' => true, 'type' => 'string'],
+                //['name' => 'wid', 'title' => '用户id', 'require' => true, 'type' => 'numeric'],
+                //['name' => 'gps_lng', 'title' => '经度', 'require' => false, 'type' => 'numeric', 'default' => ''],
+                //['name' => 'gps_lat', 'title' => '纬度', 'require' => false, 'type' => 'numeric', 'default' => ''],
+
             ],
         ];
         return $list;
     }
     /**
-     * 获取用户当日申请最后一条数据
+     * 获取用户可用数据
      *
      * @param  [type] $arr
      * @return void
      * @author wj
-     * @date 2022-07-22
+     * @date 2022-07-25
      */
-    public function getlastinfo($arr)
+    public function getuseablelist($arr)
     {
         $result = $this->checkparam(__FUNCTION__, $arr);
         if (1 != $result['status']) {
             return $result;
         }
         $data = $result['data'];
+        $openid = $data['openid'];
         $m_a = new appointmentmodel();
-        $info = $m_a->getlastinfo($data);
-        if (empty($info)) {
+        $where = ['openid' => $openid, 'ispay' => '1', 'isuse' => 0];
+        $field = ['id', 'openid', 'name', 'telno'];
+        $list = $m_a->getList($where, $field, 1, 0);
+        if (empty($list)) {
             return backarr(0, "无申请数据");
         }
-        return backarr(1, "查询成功", $info);
+        return backarr(1, "查询成功", $list);
     }
     /**
      * 新建用户申请数据
@@ -69,31 +76,15 @@ class appointmentlogic extends baselogic
             return $result;
         }
         $data = $result['data'];
-        $wid = $data['wid'];
-        $gps_lng = $data['gps_lng'];
-        $gps_lat = $data['gps_lat'];
         $m_a = new appointmentmodel();
-        $m_u = new wxusermodel();
-        $info = $m_u->getinfobyid($wid, '*');
-        if (empty($info)) {
-            return backarr(0, "无用户数据");
-        }
         $insertData = [
-            'wid' => $info['id'],
-            'openid' => $info['openid'],
-            'name' => $info['real_name'],
-            'sfzid' => $info['sfzid'],
-            'telno' => $info['telno'],
+            'openid' => $data['openid'],
+            'name' => $data['name'],
+            'sfzid' => $data['sfzid'],
+            'telno' => $data['telno'],
             'oprdate' => date('Y-m-d H:i:s'),
-            'isuse' => 0,
-            'ispay' => 0,
+            'signurl' => $data['signurl'],
         ];
-        if (empty($gps_lng) && is_numeric($gps_lng)) {
-            $insertData['gps_lng'] = $gps_lng;
-        }
-        if (empty($gps_lat) && is_numeric($gps_lat)) {
-            $insertData['gps_lat'] = $gps_lat;
-        }
         $id = $m_a->insertData($insertData);
         if (empty($id)) {
             return backarr(0, "添加失败");

+ 2 - 2
application/index/logic/baselogic.php

@@ -38,7 +38,7 @@ class baselogic
                     $title = $value['title'];
                     //必填
                     if (isset($value['require']) && $value['require']) {
-                        if (!isset($param[$name])) {
+                        if (!isset($param[$name]) || empty($param[$name])) {
                             throw new \Exception($title . '未填');
                         }
                     }
@@ -85,7 +85,7 @@ class baselogic
             } catch (\Exception $e) {
                 $msg = $e->getMessage();
                 Log::error($msg);
-                return backarr(0, "请求错误");
+                return backarr(0, $msg);
             }
         }
         return backarr(1, 'success', $param);

+ 6 - 4
application/index/logic/wechatlogic.php

@@ -53,8 +53,10 @@ class wechatlogic extends baselogic
     public function getselfwxconfig()
     {
         $config = [
-            'appid' => 'wx47d6be96fb2d466c',
-            'appSecret' => 'c0252b0cea090a1f3fb41ea7c71d55d6',
+            //'appid' => 'wx47d6be96fb2d466c',
+            //'appSecret' => 'c0252b0cea090a1f3fb41ea7c71d55d6',
+            'appid' => 'wxcacf6eb6e7478e29',
+            'appSecret' => '3722c3f95df0569498a0e32ae6e85153',
         ];
         return $config;
     }
@@ -68,8 +70,8 @@ class wechatlogic extends baselogic
     public function getpayconfig()
     {
         $config = [
-            'mchid' => '1618582831', //零散务工工会
-            'key' => 'e8b1ae8576eef64f09ebb9c9a6964cae', //商户号key
+            'mchid' => '1616316171', //零散务工工会
+            'key' => 'WaterCat20211001ShuiMaoGongJiang', //商户号key
         ];
         return $config;
     }

+ 1 - 1
application/index/logic/wxuserlogic.php

@@ -34,7 +34,7 @@ class wxuserlogic extends baselogic
                 ['name' => 'province', 'title' => '省', 'require' => false, 'type' => 'string'],
                 ['name' => 'city', 'title' => '市', 'require' => false, 'type' => 'string'],
                 ['name' => 'country', 'title' => '县', 'require' => false, 'type' => 'string'],
-                ['name' => 'tel', 'title' => '手机号', 'require' => false, 'type' => 'string'],
+                ['name' => 'telno', 'title' => '手机号', 'require' => false, 'type' => 'string'],
                 ['name' => 'address', 'title' => '地址', 'require' => false, 'type' => 'string'],
             ],
         ];

+ 7 - 1
application/index/model/appointmentmodel.php

@@ -11,6 +11,8 @@ use think\Model;
  */
 class appointmentmodel extends Model
 {
+    protected $table = "t_appointment";
+
     public function insertData($data)
     {
         if (!isset($data['oprdate']) || empty($data['oprdate']) || !is_string($data['oprdate'])) {
@@ -69,7 +71,11 @@ class appointmentmodel extends Model
     {
         $sqlObj = $this->where($where);
         if ("count" != $field) {
-            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if (empty($size)) {
+                $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            } else {
+                $sqlObj = $sqlObj->field($field)->order($order)->group($group);
+            }
             if ($row) {
                 $data = $sqlObj->find();
             } else {

+ 2 - 0
application/index/model/payordermodel.php

@@ -5,6 +5,8 @@ use think\Model;
 
 class payordermodel extends Model
 {
+    protected $table = "t_payorder";
+
     public function insertData($data)
     {
         if (!isset($data['create_date']) || empty($data['create_date']) || !is_string($data['create_date'])) {

+ 2 - 0
application/index/model/wxusermodel.php

@@ -5,6 +5,8 @@ use think\Model;
 
 class wxusermodel extends Model
 {
+    protected $table = "t_wxuser";
+
     public function insertData($data)
     {
         if (!isset($data['create_date']) || empty($data['create_date']) || !is_string($data['create_date'])) {

+ 3 - 2
config/app.php

@@ -143,12 +143,13 @@ return [
     // 异常处理handle类 留空使用 \think\exception\Handle
     'exception_handle' => '',
     'env' => 'dev', //'pro'
+    //'env' => 'pro',
     'selfurl' => [
         'dev' => [
-            'default' => 'https://app.tjzhxx.cn:43443',
+            'default' => 'https://app.tjzhxx.cn:41443',
         ],
         'pro' => [
-            'default' => 'https://app.tjzhxx.cn:43443',
+            'default' => 'https://app.tjzhxx.cn:40443',
         ],
     ],