From 437c5796ea80601ced9f03edc2e7ab1ccaa6dcdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=96=E5=BB=BA?= Date: Sun, 4 Jan 2026 15:34:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/farm/model/Farmer.php | 142 ++++++++++++----------- vendor/topthink/framework/src/helper.php | 4 +- 2 files changed, 77 insertions(+), 69 deletions(-) diff --git a/app/farm/model/Farmer.php b/app/farm/model/Farmer.php index 16ef0e4..c88054e 100644 --- a/app/farm/model/Farmer.php +++ b/app/farm/model/Farmer.php @@ -1,4 +1,5 @@ time()){ + if ($start_time < time() && $end_time > time()) { return 1; - }else{ + } else { return 0; } @@ -47,11 +49,12 @@ class Farmer extends BaseModel * @DataTime: 2021-12-30 11:22 * @功能说明: */ - public function getImgsAttr($value,$data){ + public function getImgsAttr($value, $data) + { - if(!empty($value)){ + if (!empty($value)) { - return explode(',',$value); + return explode(',', $value); } } @@ -61,20 +64,23 @@ class Farmer extends BaseModel * @DataTime: 2021-12-30 11:22 * @功能说明: */ - public function getIdcardImgsAttr($value,$data){ + public function getIdcardImgsAttr($value, $data) + { - if(!empty($value)){ + if (!empty($value)) { - return explode(',',$value); + return explode(',', $value); } } + /** * @author chenniang * @DataTime: 2020-09-29 11:04 * @功能说明:添加 */ - public function dataAdd($data){ + public function dataAdd($data) + { $data['create_time'] = time(); @@ -85,13 +91,13 @@ class Farmer extends BaseModel } - /** * @author chenniang * @DataTime: 2020-09-29 11:05 * @功能说明:编辑 */ - public function dataUpdate($dis,$data){ + public function dataUpdate($dis, $data) + { $res = $this->where($dis)->update($data); @@ -105,7 +111,8 @@ class Farmer extends BaseModel * @DataTime: 2020-09-29 11:06 * @功能说明:列表 */ - public function dataList($dis,$page=10){ + public function dataList($dis, $page = 10) + { $data = $this->where($dis)->order('id desc')->paginate($page)->toArray(); @@ -119,9 +126,10 @@ class Farmer extends BaseModel * @DataTime: 2020-09-29 11:06 * @功能说明:列表 */ - public function dataDistanceList($dis,$alh,$alhs=[],$page=10){ + public function dataDistanceList($dis, $alh, $alhs = [], $page = 10) + { - $data = $this->where($dis)->where($alhs)->field(['*',$alh])->order('distance asc,id desc')->paginate($page)->toArray(); + $data = $this->where($dis)->where($alhs)->field(['*', $alh])->order('distance asc,id desc')->paginate($page)->toArray(); return $data; @@ -133,19 +141,20 @@ class Farmer extends BaseModel * @DataTime: 2021-12-30 11:26 * @功能说明:后台列表 */ - public function adminDataList($dis,$page=10,$where=[]){ + public function adminDataList($dis, $page = 10, $where = []) + { $data = $this->alias('a') - ->join('lbfarm_user_list b','a.user_id = b.id','left') - ->where($dis) - ->where(function ($query) use ($where){ - $query->whereOr($where); - }) - ->field('a.*,b.nickName,b.avatarUrl') - ->group('a.id') - ->order('a.id desc') - ->paginate($page) - ->toArray(); + ->join('lbfarm_user_list b', 'a.user_id = b.id', 'left') + ->where($dis) + ->where(function ($query) use ($where) { + $query->whereOr($where); + }) + ->field('a.*,b.nickName,b.avatarUrl') + ->group('a.id') + ->order('a.id desc') + ->paginate($page) + ->toArray(); return $data; @@ -157,11 +166,12 @@ class Farmer extends BaseModel * @DataTime: 2020-09-29 11:43 * @功能说明: */ - public function dataInfo($dis,$file='*'){ + public function dataInfo($dis, $file = '*') + { $data = $this->where($dis)->field($file)->find(); - return !empty($data)?$data->toArray():[]; + return !empty($data) ? $data->toArray() : []; } @@ -171,13 +181,14 @@ class Farmer extends BaseModel * @DataTime: 2022-02-22 11:30 * @功能说明:检查用户是否是地主 */ - public function landlordCheck($user_id){ + public function landlordCheck($user_id) + { - $cap_dis[] = ['user_id','=',$user_id]; + $cap_dis[] = ['user_id', '=', $user_id]; - $cap_dis[] = ['type','=',1]; + $cap_dis[] = ['type', '=', 1]; - $cap_dis[] = ['status','in',[2,3]]; + $cap_dis[] = ['status', 'in', [2, 3]]; $farmer_model = new \app\farm\model\Farmer(); //查看是否是团长 @@ -185,17 +196,17 @@ class Farmer extends BaseModel $is_landlord = 1; - if(empty($cap_info)){ + if (empty($cap_info)) { $order_model = new LandOrder(); - $where[] = ['pay_type','>',1]; + $where[] = ['pay_type', '>', 1]; - $where[] = ['user_id','=',$user_id]; + $where[] = ['user_id', '=', $user_id]; //是否有土地订单 $order = $order_model->dataInfo($where); - if(empty($order)){ + if (empty($order)) { $is_landlord = 0; @@ -205,7 +216,7 @@ class Farmer extends BaseModel $user_model = new User(); - $user_model->dataUpdate(['id'=>$user_id],['is_landlord'=>$is_landlord]); + $user_model->dataUpdate(['id' => $user_id], ['is_landlord' => $is_landlord]); return $is_landlord; } @@ -216,11 +227,12 @@ class Farmer extends BaseModel * @DataTime: 2022-02-22 11:53 * @功能说明:初始化地主表 */ - public function initLandLord($data,$uniacid){ + public function initLandLord($data, $uniacid) + { $dis = [ - 'type' => 2, + 'type' => 2, 'user_id' => $data['user_id'], @@ -229,7 +241,7 @@ class Farmer extends BaseModel $find = $this->dataInfo($dis); - if(empty($find)){ + if (empty($find)) { $dis['status'] = 2; @@ -251,7 +263,7 @@ class Farmer extends BaseModel $user_model = new User(); - $user_model->dataUpdate(['id'=>$data['user_id']],['is_landlord'=>1]); + $user_model->dataUpdate(['id' => $data['user_id']], ['is_landlord' => 1]); } return true; @@ -262,22 +274,23 @@ class Farmer extends BaseModel * @DataTime: 2020-10-21 15:21 * @功能说明:保留两位小数 */ - public function getDistanceAttr($value){ + public function getDistanceAttr($value) + { - if(!empty($value)){ + if (!empty($value)) { - if($value>1000){ + if ($value > 1000) { - $value = $value/1000; + $value = $value / 1000; - $value = round($value,2); + $value = round($value, 2); - $value = $value.'km'; - }else{ + $value = $value . 'km'; + } else { - $value = round($value,2); + $value = round($value, 2); - $value = $value.'m'; + $value = $value . 'm'; } @@ -288,30 +301,29 @@ class Farmer extends BaseModel } - - /** * @author chenniang * @DataTime: 2022-02-28 14:08 * @功能说明:添加商品时农场主下拉框 */ - public function goodsFarmerSelect($user_id){ + public function goodsFarmerSelect($user_id) + { $land_order_model = new LandOrder(); - $dis[] = ['user_id','=',$user_id]; + $dis[] = ['user_id', '=', $user_id]; - $dis[] = ['pay_type','>',1]; + $dis[] = ['pay_type', '>', 1]; //购买土地对农场主id $order_farmer = $land_order_model->where($dis)->column('farmer_id'); - $where[] = ['user_id','=',$user_id]; + $where[] = ['user_id', '=', $user_id]; - $where[] = ['status','in',[2,3]]; + $where[] = ['status', 'in', [2, 3]]; //如果自己是农场主 $farmer = $this->where($where)->column('id'); - $order_farmer = array_merge($order_farmer,$farmer); + $order_farmer = array_merge($order_farmer, $farmer); return $order_farmer; } @@ -322,13 +334,14 @@ class Farmer extends BaseModel * @DataTime: 2022-02-28 16:06 * @功能说明: */ - public function farmerId($uniacid){ + public function farmerId($uniacid) + { $dis = [ 'status' => 2, - 'uniacid'=> $uniacid + 'uniacid' => $uniacid ]; $id = $this->where($dis)->column('id'); @@ -338,7 +351,4 @@ class Farmer extends BaseModel } - - - -} \ No newline at end of file +} diff --git a/vendor/topthink/framework/src/helper.php b/vendor/topthink/framework/src/helper.php index e37a3b0..2866935 100644 --- a/vendor/topthink/framework/src/helper.php +++ b/vendor/topthink/framework/src/helper.php @@ -698,9 +698,7 @@ if (!function_exists('is_dev')) { if (in_array($env, ['dev', 'development', 'local', 'test'], true)) { return true; } - if (app()->environment('dev') || app()->environment('local') || app()->environment('test')) { - return true; - } + return false; } }