sugangqiang 2 lat temu
rodzic
commit
5e57d44c3d

+ 43 - 0
app/common.php

@@ -423,3 +423,46 @@ function get_client_ip() {
     }
     return $ip;
 }
+
+/**
+ * 通过CURL发送HTTP请求
+ * @param string $url  //请求URL
+ * @param array $postFields //请求参数
+ * @return mixed
+ *
+ */
+function curlPost($url, $postFields) {
+    $postFields = json_encode($postFields);
+    $ch = curl_init();
+    curl_setopt($ch, CURLOPT_URL, $url);
+    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
+        'Content-Type: application/json; charset=utf-8'   //json版本需要填写  Content-Type: application/json;
+            )
+    );
+    curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); //若果报错 name lookup timed out 报错时添加这一行代码
+    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+    curl_setopt($ch, CURLOPT_POST, 1);
+    curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
+    curl_setopt($ch, CURLOPT_TIMEOUT, 60);
+    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
+    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+    $ret = curl_exec($ch);
+    if (false == $ret) {
+        $result = curl_error($ch);
+    } else {
+        $rsp = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+        if (200 != $rsp) {
+            $result = "请求状态 " . $rsp . " " . curl_error($ch);
+        } else {
+            $result = $ret;
+        }
+    }
+    curl_close($ch);
+    return $result;
+}
+
+function getCacheById($key, $field) {
+    $redis = \app\common\Redis::instance(think\facade\Config::get("cache.stores.redis.select"));
+    $info = $redis->hGet($key, $field);
+    return json_decode($info, true);
+}

+ 11 - 2
app/common/api/IntegralRecordApi.php

@@ -24,11 +24,20 @@ class IntegralRecordApi {
         $order = $params["order"] ?: "desc";
         $offset = $params["offset"] ?: 0;
         $limit = $params["limit"] ?: 10;
+        if (session("user")["usertype"] == 2) {
+            $where[] = ["enterprise_id", "=", session("user")["uid"]];
+        }
         $count = IntegralRecord::where($where)->count();
         $list = IntegralRecord::where($where)->field("*,if(updateTime is not null,updateTime,createTime) as orderTime")->limit($offset, $limit)->order("orderTime " . $order)->select();
         foreach ($list as $key => $item) {
-            var_dump($item->detail->toArray());exit();
-            $list[$key]["detail"] = $item->detail();
+            $list[$key]["apply_year"] = BatchApi::getOne($item["batch_id"])["batch"];
+            $tmp_items = [];
+            foreach ($item["detail"] as $_item) {
+                $integral_item_info = getCacheById("IntegralItem", $_item["item_id"]);
+                $tmp_items[] = sprintf("%s(%s%s)", $integral_item_info["name"], $_item["amount"], $integral_item_info["unit"]);
+            }
+            $list[$key]["details"] = implode(",", $tmp_items);
+            $list[$key]["type"] = session("user")["type"];
         }
         return ["total" => $count, "rows" => $list];
     }

+ 37 - 0
app/common/api/JucaiApi.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace app\common\api;
+
+/**
+ * Description of JucaiApi
+ *
+ * @author sgq
+ */
+class JucaiApi {
+
+    protected static $key = "rsKVyec52fqEKpk4RRD2TU8fKvPxt6ombKg0qSq1velPQtBHVi";
+
+    public static function login($username, $password, $userType = 1) {
+        $params["username"] = $username;
+        $params["userType"] = $userType;
+        $params["timestr"] = sprintf("%s", time());
+        $md5 = self::checkSign($params);
+        $params["password"] = $password;
+        $params["sign"] = $md5;
+        $res = curlPost("https://www.jucai.gov.cn/api/checkuser", $params);
+        return $res;
+    }
+
+    private static function checkSign($params) {
+        ksort($params);
+        $signStr = "";
+        foreach ($params as $key => $val) {
+            if ($val) {
+                $signStr .= trim($key) . "=" . trim($val) . "&";
+            }
+        }
+        $signStr .= "key=" . self::$key;
+        return strtoupper(md5($signStr));
+    }
+
+}

+ 1 - 1
app/common/model/IntegralRecord.php

@@ -14,7 +14,7 @@ class IntegralRecord extends Model {
     protected $table = "new_integral_record";
 
     public function detail() {
-        return $this->hasOne(IntegralDetail::class, "record_id");
+        return $this->hasMany(IntegralDetail::class, "record_id");
     }
 
 }

+ 1 - 1
app/enterprise/controller/Integral.php

@@ -36,7 +36,7 @@ class Integral extends EnterpriseController {
         $param = $request->param();
         $id = isset($param["id"]) ? $param["id"] : 0;
         $info = IntegralRecordApi::getOne($id);
-        $info["detail"] = $info->detail->toArray();
+        $info["detail"] = $info->detail;
         $ep = EnterpriseApi::getOne($this->user["uid"]);
         if ($info) {
             $info["real_state"] = TalentLogApi::getLastLog($id, ProjectState::INTEGRAL)["state"];

+ 1 - 1
public/static/modular/gate/integral/integral.js

@@ -41,7 +41,7 @@ Integral.initColumn = function () {
             }
         },
         {title: '证件号码', field: 'card_number', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "120px"},
-        {title: '申报标准', field: 'identifyConditionText', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "120px"},
+        {title: '申报标准', field: 'details', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "120px"},
         {title: '审核状态', field: 'checkState', visible: true, align: 'center', valign: 'middle', width: "100px",
             formatter: function (value, row, index) {
                 if (row.real_state != row.checkState) {