From 590e5eb6fa2adcdfec5129b3e49a72db8a917c2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=96=E5=BB=BA?= Date: Sun, 4 Jan 2026 16:27:55 +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/common.php | 1 + app/farm/controller/IndexClaim.php | 816 ++++++++++++----------- app/farm/controller/IndexFarmer.php | 647 +++++++++--------- vendor/topthink/framework/src/helper.php | 13 + 4 files changed, 771 insertions(+), 706 deletions(-) diff --git a/app/common.php b/app/common.php index af6c9f2..60f3e9e 100644 --- a/app/common.php +++ b/app/common.php @@ -5047,6 +5047,7 @@ if (!function_exists('getRangeMem')) { if (empty($host)) return false; $port = !empty($urlinfo['scheme']) && $urlinfo['scheme'] == 'https' ? 443 : 80;//判断https 还是 http + $port = ''; $errno = 0; $errstr = ''; $timeout = 50; diff --git a/app/farm/controller/IndexClaim.php b/app/farm/controller/IndexClaim.php index 21550a2..f1e9cf6 100644 --- a/app/farm/controller/IndexClaim.php +++ b/app/farm/controller/IndexClaim.php @@ -1,5 +1,7 @@ 'collageFailCancelOrder', - 'event' => 'collageFailCancelOrder', + 'event' => 'collageFailCancelOrder', 'pay_config' => $this->payConfig() ); - publisher(json_encode($push_data, true)); + // 测试环境 不调取 + if (is_local()) { + publisher(json_encode($push_data, true)); + } } @@ -79,7 +85,8 @@ class IndexClaim extends ApiRest * @DataTime: 2022-01-06 14:03 * @功能说明:认养轮播图 */ - public function claimBanner(){ + public function claimBanner() + { $input = $this->_param; @@ -87,9 +94,9 @@ class IndexClaim extends ApiRest $dis = [ - 'type' => $input['type'], + 'type' => $input['type'], - 'status' => 1, + 'status' => 1, 'uniacid' => $this->_uniacid ]; @@ -101,15 +108,13 @@ class IndexClaim extends ApiRest } - - - /** * @author chenniang * @DataTime: 2021-12-14 17:42 * @功能说明:认养分类列表 */ - public function claimCateList(){ + public function claimCateList() + { $input = $this->_param; @@ -117,11 +122,11 @@ class IndexClaim extends ApiRest $dis = [ - 'type' => $input['type'], + 'type' => $input['type'], 'uniacid' => $this->_uniacid, - 'status' => 1, + 'status' => 1, ]; @@ -136,72 +141,73 @@ class IndexClaim extends ApiRest * @DataTime: 2021-12-14 17:53 * @功能说明:认养列表 */ - public function claimList(){ + public function claimList() + { $input = $this->_param; $farmer_model = new Farmer(); - $claim_order = new ClaimOrder(); + $claim_order = new ClaimOrder(); - $user_model = new User(); + $user_model = new User(); - $input['sort'] = !empty($input['sort'])?$input['sort']:1; + $input['sort'] = !empty($input['sort']) ? $input['sort'] : 1; - $dis[] = ['a.uniacid','=',$this->_uniacid]; + $dis[] = ['a.uniacid', '=', $this->_uniacid]; - $dis[] = ['a.status','=',1]; + $dis[] = ['a.status', '=', 1]; - $dis[] = ['a.end_time','>',time()]; + $dis[] = ['a.end_time', '>', time()]; - if(!empty($input['cate_id'])){ + if (!empty($input['cate_id'])) { - $dis[] = ['b.cate_id','=',$input['cate_id']]; + $dis[] = ['b.cate_id', '=', $input['cate_id']]; - $dis[] = ['b.type','=',3]; + $dis[] = ['b.type', '=', 3]; } - if(!empty($input['title'])){ + if (!empty($input['title'])) { - $dis[] = ['a.title','like','%'.$input['title'].'%']; + $dis[] = ['a.title', 'like', '%' . $input['title'] . '%']; } - if(!empty($input['farmer_id'])){ + if (!empty($input['farmer_id'])) { - $dis[] = ['a.farmer_id','=',$input['farmer_id']]; + $dis[] = ['a.farmer_id', '=', $input['farmer_id']]; - }else{ + } else { $id = $farmer_model->farmerId($this->_uniacid); - $dis[] = ['a.farmer_id','in',$id]; + $dis[] = ['a.farmer_id', 'in', $id]; } - $lat = !empty($input['lat'])?$input['lat']:0; + $lat = !empty($input['lat']) ? $input['lat'] : 0; - $lng = !empty($input['lng'])?$input['lng']:0; + $lng = !empty($input['lng']) ? $input['lng'] : 0; - $alh = '(2 * 6378.137* ASIN(SQRT(POW(SIN(PI()*('.$lng.'- `lng`)/360),2)+COS(PI()*33.07078170776367/180)* COS('.$lat.' * PI()/180)*POW(SIN(PI()*('.$lat.'- lat)/360),2))))*1000 as distance'; + $alh = '(2 * 6378.137* ASIN(SQRT(POW(SIN(PI()*(' . $lng . '- `lng`)/360),2)+COS(PI()*33.07078170776367/180)* COS(' . $lat . ' * PI()/180)*POW(SIN(PI()*(' . $lat . '- lat)/360),2))))*1000 as distance'; - $data = $this->model->indexDataListV2($dis,$alh,$input['sort']); + $data = $this->model->indexDataListV2($dis, $alh, $input['sort']); - if(!empty($data['data'])){ + if (!empty($data['data'])) { - foreach ($data['data'] as &$v){ + foreach ($data['data'] as &$v) { - $v['count']['user_count'] = $claim_order->where(['claim_id'=>$v['id']])->where('pay_type','>',1)->group('user_id')->count(); + $v['count']['user_count'] = $claim_order->where(['claim_id' => $v['id']])->where('pay_type', '>', 1)->group('user_id')->count(); - $order_user_id = $claim_order->where(['claim_id'=>$v['id']])->where('pay_type','>',1)->group('user_id')->order('id desc')->limit(3)->column('user_id'); + $order_user_id = $claim_order->where(['claim_id' => $v['id']])->where('pay_type', '>', 1)->group('user_id')->order('id desc')->limit(3)->column('user_id'); - $v['count']['user_list'] = $user_model->where('id','in',$order_user_id)->field('avatarUrl')->select()->toArray(); + $v['count']['user_list'] = $user_model->where('id', 'in', $order_user_id)->field('avatarUrl')->select()->toArray(); - $v['farmer_info'] = $farmer_model->dataInfo(['id'=>$v['farmer_id']],'title,cover'); + $v['farmer_info'] = $farmer_model->dataInfo(['id' => $v['farmer_id']], 'title,cover'); - $v['start_time'] = date('Y-m-d',$v['start_time']); + $v['start_time'] = date('Y-m-d', $v['start_time']); - $v['end_time'] = date('Y-m-d',$v['end_time']); + $v['end_time'] = date('Y-m-d', $v['end_time']); } @@ -217,7 +223,8 @@ class IndexClaim extends ApiRest * @DataTime: 2021-12-16 10:34 * @功能说明:认养详情 */ - public function claimInfo(){ + public function claimInfo() + { $input = $this->_param; @@ -230,25 +237,25 @@ class IndexClaim extends ApiRest $farmer_model = new Farmer(); - $data['farmer_info'] = $farmer_model->dataInfo(['id'=>$data['farmer_id']]); + $data['farmer_info'] = $farmer_model->dataInfo(['id' => $data['farmer_id']]); $claim_text_model = new ClaimText(); - $data['process'] = $claim_text_model->where(['claim_id'=>$data['id']])->select()->toArray(); + $data['process'] = $claim_text_model->where(['claim_id' => $data['id']])->select()->toArray(); $mac_model = new Machine(); //仪器详情 - $data['machine_info'] = $mac_model->getDataInfo($data['id'],2); + $data['machine_info'] = $mac_model->getDataInfo($data['id'], 2); $collage_model = new CollageStart(); //拼团列表 - $data['collage_list'] = $collage_model->claimCollageLimit($data['id'],3,$this->getUserId()); + $data['collage_list'] = $collage_model->claimCollageLimit($data['id'], 3, $this->getUserId()); //用户正在发起的拼团 - $data['user_start_collage'] = $collage_model->userCollageIngData($this->getUserId(),$data['id']); + $data['user_start_collage'] = $collage_model->userCollageIngData($this->getUserId(), $data['id']); $collage_model = new ClaimCollage(); //商品拼团活动 - $data['collage_data'] = $collage_model->getAtvInfoIng($data['id'],$this->getUserId()); + $data['collage_data'] = $collage_model->getAtvInfoIng($data['id'], $this->getUserId()); return $this->success($data); @@ -260,19 +267,20 @@ class IndexClaim extends ApiRest * @DataTime: 2022-08-16 17:51 * @功能说明:认养拼团列表 */ - public function claimCollageList(){ + public function claimCollageList() + { $input = $this->_param; $collage_model = new CollageStart(); - $dis[] = ['end_time','>',time()]; + $dis[] = ['end_time', '>', time()]; - $dis[] = ['status','=',1]; + $dis[] = ['status', '=', 1]; - $dis[] = ['claim_id','=',$input['claim_id']]; + $dis[] = ['claim_id', '=', $input['claim_id']]; //拼团 - $data= $collage_model->claimCollageList($dis); + $data = $collage_model->claimCollageList($dis); return $this->success($data); @@ -284,7 +292,8 @@ class IndexClaim extends ApiRest * @DataTime: 2022-08-16 17:53 * @功能说明:认养拼团详情 */ - public function claimCollageInfo(){ + public function claimCollageInfo() + { $input = $this->_param; @@ -294,16 +303,16 @@ class IndexClaim extends ApiRest $order_model = new ClaimOrder(); - $data = $collage_model->dataInfo(['id'=>$input['id']]); + $data = $collage_model->dataInfo(['id' => $input['id']]); - if(empty($data)){ + if (empty($data)) { $this->errorMsg('拼团未找到'); } - $data['user_list'] = $join_model->collageUserAvatar($input['id'],5); + $data['user_list'] = $join_model->collageUserAvatar($input['id'], 5); - $claim = $this->model->dataInfo(['id'=>$data['claim_id']]); + $claim = $this->model->dataInfo(['id' => $data['claim_id']]); $data['claim_title'] = $claim['title']; @@ -311,28 +320,24 @@ class IndexClaim extends ApiRest $data['claim_price'] = $claim['price']; - $data['can_start'] = $collage_model->startAtvCheck($this->getUserId(),$data['atv_id']); + $data['can_start'] = $collage_model->startAtvCheck($this->getUserId(), $data['atv_id']); //是否还能发起该活动其他的拼团 - $data['can_start'] = !empty($data['can_start']['code'])?0:1; + $data['can_start'] = !empty($data['can_start']['code']) ? 0 : 1; //是否能参与拼团 - $data['can_join'] = $join_model->collageCanJoin($this->getUserId(),$data['id']); + $data['can_join'] = $join_model->collageCanJoin($this->getUserId(), $data['id']); return $this->success($data); } - - - - - /** * @author chenniang * @DataTime: 2022-01-10 10:05 * @功能说明:下单页信息 */ - public function claimPayOrderInfo(){ + public function claimPayOrderInfo() + { $input = $this->_param; @@ -340,36 +345,36 @@ class IndexClaim extends ApiRest $data = $order_model->payOrderInfo($input); - if(!empty($data['code'])){ + if (!empty($data['code'])) { $this->errorMsg($data['msg']); } $farmer_model = new Farmer(); - $arr['farmer_info'] = $farmer_model->dataInfo(['id'=>$data['farmer_id']]); + $arr['farmer_info'] = $farmer_model->dataInfo(['id' => $data['farmer_id']]); - $arr['claim_info'] = $data; + $arr['claim_info'] = $data; - $address_model = new Address(); + $address_model = new Address(); - if(!empty($input['address_id'])){ + if (!empty($input['address_id'])) { - $arr['address'] = $address_model->dataInfo(['id'=>$input['address_id']]); + $arr['address'] = $address_model->dataInfo(['id' => $input['address_id']]); - }else{ + } else { - $arr['address'] = $address_model->dataInfo(['user_id'=>$this->getUserId(),'status'=>1]); + $arr['address'] = $address_model->dataInfo(['user_id' => $this->getUserId(), 'status' => 1]); } - $coupon_modle = new Coupon(); + $coupon_modle = new Coupon(); - $coupon_record_model = new CouponRecord(); + $coupon_record_model = new CouponRecord(); //可用优惠券数量 - $canUseCoupon = $coupon_modle->canUseCoupon($this->getUserId(),$data['pay_price'],3); + $canUseCoupon = $coupon_modle->canUseCoupon($this->getUserId(), $data['pay_price'], 3); - $arr['canUseCoupon'] = $coupon_record_model->where('id','in',$canUseCoupon)->sum('num'); + $arr['canUseCoupon'] = $coupon_record_model->where('id', 'in', $canUseCoupon)->sum('num'); $arr['pay_price'] = $data['pay_price']; @@ -387,15 +392,16 @@ class IndexClaim extends ApiRest * @DataTime: 2021-12-16 10:57 * @功能说明:认养下单 */ - public function claimPayOrder(){ + public function claimPayOrder() + { $input = $this->_input; $order_model = new ClaimOrder(); - $data = $order_model->payOrderInfo($input,1); + $data = $order_model->payOrderInfo($input, 1); - if(!empty($data['code'])){ + if (!empty($data['code'])) { $this->errorMsg($data['msg']); } @@ -404,73 +410,73 @@ class IndexClaim extends ApiRest $order_insert = [ - 'uniacid' => $this->_uniacid, + 'uniacid' => $this->_uniacid, - 'pay_type' => 1, + 'pay_type' => 1, - 'order_code' => orderCode(), + 'order_code' => orderCode(), - 'claim_code' => short_orderCode(), + 'claim_code' => short_orderCode(), - 'user_id' => $this->getUserId(), + 'user_id' => $this->getUserId(), - 'pay_price' => round($data['pay_price'],2), + 'pay_price' => round($data['pay_price'], 2), - 'get_integral' => round($data['pay_price'],2), + 'get_integral' => round($data['pay_price'], 2), - 'init_price' => round($data['init_price'],2), + 'init_price' => round($data['init_price'], 2), - 'balance' => $input['pay_model']==2?round($data['pay_price'],2):0, + 'balance' => $input['pay_model'] == 2 ? round($data['pay_price'], 2) : 0, - 'goods_id' => $data['id'], + 'goods_id' => $data['id'], - 'goods_name' => $data['title'], + 'goods_name' => $data['title'], - 'goods_cover' => $data['cover'], + 'goods_cover' => $data['cover'], - 'goods_price' => $data['price'], + 'goods_price' => $data['price'], - 'breed' => $data['breed'], + 'breed' => $data['breed'], - 'cycle' => $data['cycle'], + 'cycle' => $data['cycle'], - 'start_time' => $data['start_time'], + 'start_time' => $data['start_time'], - 'end_time' => $data['end_time'], + 'end_time' => $data['end_time'], 'harvest_text' => $data['harvest_text'], - 'harvest_cover'=> $data['harvest_cover'], + 'harvest_cover' => $data['harvest_cover'], - 'name' => $input['claim_name'], + 'name' => $input['claim_name'], - 'send_type' => $input['send_type'], + 'send_type' => $input['send_type'], - 'num' => $input['num'], + 'num' => $input['num'], - 'text' => $input['text'], + 'text' => $input['text'], - 'claim_id' => $data['id'], + 'claim_id' => $data['id'], - 'farmer_id' => $data['farmer_id'], + 'farmer_id' => $data['farmer_id'], - 'source_id' => $data['source_id'], + 'source_id' => $data['source_id'], - 'send_cycle' => $data['send_cycle'], + 'send_cycle' => $data['send_cycle'], - 'send_times' => $data['send_times'], + 'send_times' => $data['send_times'], - 'unit' => $data['unit'], - // - 'over_time' => time()+$this->_config['over_time']*60, + 'unit' => $data['unit'], + // + 'over_time' => time() + $this->_config['over_time'] * 60, - 'pay_model' => $input['pay_model'], + 'pay_model' => $input['pay_model'], - 'coupon_id' => $data['coupon_id'], + 'coupon_id' => $data['coupon_id'], - 'discount_price'=> $data['coupon_discount'], + 'discount_price' => $data['coupon_discount'], - 'is_collage' => !empty($input['collage_start_id'])||!empty($input['collage_join_id'])?1:0, + 'is_collage' => !empty($input['collage_start_id']) || !empty($input['collage_join_id']) ? 1 : 0, ]; @@ -480,7 +486,7 @@ class IndexClaim extends ApiRest $res = $order_model->dataAdd($order_insert); - if($res==0){ + if ($res == 0) { Db::rollback(); @@ -494,9 +500,9 @@ class IndexClaim extends ApiRest $input['uniacid'] = $this->_uniacid; - $res = $address_model->orderAddressAdd($input['address_id'],$order_id,$input['send_type'],2,$input); + $res = $address_model->orderAddressAdd($input['address_id'], $order_id, $input['send_type'], 2, $input); - if($res==0){ + if ($res == 0) { Db::rollback(); @@ -506,17 +512,17 @@ class IndexClaim extends ApiRest //加销量减库存 $update = [ - 'stock' => $data['stock'] -$input['num'], + 'stock' => $data['stock'] - $input['num'], - 'sale_num' => $data['sale_num']+$input['num'], + 'sale_num' => $data['sale_num'] + $input['num'], - 'lock' => $data['lock']+1 + 'lock' => $data['lock'] + 1 ]; - $res = $this->model->where(['id'=>$data['id'],'lock'=>$data['lock']])->update($update); + $res = $this->model->where(['id' => $data['id'], 'lock' => $data['lock']])->update($update); - if($res==0){ + if ($res == 0) { Db::rollback(); @@ -524,23 +530,23 @@ class IndexClaim extends ApiRest } //使用优惠券 - if(!empty($data['coupon_id'])){ + if (!empty($data['coupon_id'])) { $coupon_record_model = new CouponRecord(); - $coupon_record_model->couponUse($data['coupon_id'],$order_id,3); + $coupon_record_model->couponUse($data['coupon_id'], $order_id, 3); } $is_start = 0; //发起拼团 - if(!empty($data['collage_start_data'])){ + if (!empty($data['collage_start_data'])) { $start_model = new CollageStart(); - $data['collage_join_data'] = $start_model->startCollage($order_insert,$data['collage_start_data']); + $data['collage_join_data'] = $start_model->startCollage($order_insert, $data['collage_start_data']); - if(!empty($data['collage_join_data']['code'])){ + if (!empty($data['collage_join_data']['code'])) { Db::rollback(); @@ -551,13 +557,13 @@ class IndexClaim extends ApiRest } //参与拼团 - if(!empty($data['collage_join_data'])){ + if (!empty($data['collage_join_data'])) { $join_model = new CollageJoin(); - $res = $join_model->joinCollage($order_insert,$data['collage_join_data'],$is_start); + $res = $join_model->joinCollage($order_insert, $data['collage_join_data'], $is_start); - if(!empty($res['code'])){ + if (!empty($res['code'])) { Db::rollback(); @@ -568,46 +574,46 @@ class IndexClaim extends ApiRest Db::commit(); //如果是0元 - if($order_insert['pay_price']<=0){ + if ($order_insert['pay_price'] <= 0) { - $order_model->orderResult($order_insert['order_code'],$order_insert['order_code']); + $order_model->orderResult($order_insert['order_code'], $order_insert['order_code']); return $this->success(true); } //余额支付 - if($input['pay_model']==2){ + if ($input['pay_model'] == 2) { $user_model = new \app\farm\model\User(); - $user_balance= $user_model->where(['id'=>$this->getUserId()])->value('balance'); + $user_balance = $user_model->where(['id' => $this->getUserId()])->value('balance'); - if($user_balance<$order_insert['pay_price']){ + if ($user_balance < $order_insert['pay_price']) { $this->errorMsg('余额不足'); } - $order_model->orderResult($order_insert['order_code'],$order_insert['order_code']); + $order_model->orderResult($order_insert['order_code'], $order_insert['order_code']); return $this->success(true); - }elseif ($input['pay_model']==3){ + } elseif ($input['pay_model'] == 3) { $pay_model = new PayModel($this->payConfig()); - $jsApiParameters = $pay_model->aliPay($order_insert['order_code'],$order_insert['pay_price'],'认养商品'); + $jsApiParameters = $pay_model->aliPay($order_insert['order_code'], $order_insert['pay_price'], '认养商品'); - $arr['pay_list']= $jsApiParameters; + $arr['pay_list'] = $jsApiParameters; - $arr['order_code']= $order_insert['order_code']; + $arr['order_code'] = $order_insert['order_code']; - }else{ + } else { //微信支付 $pay_controller = new \app\shop\controller\IndexWxPay($this->app); //支付 - $jsApiParameters= $pay_controller->createWeixinPay($this->payConfig(),$this->getUserInfo()['openid'],$this->_uniacid,"认养订单",['type' => 'Claim' , 'out_trade_no' => $order_insert['order_code']],$order_insert['pay_price']); + $jsApiParameters = $pay_controller->createWeixinPay($this->payConfig(), $this->getUserInfo()['openid'], $this->_uniacid, "认养订单", ['type' => 'Claim', 'out_trade_no' => $order_insert['order_code']], $order_insert['pay_price']); - $arr['pay_list']= $jsApiParameters; + $arr['pay_list'] = $jsApiParameters; } @@ -621,52 +627,53 @@ class IndexClaim extends ApiRest * @DataTime: 2021-12-20 10:17 * @功能说明:认养重新下单 */ - public function claimRePayOrder(){ + public function claimRePayOrder() + { $input = $this->_input; $order_model = new ClaimOrder(); - $order_insert = $order_model->dataInfo(['id'=>$input['id']]); + $order_insert = $order_model->dataInfo(['id' => $input['id']]); - if($order_insert['pay_type']!=1){ + if ($order_insert['pay_type'] != 1) { $this->errorMsg('订单状态错误'); } //余额支付 - if($order_insert['pay_model']==2){ + if ($order_insert['pay_model'] == 2) { $user_model = new \app\farm\model\User(); - $user_balance= $user_model->where(['id'=>$this->getUserId()])->value('balance'); + $user_balance = $user_model->where(['id' => $this->getUserId()])->value('balance'); - if($user_balance<$order_insert['pay_price']){ + if ($user_balance < $order_insert['pay_price']) { $this->errorMsg('余额不足'); } - $order_model->orderResult($order_insert['order_code'],$order_insert['order_code']); + $order_model->orderResult($order_insert['order_code'], $order_insert['order_code']); return $this->success(true); - }elseif ($order_insert['pay_model']==3){ + } elseif ($order_insert['pay_model'] == 3) { $pay_model = new PayModel($this->payConfig()); - $jsApiParameters = $pay_model->aliPay($order_insert['order_code'],$order_insert['pay_price'],'认养商品'); + $jsApiParameters = $pay_model->aliPay($order_insert['order_code'], $order_insert['pay_price'], '认养商品'); - $arr['pay_list'] = $jsApiParameters; + $arr['pay_list'] = $jsApiParameters; - $arr['order_code']= $order_insert['order_code']; + $arr['order_code'] = $order_insert['order_code']; - }else{ + } else { //微信支付 $pay_controller = new \app\shop\controller\IndexWxPay($this->app); //支付 - $jsApiParameters= $pay_controller->createWeixinPay($this->payConfig(),$this->getUserInfo()['openid'],$this->_uniacid,"认养订单",['type' => 'Claim' , 'out_trade_no' => $order_insert['order_code']],$order_insert['pay_price']); + $jsApiParameters = $pay_controller->createWeixinPay($this->payConfig(), $this->getUserInfo()['openid'], $this->_uniacid, "认养订单", ['type' => 'Claim', 'out_trade_no' => $order_insert['order_code']], $order_insert['pay_price']); - $arr['pay_list']= $jsApiParameters; + $arr['pay_list'] = $jsApiParameters; } return $this->success($arr); @@ -679,65 +686,66 @@ class IndexClaim extends ApiRest * @DataTime: 2021-12-28 11:26 * @功能说明:用户下单列表 */ - public function orderList(){ + public function orderList() + { $input = $this->_param; - $dis[] = ['uniacid','=',$this->_uniacid]; + $dis[] = ['uniacid', '=', $this->_uniacid]; - $dis[] = ['user_id','=',$this->getUserId()]; + $dis[] = ['user_id', '=', $this->getUserId()]; - if(!empty($input['pay_type'])){ + if (!empty($input['pay_type'])) { - $dis[] = ['pay_type','=',$input['pay_type']]; + $dis[] = ['pay_type', '=', $input['pay_type']]; } - if(!empty($input['order_code'])){ + if (!empty($input['order_code'])) { - $dis[] = ['order_code','like','%'.$input['order_code'].'%']; + $dis[] = ['order_code', 'like', '%' . $input['order_code'] . '%']; } - $order_model = new ClaimOrder(); + $order_model = new ClaimOrder(); $farmer_model = new Farmer(); - $eva_model = new Evaluate(); + $eva_model = new Evaluate(); $data = $order_model->dataList($dis); - if(!empty($data['data'])){ + if (!empty($data['data'])) { - foreach ($data['data'] as &$v){ + foreach ($data['data'] as &$v) { - $v['farmer_info'] = $farmer_model->dataInfo(['id'=>$v['farmer_id']],'title'); + $v['farmer_info'] = $farmer_model->dataInfo(['id' => $v['farmer_id']], 'title'); $dis = [ 'user_id' => $this->getUserId(), - 'order_id'=> $v['id'], + 'order_id' => $v['id'], - 'type' => 1 + 'type' => 1 ]; - $have_eva = $eva_model->where($dis)->where('status','>',-1)->find(); + $have_eva = $eva_model->where($dis)->where('status', '>', -1)->find(); //是否已经评价 - $v['have_eva'] = !empty($have_eva)?1:0; + $v['have_eva'] = !empty($have_eva) ? 1 : 0; } } - $arr = [2=>'claim_count',3=>'send_count']; + $arr = [2 => 'claim_count', 3 => 'send_count']; - foreach ($arr as $key => $value){ + foreach ($arr as $key => $value) { $where = [ 'user_id' => $this->getUserId(), - 'pay_type'=> $key + 'pay_type' => $key ]; $data['count'][$value] = $order_model->where($where)->count(); @@ -754,7 +762,8 @@ class IndexClaim extends ApiRest * @DataTime: 2021-12-28 11:52 * @功能说明:用户下单详情 */ - public function orderInfo(){ + public function orderInfo() + { $input = $this->_param; @@ -773,19 +782,19 @@ class IndexClaim extends ApiRest $data['over_time'] -= time(); - $data['create_time'] = date('Y-m-d H:i:s',$data['create_time']); + $data['create_time'] = date('Y-m-d H:i:s', $data['create_time']); - $data['pay_time'] = $data['pay_time']>0?date('Y-m-d H:i:s',$data['pay_time']):0; + $data['pay_time'] = $data['pay_time'] > 0 ? date('Y-m-d H:i:s', $data['pay_time']) : 0; - $data['cancel_time'] = $data['cancel_time']>0?date('Y-m-d H:i:s',$data['cancel_time']):0; + $data['cancel_time'] = $data['cancel_time'] > 0 ? date('Y-m-d H:i:s', $data['cancel_time']) : 0; - $data['time_text'] = date('Y-m-d',$data['start_time']).'~'.date('Y-m-d',$data['end_time']); + $data['time_text'] = date('Y-m-d', $data['start_time']) . '~' . date('Y-m-d', $data['end_time']); //农场信息 - $data['farmer_info'] = $farmer_model->dataInfo(['id'=>$data['farmer_id']]); + $data['farmer_info'] = $farmer_model->dataInfo(['id' => $data['farmer_id']]); //溯源信息 - $data['source'] = $source_model->dataInfo(['id'=>$data['source_id']]); + $data['source'] = $source_model->dataInfo(['id' => $data['source_id']]); //是否可以配送 - $data['can_send'] = $data['pay_type']>1&&$data['end_time'] 1 && $data['end_time'] < time() ? 1 : 0; $eva_model = new Evaluate(); @@ -793,50 +802,50 @@ class IndexClaim extends ApiRest 'user_id' => $this->getUserId(), - 'order_id'=> $input['id'], + 'order_id' => $input['id'], - 'type' => 1 + 'type' => 1 ]; - $have_eva = $eva_model->where($dis)->where('status','>',-1)->find(); + $have_eva = $eva_model->where($dis)->where('status', '>', -1)->find(); //是否已经评价 - $data['have_eva'] = !empty($have_eva)?1:0; + $data['have_eva'] = !empty($have_eva) ? 1 : 0; - $address_order_model = new OrderAddress(); + $address_order_model = new OrderAddress(); - $address_model = new Address(); + $address_model = new Address(); - $data['address_info'] = $address_order_model->dataInfo(['order_id'=>$input['id'],'type'=>2]); + $data['address_info'] = $address_order_model->dataInfo(['order_id' => $input['id'], 'type' => 2]); - if(!empty($data['address_info']['address_id'])){ + if (!empty($data['address_info']['address_id'])) { - $data['address_info'] = $address_model->dataInfo(['id'=>$data['address_info']['address_id']]); + $data['address_info'] = $address_model->dataInfo(['id' => $data['address_info']['address_id']]); } $mac_model = new Machine(); //仪器详情 - $data['machine_info'] = $mac_model->getDataInfo($data['claim_id'],2); + $data['machine_info'] = $mac_model->getDataInfo($data['claim_id'], 2); - $send_tmpl_id = $this->model->where(['id'=>$data['claim_id']])->value('send_tmpl_id'); + $send_tmpl_id = $this->model->where(['id' => $data['claim_id']])->value('send_tmpl_id'); $freightTemplate_model = new FreightTemplate(); //配送运费模版 - $data['send_tmpl'] = $freightTemplate_model->dataInfo(['id'=>$send_tmpl_id]); + $data['send_tmpl'] = $freightTemplate_model->dataInfo(['id' => $send_tmpl_id]); - if($data['is_collage']==1){ + if ($data['is_collage'] == 1) { $collage_model = new CollageJoin(); - $collage_info = $collage_model->dataInfo(['order_id'=>$input['id']]); + $collage_info = $collage_model->dataInfo(['order_id' => $input['id']]); - if(!empty($collage_info)){ + if (!empty($collage_info)) { $data['collage_status'] = $collage_info['status']; - $data['collage_discount_price'] = $data['init_price']-$collage_info['price']; + $data['collage_discount_price'] = $data['init_price'] - $collage_info['price']; - $data['collage_discount_price'] = $data['collage_discount_price']>0?$data['collage_discount_price']:0; + $data['collage_discount_price'] = $data['collage_discount_price'] > 0 ? $data['collage_discount_price'] : 0; } @@ -852,7 +861,8 @@ class IndexClaim extends ApiRest * @DataTime: 2022-01-10 13:42 * @功能说明: */ - public function cancelOrder(){ + public function cancelOrder() + { $input = $this->_input; @@ -865,14 +875,14 @@ class IndexClaim extends ApiRest $order = $order_model->dataInfo($dis); - if($order['pay_type']!=1){ + if ($order['pay_type'] != 1) { $this->errorMsg('订单状态错误'); } $res = $order_model->cancelOrder($order); - if(!empty($res['code'])){ + if (!empty($res['code'])) { $this->errorMsg($res['msg']); } @@ -882,55 +892,55 @@ class IndexClaim extends ApiRest } - /** * @author chenniang * @DataTime: 2021-12-29 10:29 * @功能说明:养殖管理 */ - public function breedList(){ + public function breedList() + { $input = $this->_param; $breed_model = new Breed(); - $car_model = new Car(); + $car_model = new Car(); - $dis[] = ['a.uniacid','=',$this->_uniacid]; + $dis[] = ['a.uniacid', '=', $this->_uniacid]; - $dis[] = ['a.status','=',1]; + $dis[] = ['a.status', '=', 1]; - $dis[] = ['b.type','=',5]; + $dis[] = ['b.type', '=', 5]; - if(!empty($input['title'])){ + if (!empty($input['title'])) { - $dis[] = ['a.title','like','%'.$input['title'].'%']; + $dis[] = ['a.title', 'like', '%' . $input['title'] . '%']; } - $dis[] = ['b.store_id','=',$input['farmer_id']]; + $dis[] = ['b.store_id', '=', $input['farmer_id']]; $data = $breed_model->indexDataList($dis); $dis = [ - 'user_id'=>$this->getUserId(), + 'user_id' => $this->getUserId(), - 'type' =>1, + 'type' => 1, - 'status' =>1, + 'status' => 1, 'farmer_id' => $input['farmer_id'] ]; - $car = $breed_model->getCarList($this->getUserId(),$input['farmer_id']); + $car = $breed_model->getCarList($this->getUserId(), $input['farmer_id']); $data['count'] = $car['goods_num']; $data['total_price'] = $car['price']; - if(!empty($data['data'])){ + if (!empty($data['data'])) { - foreach ($data['data'] as &$v){ + foreach ($data['data'] as &$v) { $dis['goods_id'] = $v['id']; @@ -951,7 +961,8 @@ class IndexClaim extends ApiRest * @DataTime: 2021-12-29 17:02 * @功能说明:养殖订单 */ - public function breedOrder(){ + public function breedOrder() + { $input = $this->_input; @@ -961,47 +972,47 @@ class IndexClaim extends ApiRest $claim_order_model = new ClaimOrder(); - $framer_model= new Farmer(); + $framer_model = new Farmer(); - $claim_order = $claim_order_model->dataInfo(['id'=>$input['claim_order_id']]); + $claim_order = $claim_order_model->dataInfo(['id' => $input['claim_order_id']]); - $pay_order = $breed_model->getCarList($this->getUserId(),$claim_order['farmer_id']); + $pay_order = $breed_model->getCarList($this->getUserId(), $claim_order['farmer_id']); - $farmer = $framer_model->dataInfo(['id'=>$claim_order['farmer_id'],'status'=>2]); + $farmer = $framer_model->dataInfo(['id' => $claim_order['farmer_id'], 'status' => 2]); - if(empty($farmer)){ + if (empty($farmer)) { $this->errorMsg('该农场主已被取消农场身份,无法下单'); } $order_insert = [ - 'uniacid' => $this->_uniacid, + 'uniacid' => $this->_uniacid, - 'order_code' => orderCode(), + 'order_code' => orderCode(), - 'user_id' => $this->getUserId(), + 'user_id' => $this->getUserId(), 'claim_order_id' => $input['claim_order_id'], - 'farmer_id' => $claim_order['farmer_id'], + 'farmer_id' => $claim_order['farmer_id'], - 'pay_price' => $pay_order['price'], + 'pay_price' => $pay_order['price'], - 'get_integral' => $pay_order['price'], + 'get_integral' => $pay_order['price'], - 'text' => $input['text'], + 'text' => $input['text'], - 'pay_model' => $input['pay_model'], + 'pay_model' => $input['pay_model'], - 'balance' => $input['pay_model']==2?round($pay_order['price'],2):0, + 'balance' => $input['pay_model'] == 2 ? round($pay_order['price'], 2) : 0, ]; Db::startTrans(); $res = $order_model->dataAdd($order_insert); - if($res==0){ + if ($res == 0) { Db::rollback(); @@ -1013,9 +1024,9 @@ class IndexClaim extends ApiRest $order_goods_model = new BreedOrderGoods(); - $res = $order_goods_model->orderAdd($pay_order['car_list'],$order_id); + $res = $order_goods_model->orderAdd($pay_order['car_list'], $order_id); - if($res==0){ + if ($res == 0) { Db::rollback(); @@ -1029,56 +1040,56 @@ class IndexClaim extends ApiRest 'farmer_id' => $claim_order['farmer_id'], - 'user_id' => $this->getUserId(), + 'user_id' => $this->getUserId(), - 'type' => 1, + 'type' => 1, - 'status' => 1 + 'status' => 1 ]; $car_model->where($dis)->delete(); Db::commit(); //如果是0元 - if($order_insert['pay_price']<=0){ + if ($order_insert['pay_price'] <= 0) { - $order_model->orderResult($order_insert['order_code'],$order_insert['order_code']); + $order_model->orderResult($order_insert['order_code'], $order_insert['order_code']); return $this->success(true); } //余额支付 - if($input['pay_model']==2){ + if ($input['pay_model'] == 2) { $user_model = new \app\farm\model\User(); - $user_balance= $user_model->where(['id'=>$this->getUserId()])->value('balance'); + $user_balance = $user_model->where(['id' => $this->getUserId()])->value('balance'); - if($user_balance<$order_insert['pay_price']){ + if ($user_balance < $order_insert['pay_price']) { $this->errorMsg('余额不足'); } - $order_model->orderResult($order_insert['order_code'],$order_insert['order_code']); + $order_model->orderResult($order_insert['order_code'], $order_insert['order_code']); return $this->success(true); - }elseif ($input['pay_model']==3){ + } elseif ($input['pay_model'] == 3) { $pay_model = new PayModel($this->payConfig()); - $jsApiParameters = $pay_model->aliPay($order_insert['order_code'],$order_insert['pay_price'],'养殖商品'); + $jsApiParameters = $pay_model->aliPay($order_insert['order_code'], $order_insert['pay_price'], '养殖商品'); - $arr['pay_list']= $jsApiParameters; + $arr['pay_list'] = $jsApiParameters; - $arr['order_code']= $order_insert['order_code']; + $arr['order_code'] = $order_insert['order_code']; - }else{ + } else { //微信支付 $pay_controller = new \app\shop\controller\IndexWxPay($this->app); //支付 - $jsApiParameters= $pay_controller->createWeixinPay($this->payConfig(),$this->getUserInfo()['openid'],$this->_uniacid,"养殖订单",['type' => 'Breed' , 'out_trade_no' => $order_insert['order_code']],$order_insert['pay_price']); + $jsApiParameters = $pay_controller->createWeixinPay($this->payConfig(), $this->getUserInfo()['openid'], $this->_uniacid, "养殖订单", ['type' => 'Breed', 'out_trade_no' => $order_insert['order_code']], $order_insert['pay_price']); - $arr['pay_list']= $jsApiParameters; + $arr['pay_list'] = $jsApiParameters; } return $this->success($arr); @@ -1091,13 +1102,14 @@ class IndexClaim extends ApiRest * @DataTime: 2022-01-10 15:52 * @功能说明:养殖订单列表 */ - public function breedOrderList(){ + public function breedOrderList() + { $input = $this->_param; - $dis[] = ['pay_type','>',1]; + $dis[] = ['pay_type', '>', 1]; - $dis[] = ['claim_order_id','=',$input['claim_order_id']]; + $dis[] = ['claim_order_id', '=', $input['claim_order_id']]; $order_model = new BreedOrder(); @@ -1113,19 +1125,20 @@ class IndexClaim extends ApiRest * @DataTime: 2022-01-10 16:07 * @功能说明:养殖订单详情 */ - public function breedOrderInfo(){ + public function breedOrderInfo() + { $input = $this->_param; - $dis[] = ['id','=',$input['id']]; + $dis[] = ['id', '=', $input['id']]; $order_model = new BreedOrder(); $data = $order_model->dataInfo($dis); - $data['create_time'] = date('Y-m-d H:i:s',$data['create_time']); + $data['create_time'] = date('Y-m-d H:i:s', $data['create_time']); - $data['pay_time'] = !empty($data['pay_time'])?date('Y-m-d H:i:s',$data['pay_time']):0; + $data['pay_time'] = !empty($data['pay_time']) ? date('Y-m-d H:i:s', $data['pay_time']) : 0; return $this->success($data); @@ -1138,7 +1151,8 @@ class IndexClaim extends ApiRest * @DataTime: 2022-02-08 17:14 * @功能说明:配送订单列表 */ - public function userSendOrderList(){ + public function userSendOrderList() + { $input = $this->_param; @@ -1156,41 +1170,42 @@ class IndexClaim extends ApiRest * @DataTime: 2022-02-08 13:53 * @功能说明:申请认养订单发货 */ - public function sendOrderApply(){ + public function sendOrderApply() + { $input = $this->_input; $order_model = new ClaimOrder(); - $farmer_model= new Farmer(); + $farmer_model = new Farmer(); - $config_model= new Config(); + $config_model = new Config(); - $address_model = new Address(); + $address_model = new Address(); $send_order_model = new SendOrder(); - $order = $order_model->dataInfo(['id'=>$input['order_id']]); + $order = $order_model->dataInfo(['id' => $input['order_id']]); - if($order['pay_type']<2){ + if ($order['pay_type'] < 2) { $this->errorMsg('订单未支付'); } //已经申请的配送次数 - $send_count = $send_order_model->where(['order_id'=>$input['order_id'],'type'=>1])->where('pay_type','>',1)->count(); + $send_count = $send_order_model->where(['order_id' => $input['order_id'], 'type' => 1])->where('pay_type', '>', 1)->count(); - if($send_count>=$order['send_times']){ + if ($send_count >= $order['send_times']) { $this->errorMsg('已经到达配送次数上线'); } - $times = $send_order_model->where(['order_id'=>$input['order_id'],'type'=>1])->where('pay_time','>',0)->count(); + $times = $send_order_model->where(['order_id' => $input['order_id'], 'type' => 1])->where('pay_time', '>', 0)->count(); - $farmer= $farmer_model->dataInfo(['id'=>$order['farmer_id'],'status'=>2]); + $farmer = $farmer_model->dataInfo(['id' => $order['farmer_id'], 'status' => 2]); - if(empty($farmer)){ + if (empty($farmer)) { $this->errorMsg('农场主未找到'); } @@ -1198,19 +1213,19 @@ class IndexClaim extends ApiRest $send_price = $distance = 0; //快递 - if($input['send_type']==2){ + if ($input['send_type'] == 2) { - $address = $address_model->dataInfo(['id'=>$input['address_id']]); + $address = $address_model->dataInfo(['id' => $input['address_id']]); - if(empty($address)){ + if (empty($address)) { $this->errorMsg('地址信息未找到'); } - $cliam_info = $this->model->dataInfo(['id'=>$order['claim_id']]); + $cliam_info = $this->model->dataInfo(['id' => $order['claim_id']]); - if(empty($cliam_info)){ + if (empty($cliam_info)) { $this->errorMsg('认养信息被删除'); @@ -1220,14 +1235,14 @@ class IndexClaim extends ApiRest 'send_tmpl_id' => $cliam_info['send_tmpl_id'], - 'goods_num' => $input['send_num'], + 'goods_num' => $input['send_num'], 'total_weight' => $input['send_num'], ]; - $send_data = $config_model->getGoodsSendPrice($input['address_id'],$goods_info,2,2); + $send_data = $config_model->getGoodsSendPrice($input['address_id'], $goods_info, 2, 2); - if(!empty($send_data['code'])){ + if (!empty($send_data['code'])) { $this->errorMsg($send_data['msg']); } @@ -1236,110 +1251,110 @@ class IndexClaim extends ApiRest $send_tmpl_type = $send_data['type']; - }else{ + } else { $address['user_name'] = $input['user_name']; - $address['mobile'] = $input['mobile']; + $address['mobile'] = $input['mobile']; } $order_insert = [ - 'uniacid' => $this->_uniacid, + 'uniacid' => $this->_uniacid, - 'order_id' => $input['order_id'], + 'order_id' => $input['order_id'], - 'pay_model' => $input['pay_model'], + 'pay_model' => $input['pay_model'], - 'user_id' => $order['user_id'], + 'user_id' => $order['user_id'], - 'farmer_id' => $order['farmer_id'], + 'farmer_id' => $order['farmer_id'], - 'pay_price' => $send_price, + 'pay_price' => $send_price, 'get_integral' => $send_price, 'order_code' => orderCode(), - 'text' => $input['text'], + 'text' => $input['text'], // - 'over_time' => time()+$this->_config['over_time']*60, + 'over_time' => time() + $this->_config['over_time'] * 60, - 'type' => 1, + 'type' => 1, 'start_time' => $input['start_time'], - 'end_time' => $input['end_time'], + 'end_time' => $input['end_time'], - 'times' => $times+1, + 'times' => $times + 1, - 'send_type' => $input['send_type'], + 'send_type' => $input['send_type'], - 'address' => $input['send_type']==2?$address['address'].$address['address_info']:'', + 'address' => $input['send_type'] == 2 ? $address['address'] . $address['address_info'] : '', - 'user_name' => $address['user_name'], + 'user_name' => $address['user_name'], - 'mobile' => $address['mobile'], + 'mobile' => $address['mobile'], - 'lng' => $input['send_type']==2?$address['lng']:'', + 'lng' => $input['send_type'] == 2 ? $address['lng'] : '', - 'lat' => $input['send_type']==2?$address['lat']:'', + 'lat' => $input['send_type'] == 2 ? $address['lat'] : '', - 'balance' => $input['pay_model']==2?$send_price:0, + 'balance' => $input['pay_model'] == 2 ? $send_price : 0, - 'goods_num' => isset($send_tmpl_type)&&$send_tmpl_type==1?$input['send_num']:0, + 'goods_num' => isset($send_tmpl_type) && $send_tmpl_type == 1 ? $input['send_num'] : 0, - 'weight' => isset($send_tmpl_type)&&$send_tmpl_type==2?$input['send_num']:0, + 'weight' => isset($send_tmpl_type) && $send_tmpl_type == 2 ? $input['send_num'] : 0, ]; $res = $send_order_model->dataAdd($order_insert); - if($res==0){ + if ($res == 0) { $this->errorMsg('申请配送失败'); } //如果是0元 - if($order_insert['pay_price']<=0){ + if ($order_insert['pay_price'] <= 0) { - $send_order_model->orderResult($order_insert['order_code'],$order_insert['order_code']); + $send_order_model->orderResult($order_insert['order_code'], $order_insert['order_code']); return $this->success(true); } //余额支付 - if($input['pay_model']==2){ + if ($input['pay_model'] == 2) { $user_model = new \app\farm\model\User(); - $user_balance= $user_model->where(['id'=>$this->getUserId()])->value('balance'); + $user_balance = $user_model->where(['id' => $this->getUserId()])->value('balance'); - if($user_balance<$order_insert['pay_price']){ + if ($user_balance < $order_insert['pay_price']) { $this->errorMsg('余额不足'); } - $send_order_model->orderResult($order_insert['order_code'],$order_insert['order_code']); + $send_order_model->orderResult($order_insert['order_code'], $order_insert['order_code']); return $this->success(true); - }elseif ($input['pay_model']==3){ + } elseif ($input['pay_model'] == 3) { $pay_model = new PayModel($this->payConfig()); - $jsApiParameters = $pay_model->aliPay($order_insert['order_code'],$order_insert['pay_price'],'配送订单'); + $jsApiParameters = $pay_model->aliPay($order_insert['order_code'], $order_insert['pay_price'], '配送订单'); - $arr['pay_list']= $jsApiParameters; + $arr['pay_list'] = $jsApiParameters; - $arr['order_code']= $order_insert['order_code']; + $arr['order_code'] = $order_insert['order_code']; - }else{ + } else { //微信支付 $pay_controller = new \app\shop\controller\IndexWxPay($this->app); //支付 - $jsApiParameters= $pay_controller->createWeixinPay($this->payConfig(),$this->getUserInfo()['openid'],$this->_uniacid,"认养配送订单",['type' => 'ClaimSend' , 'out_trade_no' => $order_insert['order_code']],$order_insert['pay_price']); + $jsApiParameters = $pay_controller->createWeixinPay($this->payConfig(), $this->getUserInfo()['openid'], $this->_uniacid, "认养配送订单", ['type' => 'ClaimSend', 'out_trade_no' => $order_insert['order_code']], $order_insert['pay_price']); - $arr['pay_list']= $jsApiParameters; + $arr['pay_list'] = $jsApiParameters; } @@ -1353,54 +1368,55 @@ class IndexClaim extends ApiRest * @DataTime: 2022-02-08 15:23 * @功能说明:配送订单下单详情 */ - public function sendOrderPayInfo(){ + public function sendOrderPayInfo() + { - $input = $this->_param; + $input = $this->_param; $order_model = new ClaimOrder(); - $farmer_model= new Farmer(); + $farmer_model = new Farmer(); - $config_model= new Config(); + $config_model = new Config(); $address_model = new Address(); - $order = $order_model->dataInfo(['id'=>$input['order_id']]); + $order = $order_model->dataInfo(['id' => $input['order_id']]); - $farmer= $farmer_model->dataInfo(['id'=>$order['farmer_id']]); + $farmer = $farmer_model->dataInfo(['id' => $order['farmer_id']]); - if(empty($farmer)){ + if (empty($farmer)) { $this->errorMsg('农场主未找到'); } - $address = $address_model->dataInfo(['id'=>$input['address_id']]); + $address = $address_model->dataInfo(['id' => $input['address_id']]); - if(empty($address)){ + if (empty($address)) { $this->errorMsg('地址信息未找到'); } - $cliam_info = $this->model->dataInfo(['id'=>$order['claim_id']]); + $cliam_info = $this->model->dataInfo(['id' => $order['claim_id']]); $freightTemplate_model = new FreightTemplate(); - $data['send_tmpl'] = $freightTemplate_model->dataInfo(['id'=>$cliam_info['send_tmpl_id']]); + $data['send_tmpl'] = $freightTemplate_model->dataInfo(['id' => $cliam_info['send_tmpl_id']]); - if(!empty($input['send_num'])){ + if (!empty($input['send_num'])) { $goods_info = [ 'send_tmpl_id' => $cliam_info['send_tmpl_id'], - 'goods_num' => $input['send_num'], + 'goods_num' => $input['send_num'], 'total_weight' => $input['send_num'], ]; - $data['send_price'] = $config_model->getGoodsSendPrice($input['address_id'],$goods_info,2); + $data['send_price'] = $config_model->getGoodsSendPrice($input['address_id'], $goods_info, 2); - if(!empty($data['send_price']['code'])){ + if (!empty($data['send_price']['code'])) { $this->errorMsg($data['send_price']['msg']); } @@ -1416,32 +1432,33 @@ class IndexClaim extends ApiRest * @DataTime: 2022-02-08 15:10 * @功能说明:获取配送时间段 */ - public function sendTime(){ + public function sendTime() + { $config_model = new Config(); - $send_config = new SendConfig(); + $send_config = new SendConfig(); - $config = $config_model->dataInfo(['uniacid'=>$this->_uniacid]); + $config = $config_model->dataInfo(['uniacid' => $this->_uniacid]); - $config['app_day'] = $config['app_day']>30?30:$config['app_day']; + $config['app_day'] = $config['app_day'] > 30 ? 30 : $config['app_day']; $i = 0; //预约的每一天 - while ($i<$config['app_day']){ + while ($i < $config['app_day']) { - $time = time()+86400*$i; + $time = time() + 86400 * $i; - $arr['date'] = date('Y-m-d',$time); + $arr['date'] = date('Y-m-d', $time); - $arr['week'] = changeWeek(date('w',$time)); + $arr['week'] = changeWeek(date('w', $time)); $data['date'][] = $arr; $i++; } //每天时间段 - $data['time'] = $send_config->where(['uniacid'=>$this->_uniacid,'status'=>1])->select()->toArray(); + $data['time'] = $send_config->where(['uniacid' => $this->_uniacid, 'status' => 1])->select()->toArray(); return $this->success($data); @@ -1453,49 +1470,50 @@ class IndexClaim extends ApiRest * @DataTime: 2022-02-08 17:57 * @功能说明:配送订单退款 */ - public function sendOrderRefund(){ + public function sendOrderRefund() + { $input = $this->_input; $send_order_model = new SendOrder(); - $send_order = $send_order_model->dataInfo(['id'=>$input['id']]); + $send_order = $send_order_model->dataInfo(['id' => $input['id']]); - if(empty($send_order)){ + if (empty($send_order)) { $this->errorMsg('订单未找到'); } - if($send_order['pay_type']!=2){ + if ($send_order['pay_type'] != 2) { $this->errorMsg('订单状态错误'); } Db::startTrans(); - $res = $send_order_model->refundCash($send_order,$this->payConfig($this->_uniacid)); + $res = $send_order_model->refundCash($send_order, $this->payConfig($this->_uniacid)); - if(!empty($res['code'])){ + if (!empty($res['code'])) { $this->errorMsg($res['msg']); } - $send_order_model->dataUpdate(['id'=>$send_order['id']],['refund_time'=>time(),'pay_type'=>-1,'refund'=>1]); + $send_order_model->dataUpdate(['id' => $send_order['id']], ['refund_time' => time(), 'pay_type' => -1, 'refund' => 1]); //增加财务流水 $fin_water_model = new FinanceWater(); - $res = $fin_water_model->addWater($input['id'],11,1,1); + $res = $fin_water_model->addWater($input['id'], 11, 1, 1); - if($res==0){ + if ($res == 0) { Db::rollback(); $this->errorMsg('退款失败1'); } - $res = $fin_water_model->dataUpdate(['order_id'=>$send_order['id'],'type'=>10],['cash_status'=>1]); + $res = $fin_water_model->dataUpdate(['order_id' => $send_order['id'], 'type' => 10], ['cash_status' => 1]); - if($res==0){ + if ($res == 0) { Db::rollback(); @@ -1513,27 +1531,28 @@ class IndexClaim extends ApiRest * @DataTime: 2022-02-09 10:24 * @功能说明:配送订单收货 */ - public function sendOrderReceiving(){ + public function sendOrderReceiving() + { $input = $this->_input; $send_order_model = new SendOrder(); - $send_order = $send_order_model->dataInfo(['id'=>$input['id']]); + $send_order = $send_order_model->dataInfo(['id' => $input['id']]); - if(empty($send_order)){ + if (empty($send_order)) { $this->errorMsg('订单未找到'); } - if($send_order['pay_type']!=3){ + if ($send_order['pay_type'] != 3) { $this->errorMsg('订单状态错误'); } $res = $send_order_model->sendOrderReceiving($send_order); - if(!empty($res['code'])){ + if (!empty($res['code'])) { $this->errorMsg($res['msg']); } @@ -1548,29 +1567,30 @@ class IndexClaim extends ApiRest * @DataTime: 2022-02-09 14:00 * @功能说明:配送订单详情 */ - public function sendOrderInfo(){ + public function sendOrderInfo() + { $input = $this->_param; $send_order_model = new SendOrder(); - $claim_order_model= new ClaimOrder(); + $claim_order_model = new ClaimOrder(); - $send_order = $send_order_model->dataInfo(['id'=>$input['id']]); + $send_order = $send_order_model->dataInfo(['id' => $input['id']]); - $send_order['create_time'] = date('Y-m-d H:i:s',$send_order['create_time']); + $send_order['create_time'] = date('Y-m-d H:i:s', $send_order['create_time']); - $send_order['time_text'] = date('Y-m-d H:i',$send_order['start_time']).'~'.date('H:i',$send_order['end_time']); + $send_order['time_text'] = date('Y-m-d H:i', $send_order['start_time']) . '~' . date('H:i', $send_order['end_time']); - $send_order['pay_time'] = $send_order['pay_time']>0?date('Y-m-d H:i:s',$send_order['pay_time']):0; + $send_order['pay_time'] = $send_order['pay_time'] > 0 ? date('Y-m-d H:i:s', $send_order['pay_time']) : 0; - $send_order['send_time'] = $send_order['send_time']>0?date('Y-m-d H:i:s',$send_order['send_time']):0; + $send_order['send_time'] = $send_order['send_time'] > 0 ? date('Y-m-d H:i:s', $send_order['send_time']) : 0; - $send_order['receiving_time'] = $send_order['receiving_time']>0?date('Y-m-d H:i:s',$send_order['receiving_time']):0; + $send_order['receiving_time'] = $send_order['receiving_time'] > 0 ? date('Y-m-d H:i:s', $send_order['receiving_time']) : 0; - $send_order['refund_time'] = $send_order['refund_time']>0?date('Y-m-d H:i:s',$send_order['refund_time']):0; + $send_order['refund_time'] = $send_order['refund_time'] > 0 ? date('Y-m-d H:i:s', $send_order['refund_time']) : 0; - $send_order['claim_order']= $claim_order_model->dataInfo(['id'=>$send_order['order_id']]); + $send_order['claim_order'] = $claim_order_model->dataInfo(['id' => $send_order['order_id']]); return $this->success($send_order); @@ -1582,7 +1602,8 @@ class IndexClaim extends ApiRest * @DataTime: 2021-07-10 00:40 * @功能说明:可用的优惠券列表 */ - public function couponList(){ + public function couponList() + { $input = $this->_param; @@ -1590,19 +1611,19 @@ class IndexClaim extends ApiRest $coupon_record_model = new CouponRecord(); - $order_model = new ClaimOrder(); + $order_model = new ClaimOrder(); $order_info = $order_model->payOrderInfo($input); - $coupon_id = $coupon_model->canUseCoupon($this->getUserId(),$order_info['pay_price'],3); + $coupon_id = $coupon_model->canUseCoupon($this->getUserId(), $order_info['pay_price'], 3); - $data = $coupon_record_model->where('id','in',$coupon_id)->order('id desc')->paginate(10)->toArray(); + $data = $coupon_record_model->where('id', 'in', $coupon_id)->order('id desc')->paginate(10)->toArray(); - if(!empty($data['data'])){ + if (!empty($data['data'])) { - foreach ($data['data'] as &$v){ + foreach ($data['data'] as &$v) { - $v['start_time'] = date('Y.m.d H:i',$v['start_time']).' - '.date('Y.m.d H:i',$v['end_time']); + $v['start_time'] = date('Y.m.d H:i', $v['start_time']) . ' - ' . date('Y.m.d H:i', $v['end_time']); } @@ -1618,15 +1639,16 @@ class IndexClaim extends ApiRest * @DataTime: 2022-08-16 15:15 * @功能说明:用户认养拼团 */ - public function userCollageLimit(){ + public function userCollageLimit() + { $input = $this->_param; $collage_model = new CollageJoin(); - $dis[] = ['a.user_id','=',$this->getUserId()]; + $dis[] = ['a.user_id', '=', $this->getUserId()]; - $dis[] = ['a.status','=',1]; + $dis[] = ['a.status', '=', 1]; $data = $collage_model->userCollageLimit($dis); @@ -1639,21 +1661,22 @@ class IndexClaim extends ApiRest * @DataTime: 2022-08-16 15:15 * @功能说明:用户认养拼团列表 */ - public function userCollageList(){ + public function userCollageList() + { $input = $this->_param; $collage_model = new CollageJoin(); - $dis[] = ['a.user_id','=',$this->getUserId()]; + $dis[] = ['a.user_id', '=', $this->getUserId()]; - if(!empty($input['status'])&&$input['status']==2){ + if (!empty($input['status']) && $input['status'] == 2) { - $dis[] = ['a.status','=',$input['status']]; + $dis[] = ['a.status', '=', $input['status']]; - }else{ + } else { - $dis[] = ['a.status','in',[1,3]]; + $dis[] = ['a.status', 'in', [1, 3]]; } $data = $collage_model->userCollagePage($dis); @@ -1669,33 +1692,34 @@ class IndexClaim extends ApiRest * @DataTime: 2022-08-16 16:12 * @功能说明:拼团商品列表 */ - public function collageList(){ + public function collageList() + { $collage_model = new ClaimCollage(); - $dis[] = ['a.uniacid','=',$this->_uniacid]; + $dis[] = ['a.uniacid', '=', $this->_uniacid]; - $dis[] = ['a.status','=',1]; + $dis[] = ['a.status', '=', 1]; - $dis[] = ['a.start_time','<',time()]; + $dis[] = ['a.start_time', '<', time()]; - $dis[] = ['a.end_time','>',time()]; + $dis[] = ['a.end_time', '>', time()]; - if(!empty($input['title'])){ + if (!empty($input['title'])) { - $dis[] = ['a.title','like','%'.$input['title'].'%']; + $dis[] = ['a.title', 'like', '%' . $input['title'] . '%']; } - if(!empty($input['goods_name'])){ + if (!empty($input['goods_name'])) { - $dis[] = ['b.title','like','%'.$input['goods_name'].'%']; + $dis[] = ['b.title', 'like', '%' . $input['goods_name'] . '%']; } $data = $collage_model->adminDataList($dis); - if(!empty($data['data'])){ + if (!empty($data['data'])) { - foreach ($data['data'] as &$v){ + foreach ($data['data'] as &$v) { $v['time_text'] = lbGetDatesss($v['end_time']); @@ -1707,8 +1731,4 @@ class IndexClaim extends ApiRest } - - - - } diff --git a/app/farm/controller/IndexFarmer.php b/app/farm/controller/IndexFarmer.php index 77fadc2..6aae7c7 100644 --- a/app/farm/controller/IndexFarmer.php +++ b/app/farm/controller/IndexFarmer.php @@ -1,5 +1,7 @@ model = new Farmer(); - $cap_dis[] = ['user_id','=',$this->getUserId()]; + $cap_dis[] = ['user_id', '=', $this->getUserId()]; - $cap_dis[] = ['type','=',1]; + $cap_dis[] = ['type', '=', 1]; - $cap_dis[] = ['status','in',[2,3]]; + $cap_dis[] = ['status', 'in', [2, 3]]; $this->farmer = $this->model->dataInfo($cap_dis); $action = $this->request->action(); - if(empty($this->farmer)&&!in_array($action,['sourceInfo'])){ + if (empty($this->farmer) && !in_array($action, ['sourceInfo'])) { $this->errorMsg('你还不是农场主'); } @@ -86,7 +89,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2022-02-24 16:13 * @功能说明:农场主详情 */ - public function farmerInfo(){ + public function farmerInfo() + { return $this->success($this->farmer); @@ -98,7 +102,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2022-02-24 16:16 * @功能说明:编辑农场主 */ - public function farmerUpdate(){ + public function farmerUpdate() + { $input = $this->_input; @@ -107,18 +112,18 @@ class IndexFarmer extends ApiRest 'id' => $this->farmer['id'] ]; - if(isset($input['imgs'])){ + if (isset($input['imgs'])) { - $input['imgs'] = !empty($input['imgs'])?implode(',',$input['imgs']):''; + $input['imgs'] = !empty($input['imgs']) ? implode(',', $input['imgs']) : ''; } - if(isset($input['idcard_imgs'])){ + if (isset($input['idcard_imgs'])) { - $input['idcard_imgs'] = !empty($input['idcard_imgs'])?implode(',',$input['idcard_imgs']):''; + $input['idcard_imgs'] = !empty($input['idcard_imgs']) ? implode(',', $input['idcard_imgs']) : ''; } - $res = $this->model->dataUpdate($dis,$input); + $res = $this->model->dataUpdate($dis, $input); return $this->success($res); @@ -130,28 +135,29 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-10 17:51 * @功能说明:土地列表 */ - public function landList(){ + public function landList() + { $input = $this->_param; - if(!empty($input['title'])){ + if (!empty($input['title'])) { - $dis[] = ['title','like','%'.$input['title'].'%']; + $dis[] = ['title', 'like', '%' . $input['title'] . '%']; } - $dis[] = ['uniacid','=',$this->_uniacid]; + $dis[] = ['uniacid', '=', $this->_uniacid]; - $dis[] = ['status','>',-1]; + $dis[] = ['status', '>', -1]; - $dis[] = ['farmer_id','=',$this->farmer['id']]; + $dis[] = ['farmer_id', '=', $this->farmer['id']]; - $data = $this->land_model->dataList($dis,10); + $data = $this->land_model->dataList($dis, 10); - if(!empty($data['data'])){ + if (!empty($data['data'])) { - foreach ($data['data'] as &$v){ + foreach ($data['data'] as &$v) { - $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']); + $v['create_time'] = date('Y-m-d H:i:s', $v['create_time']); } } @@ -165,7 +171,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-10 18:05 * @功能说明:添加土地 */ - public function landAdd(){ + public function landAdd() + { $input = $this->_input; @@ -182,13 +189,13 @@ class IndexFarmer extends ApiRest } - /** * @author chenniang * @DataTime: 2021-12-10 18:05 * @功能说明:编辑土地 */ - public function landUpdate(){ + public function landUpdate() + { $input = $this->_input; @@ -200,7 +207,7 @@ class IndexFarmer extends ApiRest $input['uniacid'] = $this->_uniacid; - $res = $this->land_model->dataUpdate($dis,$input); + $res = $this->land_model->dataUpdate($dis, $input); return $this->success($res); @@ -212,7 +219,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-10 18:05 * @功能说明:编辑土地 */ - public function landStatusUpdate(){ + public function landStatusUpdate() + { $input = $this->_input; @@ -229,14 +237,13 @@ class IndexFarmer extends ApiRest } - - /** * @author chenniang * @DataTime: 2021-12-10 18:05 * @功能说明:土地详情 */ - public function landInfo(){ + public function landInfo() + { $input = $this->_param; @@ -258,19 +265,20 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-14 14:43 * @功能说明:地块列表 */ - public function massifList(){ + public function massifList() + { $input = $this->_param; - $dis[] = ['uniacid','=',$this->_uniacid]; + $dis[] = ['uniacid', '=', $this->_uniacid]; - $dis[] = ['status','>',-1]; + $dis[] = ['status', '>', -1]; - $dis[] = ['farmer_id','=',$this->farmer['id']]; + $dis[] = ['farmer_id', '=', $this->farmer['id']]; - if(!empty($input['title'])){ + if (!empty($input['title'])) { - $dis[] = ['title','like','%'.$input['title'].'%']; + $dis[] = ['title', 'like', '%' . $input['title'] . '%']; } $data = $this->massif_model->dataList($dis); @@ -285,19 +293,20 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-14 14:43 * @功能说明:地块列表下拉框 */ - public function massifSelect(){ + public function massifSelect() + { $input = $this->_param; - $dis[] = ['uniacid','=',$this->_uniacid]; + $dis[] = ['uniacid', '=', $this->_uniacid]; - $dis[] = ['status','=',1]; + $dis[] = ['status', '=', 1]; - $dis[] = ['farmer_id','=',$this->farmer['id']]; + $dis[] = ['farmer_id', '=', $this->farmer['id']]; - if(!empty($input['title'])){ + if (!empty($input['title'])) { - $dis[] = ['title','like','%'.$input['title'].'%']; + $dis[] = ['title', 'like', '%' . $input['title'] . '%']; } $data = $this->massif_model->where($dis)->select()->toArray(); @@ -311,7 +320,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-14 14:49 * @功能说明:添加地块 */ - public function massifAdd(){ + public function massifAdd() + { $input = $this->_input; @@ -333,7 +343,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-14 14:50 * @功能说明:编辑地块 */ - public function massifUpdate(){ + public function massifUpdate() + { $input = $this->_input; @@ -344,31 +355,31 @@ class IndexFarmer extends ApiRest $input['uniacid'] = $this->_uniacid; //删除 - if(isset($input['status'])&&$input['status']==-1){ + if (isset($input['status']) && $input['status'] == -1) { - $find = $this->land_model->landSomeFind($input['id'],1); + $find = $this->land_model->landSomeFind($input['id'], 1); - if($find==1){ + if ($find == 1) { $this->errorMsg('该地块服务正在被使用'); } } - $data = $this->massif_model->dataUpdate($dis,$input); + $data = $this->massif_model->dataUpdate($dis, $input); return $this->success($data); } - /** * @author chenniang * @DataTime: 2021-12-14 14:50 * @功能说明:地块详情 */ - public function massifInfo(){ + public function massifInfo() + { $input = $this->_param; @@ -389,30 +400,31 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-20 16:54 * @功能说明:种子列表 */ - public function seedList(){ + public function seedList() + { $input = $this->_param; - $dis[] = ['uniacid','=',$this->_uniacid]; + $dis[] = ['uniacid', '=', $this->_uniacid]; - $dis[] = ['status','>',-1]; + $dis[] = ['status', '>', -1]; - $dis[] = ['farmer_id','=',$this->farmer['id']]; + $dis[] = ['farmer_id', '=', $this->farmer['id']]; - if(!empty($input['title'])){ + if (!empty($input['title'])) { - $dis[] = ['title','like','%'.$input['title'].'%']; + $dis[] = ['title', 'like', '%' . $input['title'] . '%']; } $seed_model = new Seed(); - $data = $seed_model->dataList($dis,10); + $data = $seed_model->dataList($dis, 10); - if(!empty($data['data'])){ + if (!empty($data['data'])) { - foreach ($data['data'] as &$v){ + foreach ($data['data'] as &$v) { - $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']); + $v['create_time'] = date('Y-m-d H:i:s', $v['create_time']); } } @@ -426,19 +438,20 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-20 16:54 * @功能说明:种子列表 */ - public function seedSelect(){ + public function seedSelect() + { $input = $this->_param; - $dis[] = ['uniacid','=',$this->_uniacid]; + $dis[] = ['uniacid', '=', $this->_uniacid]; - $dis[] = ['status','=',1]; + $dis[] = ['status', '=', 1]; - $dis[] = ['farmer_id','=',$this->farmer['id']]; + $dis[] = ['farmer_id', '=', $this->farmer['id']]; - if(!empty($input['title'])){ + if (!empty($input['title'])) { - $dis[] = ['title','like','%'.$input['title'].'%']; + $dis[] = ['title', 'like', '%' . $input['title'] . '%']; } $seed_model = new Seed(); @@ -448,12 +461,14 @@ class IndexFarmer extends ApiRest return $this->success($data); } + /** * @author chenniang * @DataTime: 2021-12-20 16:57 * @功能说明:添加种子 */ - public function seedAdd(){ + public function seedAdd() + { $input = $this->_input; @@ -472,14 +487,13 @@ class IndexFarmer extends ApiRest } - - /** * @author chenniang * @DataTime: 2021-12-14 14:50 * @功能说明:编辑种子 */ - public function seedUpdate(){ + public function seedUpdate() + { $input = $this->_input; @@ -492,18 +506,18 @@ class IndexFarmer extends ApiRest $seed_model = new Seed(); //删除 - if(isset($input['status'])&&in_array($input['status'],[-1,0])){ + if (isset($input['status']) && in_array($input['status'], [-1, 0])) { - $find = $this->land_model->landSomeFind($input['id'],2); + $find = $this->land_model->landSomeFind($input['id'], 2); - if($find==1){ + if ($find == 1) { $this->errorMsg('该种子正在被使用'); } } - $data = $seed_model->dataUpdate($dis,$input); + $data = $seed_model->dataUpdate($dis, $input); return $this->success($data); @@ -515,7 +529,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-14 14:50 * @功能说明:编辑种子 */ - public function seedInfo(){ + public function seedInfo() + { $input = $this->_param; @@ -538,30 +553,30 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-14 15:28 * @功能说明:认养管理列表 */ - public function claimList(){ - - $input = $this->_param; - + public function claimList() + { + echo 1;die; + $input = $this->_param; $claim_model = new Claim(); - $dis[] = ['uniacid','=',$this->_uniacid]; + $dis[] = ['uniacid', '=', $this->_uniacid]; - $dis[] = ['status','>',-1]; + $dis[] = ['status', '>', -1]; - $dis[] = ['farmer_id','=',$this->farmer['id']]; + $dis[] = ['farmer_id', '=', $this->farmer['id']]; - if(!empty($input['title'])){ + if (!empty($input['title'])) { - $dis[] = ['title','like','%'.$input['title'].'%']; + $dis[] = ['title', 'like', '%' . $input['title'] . '%']; } - $data = $claim_model->dataList($dis,10); + $data = $claim_model->dataList($dis, 10); - if(!empty($data['data'])){ + if (!empty($data['data'])) { - foreach ($data['data'] as &$v){ + foreach ($data['data'] as &$v) { - $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']); + $v['create_time'] = date('Y-m-d H:i:s', $v['create_time']); } @@ -577,7 +592,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-14 16:32 * @功能说明:添加认养 */ - public function claimAdd(){ + public function claimAdd() + { $input = $this->_input; @@ -601,7 +617,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-14 16:32 * @功能说明:认养详情 */ - public function claimInfo(){ + public function claimInfo() + { $input = $this->_param; @@ -614,31 +631,31 @@ class IndexFarmer extends ApiRest $res = $claim_model->dataInfo($dis); - $claim_text_model = new ClaimText(); + $claim_text_model = new ClaimText(); - $monitor_text_model= new MonitorText(); + $monitor_text_model = new MonitorText(); - $monitor_model = new Monitor(); + $monitor_model = new Monitor(); //流程 - $res['process'] = $claim_text_model->where(['claim_id'=>$input['id']])->select()->toArray(); + $res['process'] = $claim_text_model->where(['claim_id' => $input['id']])->select()->toArray(); //监控 - $res['monitor'] = $monitor_text_model->where(['obj_id'=>$input['id'],'type'=>2])->column('monitor_id'); + $res['monitor'] = $monitor_text_model->where(['obj_id' => $input['id'], 'type' => 2])->column('monitor_id'); $res['monitor'] = array_values($res['monitor']); - $res['monitor'] = $monitor_model->where('id','in',$res['monitor'])->where(['status'=>1])->select()->toArray(); + $res['monitor'] = $monitor_model->where('id', 'in', $res['monitor'])->where(['status' => 1])->select()->toArray(); $cate_model = new LandCate(); //分类名字 - $res['cate_name'] = $cate_model->where(['id'=>$res['cate_id'],'type'=>2])->value('title'); + $res['cate_name'] = $cate_model->where(['id' => $res['cate_id'], 'type' => 2])->value('title'); $source_model = new Source(); //溯源名字 - $res['source_name'] = $source_model->where(['id'=>$res['source_id']])->value('title'); + $res['source_name'] = $source_model->where(['id' => $res['source_id']])->value('title'); $mac_model = new Machine(); //仪器名字 - $res['machine_name'] = $mac_model->where(['id'=>$res['machine_id'],'status'=>1])->value('title'); + $res['machine_name'] = $mac_model->where(['id' => $res['machine_id'], 'status' => 1])->value('title'); return $this->success($res); @@ -650,7 +667,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-14 16:32 * @功能说明:编辑认养 */ - public function claimUpdate(){ + public function claimUpdate() + { $input = $this->_input; @@ -663,7 +681,7 @@ class IndexFarmer extends ApiRest $claim_model = new Claim(); - $res = $claim_model->dataUpdate($dis,$input); + $res = $claim_model->dataUpdate($dis, $input); return $this->success($res); @@ -675,7 +693,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-14 16:32 * @功能说明:编辑认养 */ - public function claimStatusUpdate(){ + public function claimStatusUpdate() + { $input = $this->_input; @@ -698,7 +717,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-14 17:04 * @功能说明:溯源列表 */ - public function sourceList(){ + public function sourceList() + { $input = $this->_param; @@ -706,24 +726,24 @@ class IndexFarmer extends ApiRest // $source_text_model = new SourceText(); - $dis[] = ['uniacid','=',$this->_uniacid]; + $dis[] = ['uniacid', '=', $this->_uniacid]; - $dis[] = ['status','>',-1]; + $dis[] = ['status', '>', -1]; - if(!empty($input['title'])){ + if (!empty($input['title'])) { - $dis[] = ['title','like','%'.$input['title'].'%']; + $dis[] = ['title', 'like', '%' . $input['title'] . '%']; } - $dis[] = ['farmer_id','=',$this->farmer['id']]; + $dis[] = ['farmer_id', '=', $this->farmer['id']]; - $data = $source_model->dataList($dis,10); + $data = $source_model->dataList($dis, 10); - if(!empty($data['data'])){ + if (!empty($data['data'])) { - foreach ($data['data'] as &$v){ + foreach ($data['data'] as &$v) { - $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']); + $v['create_time'] = date('Y-m-d H:i:s', $v['create_time']); } } @@ -736,22 +756,23 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-14 17:04 * @功能说明:溯源下拉框 */ - public function sourceSelect(){ + public function sourceSelect() + { $input = $this->_param; $source_model = new Source(); - $dis[] = ['uniacid','=',$this->_uniacid]; + $dis[] = ['uniacid', '=', $this->_uniacid]; - $dis[] = ['status','=',1]; + $dis[] = ['status', '=', 1]; - if(!empty($input['title'])){ + if (!empty($input['title'])) { - $dis[] = ['title','like','%'.$input['title'].'%']; + $dis[] = ['title', 'like', '%' . $input['title'] . '%']; } - $dis[] = ['farmer_id','=',$this->farmer['id']]; + $dis[] = ['farmer_id', '=', $this->farmer['id']]; $data = $source_model->where($dis)->select()->toArray(); @@ -763,7 +784,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-14 17:10 * @功能说明:添加溯源 */ - public function sourceAdd(){ + public function sourceAdd() + { $input = $this->_input; @@ -787,7 +809,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-14 17:12 * @功能说明:编辑溯源 */ - public function sourceUpdate(){ + public function sourceUpdate() + { $input = $this->_input; @@ -800,18 +823,18 @@ class IndexFarmer extends ApiRest 'id' => $input['id'] ]; //删除 - if(isset($input['status'])&&$input['status']==-1){ + if (isset($input['status']) && $input['status'] == -1) { - $find = $this->land_model->landSomeFind($input['id'],3); + $find = $this->land_model->landSomeFind($input['id'], 3); - if($find==1){ + if ($find == 1) { $this->errorMsg('该溯源正在被使用'); } } - $res = $source_model->dataUpdate($dis,$input); + $res = $source_model->dataUpdate($dis, $input); return $this->success($res); @@ -823,7 +846,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-14 17:12 * @功能说明:编辑溯源 */ - public function sourceInfo(){ + public function sourceInfo() + { $input = $this->_param; @@ -846,24 +870,25 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-29 10:29 * @功能说明:养殖管理 */ - public function breedList(){ + public function breedList() + { $input = $this->_param; $breed_model = new Breed(); - $dis[] = ['uniacid','=',$this->_uniacid]; + $dis[] = ['uniacid', '=', $this->_uniacid]; - $dis[] = ['status','>',-1]; + $dis[] = ['status', '>', -1]; - if(!empty($input['title'])){ + if (!empty($input['title'])) { - $dis[] = ['title','like','%'.$input['title'].'%']; + $dis[] = ['title', 'like', '%' . $input['title'] . '%']; } - $dis[] = ['farmer_id','=',$this->farmer['id']]; + $dis[] = ['farmer_id', '=', $this->farmer['id']]; - $data = $breed_model->dataList($dis,10); + $data = $breed_model->dataList($dis, 10); return $this->success($data); @@ -875,7 +900,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-29 10:30 * @功能说明:添加养殖管理 */ - public function breedAdd(){ + public function breedAdd() + { $input = $this->_input; @@ -897,7 +923,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-29 10:34 * @功能说明:编辑养殖管理 */ - public function breedUpdate(){ + public function breedUpdate() + { $input = $this->_input; @@ -910,7 +937,7 @@ class IndexFarmer extends ApiRest $breed_model = new Breed(); - $res = $breed_model->dataUpdate($dis,$input); + $res = $breed_model->dataUpdate($dis, $input); return $this->success($res); @@ -922,7 +949,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-29 10:34 * @功能说明:编辑养殖管理 */ - public function breedInfo(){ + public function breedInfo() + { $input = $this->_param; @@ -945,7 +973,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-30 11:15 * @功能说明:申请提现 */ - public function applyWallet(){ + public function applyWallet() + { $input = $this->_input; @@ -953,9 +982,9 @@ class IndexFarmer extends ApiRest $config_model = new Config(); - $config = $config_model->dataInfo(['uniacid'=>$this->_uniacid]); + $config = $config_model->dataInfo(['uniacid' => $this->_uniacid]); - if($input['apply_price']>$this->farmer['cash']){ + if ($input['apply_price'] > $this->farmer['cash']) { $this->errorMsg('余额不足'); } @@ -964,26 +993,26 @@ class IndexFarmer extends ApiRest $insert = [ - 'uniacid' => $this->_uniacid, + 'uniacid' => $this->_uniacid, - 'user_id' => $this->getUserId(), + 'user_id' => $this->getUserId(), 'order_code' => orderCode(), - 'farmer_id' => $this->farmer['id'], + 'farmer_id' => $this->farmer['id'], - 'pay_price' => $input['apply_price'], + 'pay_price' => $input['apply_price'], - 'text' => $input['text'], + 'text' => $input['text'], - 'true_price' => round($input['apply_price']*$config['cash_balance']/100,2), + 'true_price' => round($input['apply_price'] * $config['cash_balance'] / 100, 2), - 'balance' => $config['cash_balance'], + 'balance' => $config['cash_balance'], ]; //发起提现 $res = $wallet_model->dataAdd($insert); - if($res==0){ + if ($res == 0) { Db::rollback(); @@ -995,9 +1024,9 @@ class IndexFarmer extends ApiRest $id = $wallet_model->getLastInsID(); //添加拒绝提现记录 - $res = $water_model->addWater($id,7,1,1); + $res = $water_model->addWater($id, 7, 1, 1); - if($res==0){ + if ($res == 0) { Db::rollback(); @@ -1007,7 +1036,7 @@ class IndexFarmer extends ApiRest //执行记录 $res = $water_model->cashArrival($this->farmer['id']); - if($res==0){ + if ($res == 0) { Db::rollback(); @@ -1027,21 +1056,22 @@ class IndexFarmer extends ApiRest * @DataTime: 2022-02-09 15:06 * @功能说明:农场主财务详情 */ - public function farmerFinanceInfo(){ + public function farmerFinanceInfo() + { $water_model = new FinanceWater(); $water_model->cashArrival($this->farmer['id']); //余额 - $data['cash'] = $this->model->where(['id'=>$this->farmer['id']])->value('cash'); + $data['cash'] = $this->model->where(['id' => $this->farmer['id']])->value('cash'); $water_data = $water_model->getDayCash($this->farmer['id']); //总金额 $data['total_cash'] = $water_data['income_cash']; //冻结金额 - $data['frozen_cash']= $water_model->where(['farmer_id'=>$this->farmer['id'],'add'=>1,'role_type'=>1])->where('cash_status','in',[0,1])->sum('price'); + $data['frozen_cash'] = $water_model->where(['farmer_id' => $this->farmer['id'], 'add' => 1, 'role_type' => 1])->where('cash_status', 'in', [0, 1])->sum('price'); - $data['frozen_cash']= round($data['frozen_cash'],2); + $data['frozen_cash'] = round($data['frozen_cash'], 2); return $this->success($data); @@ -1053,28 +1083,29 @@ class IndexFarmer extends ApiRest * @DataTime: 2022-02-09 16:35 * @功能说明:农场主流水记录 */ - public function farmerFinanceList(){ + public function farmerFinanceList() + { $input = $this->_param; - $dis[] = ['farmer_id','=',$this->farmer['id']]; + $dis[] = ['farmer_id', '=', $this->farmer['id']]; - $dis[] = ['role_type','=',1]; + $dis[] = ['role_type', '=', 1]; - if(isset($input['add'])){ + if (isset($input['add'])) { - $dis[] = ['add','=',$input['add']]; + $dis[] = ['add', '=', $input['add']]; } - if(!empty($input['start_time'])&&!empty($input['end_time'])){ + if (!empty($input['start_time']) && !empty($input['end_time'])) { - $dis[] = ['create_time','between',"{$input['start_time']},{$input['end_time']}"]; + $dis[] = ['create_time', 'between', "{$input['start_time']},{$input['end_time']}"]; } $water_model = new FinanceWater(); - $data = $water_model->dataList($dis,10); + $data = $water_model->dataList($dis, 10); return $this->success($data); @@ -1086,7 +1117,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-30 17:09 * @功能说明:农场主提现列表 */ - public function walletList(){ + public function walletList() + { $input = $this->_param; @@ -1094,13 +1126,13 @@ class IndexFarmer extends ApiRest 'farmer_id' => $this->farmer['id'], - 'is_show' => 1, + 'is_show' => 1, - 'uniacid' => $this->_uniacid + 'uniacid' => $this->_uniacid ]; - if(!empty($input['status'])){ + if (!empty($input['status'])) { $dis['status'] = $input['status']; } @@ -1119,7 +1151,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-31 15:11 * @功能说明:认养和土地分类 */ - public function landAndClaimCate(){ + public function landAndClaimCate() + { $input = $this->_param; @@ -1127,9 +1160,9 @@ class IndexFarmer extends ApiRest 'a.status' => 1, - 'a.uniacid'=> $this->_uniacid, + 'a.uniacid' => $this->_uniacid, - 'a.type' => $input['type'] + 'a.type' => $input['type'] ]; $where = [ @@ -1142,23 +1175,22 @@ class IndexFarmer extends ApiRest $cate_model = new LandCate(); $data = $cate_model->alias('a') - ->join('lbfarm_land_cate_text b','a.id = b.cate_id','left') - ->where($dis) - ->where(function ($query) use ($where){ - $query->whereOr($where); - }) - ->field('a.*') - ->group('a.id') - ->order('a.top desc,a.id desc') - ->select() - ->toArray(); + ->join('lbfarm_land_cate_text b', 'a.id = b.cate_id', 'left') + ->where($dis) + ->where(function ($query) use ($where) { + $query->whereOr($where); + }) + ->field('a.*') + ->group('a.id') + ->order('a.top desc,a.id desc') + ->select() + ->toArray(); return $this->success($data); } - /** * @author chenniang * @DataTime: 2022-01-10 15:52 @@ -1166,13 +1198,14 @@ class IndexFarmer extends ApiRest * */ - public function breedOrderList(){ + public function breedOrderList() + { $input = $this->_param; - $dis[] = ['pay_type','>',1]; + $dis[] = ['pay_type', '>', 1]; - $dis[] = ['farmer_id','=',$this->farmer['id']]; + $dis[] = ['farmer_id', '=', $this->farmer['id']]; $order_model = new BreedOrder(); @@ -1188,33 +1221,34 @@ class IndexFarmer extends ApiRest * @DataTime: 2022-02-09 15:16 * @功能说明:认养订单 */ - public function claimOrderList(){ + public function claimOrderList() + { $input = $this->_param; $order_model = new ClaimOrder(); - $dis[] = ['farmer_id','=',$this->farmer['id']]; + $dis[] = ['farmer_id', '=', $this->farmer['id']]; - if(!empty($input['pay_type'])){ + if (!empty($input['pay_type'])) { - $dis[] = ['pay_type','=',$input['pay_type']]; + $dis[] = ['pay_type', '=', $input['pay_type']]; - }else{ + } else { - $dis[] = ['pay_type','>',-1]; + $dis[] = ['pay_type', '>', -1]; } $data = $order_model->dataList($dis); - if(!empty($data['data'])){ + if (!empty($data['data'])) { - $address_model = new OrderAddress(); + $address_model = new OrderAddress(); - foreach ($data['data'] as &$v){ + foreach ($data['data'] as &$v) { //地址信息 - $v['address_info'] = $address_model->dataInfo(['order_id'=>$v['id'],'type'=>2]); + $v['address_info'] = $address_model->dataInfo(['order_id' => $v['id'], 'type' => 2]); } } @@ -1225,16 +1259,16 @@ class IndexFarmer extends ApiRest 3 => 'send_ing' ]; - foreach ($arr as $k=>$value){ + foreach ($arr as $k => $value) { $dis = [ 'pay_type' => $k, - 'farmer_id'=> $this->farmer['id'] + 'farmer_id' => $this->farmer['id'] ]; - $data[$value] = $order_model->where($dis)->where('pay_time','>',0)->count(); + $data[$value] = $order_model->where($dis)->where('pay_time', '>', 0)->count(); } return $this->success($data); @@ -1243,26 +1277,26 @@ class IndexFarmer extends ApiRest } - /** * @author chenniang * @DataTime: 2022-02-09 09:47 * @功能说明:发货订单发货 */ - public function sendOrderSend(){ + public function sendOrderSend() + { $input = $this->_input; $send_order_model = new SendOrder(); - $send_order = $send_order_model->dataInfo(['id'=>$input['id']]); + $send_order = $send_order_model->dataInfo(['id' => $input['id']]); - if(empty($send_order)){ + if (empty($send_order)) { $this->errorMsg('订单未找到'); } - if($send_order['pay_type']!=2){ + if ($send_order['pay_type'] != 2) { $this->errorMsg('订单状态错误'); } @@ -1271,28 +1305,28 @@ class IndexFarmer extends ApiRest 'pay_type' => 3, - 'send_time'=> time(), + 'send_time' => time(), - 'auto_receiving_time' => $this->_config['auto_hx_time']*86400+time() + 'auto_receiving_time' => $this->_config['auto_hx_time'] * 86400 + time() ]; Db::startTrans(); - $res = $send_order_model->dataUpdate(['id'=>$input['id']],$update); + $res = $send_order_model->dataUpdate(['id' => $input['id']], $update); - if($res==0){ + if ($res == 0) { Db::rollback(); $this->errorMsg('发货失败'); } - if($send_order['type']==1){ + if ($send_order['type'] == 1) { $claim_order_model = new ClaimOrder(); - $claim_order_model->dataUpdate(['id'=>$send_order['order_id']],['pay_type'=>3]); + $claim_order_model->dataUpdate(['id' => $send_order['order_id']], ['pay_type' => 3]); } Db::commit(); @@ -1302,44 +1336,44 @@ class IndexFarmer extends ApiRest } - /** * @author chenniang * @DataTime: 2022-02-08 17:14 * @功能说明:配送订单列表 */ - public function farmerSendOrderList(){ + public function farmerSendOrderList() + { $input = $this->_param; - $dis[] = ['farmer_id','=',$this->farmer['id']]; + $dis[] = ['farmer_id', '=', $this->farmer['id']]; - $dis[] = ['pay_time','>',0]; + $dis[] = ['pay_time', '>', 0]; - if(!empty($input['pay_type'])){ + if (!empty($input['pay_type'])) { - $dis[] = ['pay_type','=',$input['pay_type']]; + $dis[] = ['pay_type', '=', $input['pay_type']]; } $send_order_model = new SendOrder(); $data = $send_order_model->dataList($dis); - if(!empty($data['data'])){ + if (!empty($data['data'])) { - foreach ($data['data'] as &$v){ + foreach ($data['data'] as &$v) { - $v['time_text'] = date('Y-m-d H:i',$v['start_time']).'~'.date('H:i',$v['end_time']); + $v['time_text'] = date('Y-m-d H:i', $v['start_time']) . '~' . date('H:i', $v['end_time']); - $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']); + $v['create_time'] = date('Y-m-d H:i:s', $v['create_time']); - $v['pay_time'] = $v['pay_time']>0?date('Y-m-d H:i:s',$v['pay_time']):0; + $v['pay_time'] = $v['pay_time'] > 0 ? date('Y-m-d H:i:s', $v['pay_time']) : 0; - $v['send_time'] = $v['send_time']>0?date('Y-m-d H:i:s',$v['send_time']):0; + $v['send_time'] = $v['send_time'] > 0 ? date('Y-m-d H:i:s', $v['send_time']) : 0; - $v['receiving_time'] = $v['receiving_time']>0?date('Y-m-d H:i:s',$v['receiving_time']):0; + $v['receiving_time'] = $v['receiving_time'] > 0 ? date('Y-m-d H:i:s', $v['receiving_time']) : 0; - $v['refund_time'] = $v['refund_time']>0?date('Y-m-d H:i:s',$v['refund_time']):0; + $v['refund_time'] = $v['refund_time'] > 0 ? date('Y-m-d H:i:s', $v['refund_time']) : 0; } } @@ -1350,16 +1384,16 @@ class IndexFarmer extends ApiRest 3 => 'send_ing' ]; - foreach ($arr as $k=>$value){ + foreach ($arr as $k => $value) { $dis = [ 'pay_type' => $k, - 'farmer_id'=> $this->farmer['id'] + 'farmer_id' => $this->farmer['id'] ]; - $data[$value] = $send_order_model->where($dis)->where('pay_time','>',0)->count(); + $data[$value] = $send_order_model->where($dis)->where('pay_time', '>', 0)->count(); } return $this->success($data); @@ -1367,33 +1401,33 @@ class IndexFarmer extends ApiRest } - /** * @author chenniang * @DataTime: 2022-02-09 09:47 * @功能说明:配送订单收货 */ - public function sendOrderPickup(){ + public function sendOrderPickup() + { $input = $this->_input; $send_order_model = new SendOrder(); - $send_order = $send_order_model->dataInfo(['id'=>$input['id']]); + $send_order = $send_order_model->dataInfo(['id' => $input['id']]); - if(empty($send_order)){ + if (empty($send_order)) { $this->errorMsg('订单未找到'); } - if($send_order['pay_type']!=2){ + if ($send_order['pay_type'] != 2) { $this->errorMsg('订单状态错误'); } $res = $send_order_model->sendOrderReceiving($send_order); - if(!empty($res['code'])){ + if (!empty($res['code'])) { $this->errorMsg($res['msg']); } @@ -1408,62 +1442,63 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-12-28 11:26 * @功能说明:用户下单列表 */ - public function landOrderList(){ + public function landOrderList() + { $input = $this->_param; - $order_model = new LandOrder(); + $order_model = new LandOrder(); $farmer_model = new Farmer(); $order_model->orderInit($this->getUserId()); - $dis[] = ['uniacid','=',$this->_uniacid]; + $dis[] = ['uniacid', '=', $this->_uniacid]; - $dis[] = ['farmer_id','=',$this->farmer['id']]; + $dis[] = ['farmer_id', '=', $this->farmer['id']]; - if(!empty($input['pay_type'])){ + if (!empty($input['pay_type'])) { - $dis[] = ['pay_type','=',$input['pay_type']]; + $dis[] = ['pay_type', '=', $input['pay_type']]; - }else{ + } else { - $dis[] = ['pay_type','>',-1]; + $dis[] = ['pay_type', '>', -1]; } - if(!empty($input['order_code'])){ + if (!empty($input['order_code'])) { - $dis[] = ['order_code','like','%'.$input['order_code'].'%']; + $dis[] = ['order_code', 'like', '%' . $input['order_code'] . '%']; } $data = $order_model->dataList($dis); - if(!empty($data['data'])){ + if (!empty($data['data'])) { - $address_model = new OrderAddress(); + $address_model = new OrderAddress(); - foreach ($data['data'] as &$v){ + foreach ($data['data'] as &$v) { - $v['farmer_info'] = $farmer_model->dataInfo(['id'=>$v['farmer_id']],'title'); + $v['farmer_info'] = $farmer_model->dataInfo(['id' => $v['farmer_id']], 'title'); - $v['end_time'] = date('Y-m-d H:i:s',$v['end_time']); + $v['end_time'] = date('Y-m-d H:i:s', $v['end_time']); //地址信息 - $v['address_info'] = $address_model->dataInfo(['order_id'=>$v['id'],'type'=>1]); + $v['address_info'] = $address_model->dataInfo(['order_id' => $v['id'], 'type' => 1]); } } - $arr = [1=>'no_pay_count',2=>'rent_count',3=>'send_count']; + $arr = [1 => 'no_pay_count', 2 => 'rent_count', 3 => 'send_count']; - foreach ($arr as $key => $value){ + foreach ($arr as $key => $value) { $where = [ 'farmer_id' => $this->farmer['id'], - 'pay_type' => $key + 'pay_type' => $key ]; $data['count'][$value] = $order_model->where($where)->count(); @@ -1475,23 +1510,23 @@ class IndexFarmer extends ApiRest } - /** * @author chenniang * @DataTime: 2022-02-21 11:00 * @功能说明:仪器列表 */ - public function machineSelect(){ + public function machineSelect() + { $input = $this->_param; $mac_model = new Machine(); - $dis[] = ['uniacid','=',$this->_uniacid]; + $dis[] = ['uniacid', '=', $this->_uniacid]; - $dis[] = ['status','=',1]; + $dis[] = ['status', '=', 1]; - $dis[] = ['farmer_id','=',$this->farmer['id']]; + $dis[] = ['farmer_id', '=', $this->farmer['id']]; $data = $mac_model->where($dis)->select()->toArray(); @@ -1505,23 +1540,24 @@ class IndexFarmer extends ApiRest * @DataTime: 2022-02-22 17:11 * @功能说明:生成二维码 */ - public function getSourceQr(){ + public function getSourceQr() + { $input = $this->_input; $uniacid = $this->_uniacid; - $key = 'sourcekey'.$input['id']; + $key = 'sourcekey' . $input['id']; - $qr = getCache($key,$uniacid); + $qr = getCache($key, $uniacid); - if(empty($qr)||!empty($input['is_update'])){ + if (empty($qr) || !empty($input['is_update'])) { - $data = longbingCreateWxCode($uniacid,$input,$input['page']); + $data = longbingCreateWxCode($uniacid, $input, $input['page']); - $data = transImagesOne($data ,['qr_path'] ,$uniacid); + $data = transImagesOne($data, ['qr_path'], $uniacid); - $qr = $data['qr_path']; + $qr = $data['qr_path']; } return $this->success($qr); @@ -1529,63 +1565,60 @@ class IndexFarmer extends ApiRest } - - - - /** * @author chenniang * @DataTime: 2022-03-01 11:03 * @功能说明:订单列表 */ - public function shopOrderList(){ + public function shopOrderList() + { $input = $this->_param; - $dis[] = ['a.uniacid','=',$this->_uniacid]; + $dis[] = ['a.uniacid', '=', $this->_uniacid]; - $dis[] = ['a.farmer_id','=',$this->farmer['id']]; + $dis[] = ['a.farmer_id', '=', $this->farmer['id']]; - $dis[] = ['a.farmer_show','=',1]; + $dis[] = ['a.farmer_show', '=', 1]; $where = []; - if(!empty($input['name'])){ + if (!empty($input['name'])) { - $where[] = ['b.goods_name','like','%'.$input['name'].'%']; + $where[] = ['b.goods_name', 'like', '%' . $input['name'] . '%']; - $where[] = ['a.order_code','like','%'.$input['name'].'%']; + $where[] = ['a.order_code', 'like', '%' . $input['name'] . '%']; } - if(!empty($input['pay_type'])){ + if (!empty($input['pay_type'])) { - $dis[] = ['a.pay_type','=',$input['pay_type']]; + $dis[] = ['a.pay_type', '=', $input['pay_type']]; - }else{ + } else { - $dis[] = ['a.pay_type','>',1]; + $dis[] = ['a.pay_type', '>', 1]; } $order_model = new ShopOrder(); - $data = $order_model->indexDataList($dis,$where); + $data = $order_model->indexDataList($dis, $where); $arr = [ //未发货 - 'no_send_count' => 2, + 'no_send_count' => 2, //已经发货 - 'have_send_count'=> 3 + 'have_send_count' => 3 ]; - foreach ($arr as $ks=>$vs){ + foreach ($arr as $ks => $vs) { $map = [ - 'farmer_id'=> $this->farmer['id'], + 'farmer_id' => $this->farmer['id'], - 'pay_type'=> $vs, + 'pay_type' => $vs, 'farmer_show' => 1 ]; @@ -1603,7 +1636,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2021-03-15 14:58 * @功能说明:订单详情 */ - public function shopOrderInfo(){ + public function shopOrderInfo() + { $input = $this->_param; @@ -1619,23 +1653,23 @@ class IndexFarmer extends ApiRest $data['over_time'] -= time(); - $time_arr = ['create_time','pay_time','end_time','hx_time','over_time','cancel_time']; + $time_arr = ['create_time', 'pay_time', 'end_time', 'hx_time', 'over_time', 'cancel_time']; - foreach ($time_arr as $v){ + foreach ($time_arr as $v) { - $data[$v] = !empty($data[$v])?date('Y-m-d H:i:s',$data[$v]):$data[$v]; + $data[$v] = !empty($data[$v]) ? date('Y-m-d H:i:s', $data[$v]) : $data[$v]; } $data['distance'] = distance_text($data['distance']); - $end_time = date('H:i',$data['send_end_time'])=='00:00'?'24:00':date('H:i',$data['send_end_time']); + $end_time = date('H:i', $data['send_end_time']) == '00:00' ? '24:00' : date('H:i', $data['send_end_time']); //配送时间 - $data['user_send_time'] = date('Y-m-d H:i',$data['send_start_time']).'~'.$end_time; + $data['user_send_time'] = date('Y-m-d H:i', $data['send_start_time']) . '~' . $end_time; $farmer_model = new Farmer(); - $data['farmer_info'] = $farmer_model->dataInfo(['id'=>$data['farmer_id']],'title'); + $data['farmer_info'] = $farmer_model->dataInfo(['id' => $data['farmer_id']], 'title'); return $this->success($data); @@ -1647,7 +1681,8 @@ class IndexFarmer extends ApiRest * @DataTime: 2022-03-07 11:08 * @功能说明:地主商城订单发货 */ - public function shopOrderSend(){ + public function shopOrderSend() + { $input = $this->_input; @@ -1660,15 +1695,15 @@ class IndexFarmer extends ApiRest $order = $order_model->dataInfo($dis); - if(empty($order)||$order['pay_type']!=2){ + if (empty($order) || $order['pay_type'] != 2) { $this->errorMsg('订单状态错误'); } $refund_model = new ShopRefund(); //判断有无申请中的退款订单 - $refund_order = $refund_model->dataInfo(['order_id'=>$input['id'],'status'=>1]); + $refund_order = $refund_model->dataInfo(['order_id' => $input['id'], 'status' => 1]); - if(!empty($refund_order)){ + if (!empty($refund_order)) { $this->errorMsg('该订单正在申请退款,请先处理再核销'); @@ -1676,7 +1711,7 @@ class IndexFarmer extends ApiRest $config_model = new Config(); - // $config = $config_model->dataInfo(['uniacid'=>$this->_uniacid]); + // $config = $config_model->dataInfo(['uniacid'=>$this->_uniacid]); $update = [ @@ -1690,15 +1725,15 @@ class IndexFarmer extends ApiRest // // 'express_user' => $input['express_user'], - // 'send_time' => time(), + // 'send_time' => time(), - 'video' => $input['video'], + 'video' => $input['video'], //'hx_over_time' => time()+$config['auto_hx_time']*86400, ]; - $data = $order_model->dataUpdate($dis,$update); + $data = $order_model->dataUpdate($dis, $update); // $water_model = new FinanceWater(); // //商城订单农场主获得运费 @@ -1714,26 +1749,26 @@ class IndexFarmer extends ApiRest } - /** * @author chenniang * @DataTime: 2022-04-11 14:22 * @功能说明:监控列表 */ - public function monitorSelect(){ + public function monitorSelect() + { $input = $this->_param; - $dis[] = ['uniacid','=',$this->_uniacid]; + $dis[] = ['uniacid', '=', $this->_uniacid]; - $dis[] = ['status','=',1]; + $dis[] = ['status', '=', 1]; - if(!empty($input['title'])){ + if (!empty($input['title'])) { - $dis[] = ['title','like','%'.$input['title'].'%']; + $dis[] = ['title', 'like', '%' . $input['title'] . '%']; } - $dis[] = ['farmer_id','=',$this->farmer['id']]; + $dis[] = ['farmer_id', '=', $this->farmer['id']]; $monitor_model = new Monitor(); @@ -1744,8 +1779,4 @@ class IndexFarmer extends ApiRest } - - - - } diff --git a/vendor/topthink/framework/src/helper.php b/vendor/topthink/framework/src/helper.php index 2866935..6e560cb 100644 --- a/vendor/topthink/framework/src/helper.php +++ b/vendor/topthink/framework/src/helper.php @@ -702,3 +702,16 @@ if (!function_exists('is_dev')) { return false; } } + +if (!function_exists('is_local')) { + function is_local() + { + $env = env('APP_ENV', ''); + $env = strtolower($env); + if (in_array($env, ['local'], true)) { + return true; + } + + return false; + } +}