123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace app\common\api;
- use app\common\model\TalentAllowance as TaModel;
- use app\common\state\MainState;
- use think\facade\Db;
- use app\common\state\CommonConst;
- /**
- * Description of TalentAllowanceApi
- *
- * @author sgq
- */
- class TalentAllowanceApi {
- public static function getList($params) {
- $user = session("user");
- $order = trim($params["order"]) ?: "desc";
- $offset = trim($params["offset"]) ?: 0;
- $limit = trim($params["limit"]) ?: 10;
- $where = [];
- $where[] = ["enterpriseId", "=", $user["uid"]];
- if ($_where = self::setTalentAllowanceInfo($params)) {
- $where = array_merge($where, $_where);
- }
- $count = TaModel::where($where)->count();
- $list = TaModel::where($where)->limit($offset, $limit)->order("year " . $order)->select()->toArray();
- $levelList = DictApi::selectByParentCode("talent_arrange");
- $talentTypeList = DictApi::selectByParentCode("enterprise_tag");
- $streetList = DictApi::selectByParentCode("street");
- $identifyConditionIds = array_filter(array_unique(array_column($list, "identifyCondition")));
- $whr[] = ["id", "in", $identifyConditionIds];
- $whr[] = ["type", "=", $user["type"]];
- $identifyConditionKvList = TalentConditionApi::getKvList($whr);
- foreach ($list as $key => $item) {
- $list[$key]["talentArrangeName"] = $levelList[$item["talentArrange"]];
- $list[$key]["talentTypeName"] = $talentTypeList[$item["talentType"]];
- $list[$key]["addressName"] = $streetList[$item["address"]];
- $list[$key]["identifyConditionText"] = $identifyConditionKvList[$item["identifyCondition"]];
- }
- return ["total" => $count, "rows" => $list];
- }
- public static function setTalentAllowanceInfo($params) {
- $where = [];
- if (\StrUtil::isNotEmpAndNull($params["year"])) {
- $where[] = ["year", "=", $params["year"]];
- }
- if (\StrUtil::isNotEmpAndNull($params["enterpriseName"])) {
- $where[] = ["enterpriseName", "like", "%" . $params["enterpriseName"] . "%"];
- }
- if (\StrUtil::isNotEmpAndNull($params["name"])) {
- $where[] = ["name", "like", "%" . $params["name"] . "%"];
- }
- if (\StrUtil::isNotEmpAndNull($params["talentType"])) {
- $where[] = ["talentType", "=", $params["talentType"]];
- }
- if (\StrUtil::isNotEmpAndNull($params["talentArrange"])) {
- $where[] = ["talentArrange", "=", $params["talentArrange"]];
- }
- if (\StrUtil::isNotEmpAndNull($params["identiryCondition"])) {
- $where[] = ["identifyCondition", "=", $params["identifyCondition"]];
- }
- if (\StrUtil::isNotEmpAndNull($params["address"])) {
- $where[] = ["address", "=", $params["address"]];
- }
- return $where;
- }
- public static function getInfoById($id) {
- return TaModel::findOrEmpty($id)->toArray();
- }
- public static function getApplyCountByIdCard($idCard) {
- $where = [];
- $where[] = ["idCard", "=", $idCard];
- $where[] = ["checkState", "<>", MainState::NOTPASS];
- $list = TaModel::where($where)->distinct(true)->field("substr(year,1,4) as year")->select()->toArray();
- $years = array_column($list, "year");
- return $years;
- }
- public static function getPassYearsByIdCard($idCard) {
- $where = [];
- $where[] = ["idCard", "=", $idCard];
- $where[] = ["checkState", "=", MainState::PASS];
- $list = TaModel::where($where)->distinct(true)->field("substr(year,1,4) as year")->select()->toArray();
- $passYears = array_column($list, "year");
- return $passYears;
- }
- }
|