diff --git a/.gitignore b/.gitignore
index 57c9637..4f23976 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,5 @@ unpackage
node_modules
.DS_Store
.hbuilderx
+/vendor/
+.env
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
deleted file mode 100644
index 03d9549..0000000
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/php.xml b/.idea/php.xml
deleted file mode 100644
index 65e595c..0000000
--- a/.idea/php.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/phpunit.xml b/.idea/phpunit.xml
deleted file mode 100644
index 9250108..0000000
--- a/.idea/phpunit.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 35eb1dd..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
deleted file mode 100644
index 7a1b3e2..0000000
--- a/.idea/workspace.xml
+++ /dev/null
@@ -1,289 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $PROJECT_DIR$/composer.json
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {
- "associatedIndex": 0
-}
-
-
-
-
-
- {
- "keyToString": {
- "ASKED_ADD_EXTERNAL_FILES": "true",
- "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
- "RunOnceActivity.OpenProjectViewOnStart": "true",
- "RunOnceActivity.ShowReadmeOnStart": "true",
- "WebServerToolWindowFactoryState": "false",
- "git-widget-placeholder": "main",
- "node.js.detected.package.eslint": "true",
- "node.js.detected.package.tslint": "true",
- "node.js.selected.package.eslint": "(autodetect)",
- "node.js.selected.package.tslint": "(autodetect)",
- "nodejs_package_manager_path": "npm",
- "ts.external.directory.path": "/Applications/PhpStorm.app/Contents/plugins/javascript-impl/jsLanguageServicesImpl/external",
- "vue.rearranger.settings.migration": "true"
- }
-}
-
-
-
-
- 1766383599659
-
-
- 1766383599659
-
-
-
-
-
-
-
- 1766383620899
-
-
-
- 1766383620899
-
-
-
- 1766383725724
-
-
-
- 1766383725724
-
-
-
- 1766384088985
-
-
-
- 1766384088985
-
-
-
- 1766385175143
-
-
-
- 1766385175143
-
-
-
- 1766385211889
-
-
-
- 1766385211889
-
-
-
- 1766385266137
-
-
-
- 1766385266137
-
-
-
- 1766385310549
-
-
-
- 1766385310549
-
-
-
- 1766394714545
-
-
-
- 1766394714545
-
-
-
- 1766394785668
-
-
-
- 1766394785668
-
-
-
- 1766396463700
-
-
-
- 1766396463700
-
-
-
- 1766542118270
-
-
-
- 1766542118270
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/ApiRest.php b/app/ApiRest.php
index 361ecab..83d837e 100644
--- a/app/ApiRest.php
+++ b/app/ApiRest.php
@@ -1,23 +1,17 @@
'https://retail.xiaochengxucms.com/defaultAvatar.png',
// 默认内容图片
- 'image' => 'https://retail.xiaochengxucms.com/lbCardDefaultImage.png',
+ 'image' => 'https://retail.xiaochengxucms.com/lbCardDefaultImage.png',
);
- protected $_is_weiqin = false ;
+ protected $_is_weiqin = false;
- protected $check_url = "";
+ protected $check_url = "";
/**
* 无需登录的方法,同时也就不需要鉴权了
@@ -84,75 +78,83 @@ abstract class ApiRest extends BaseController
protected $noNeedLogin = [];
- public function __construct ( App $app )
+ public function __construct(App $app)
{
+ parent::__construct($app);
-
- parent::__construct( $app );
-
- if(in_array($this->_method,['options','Options','OPTIONS'])){
-
- echo true;exit;
+ if (in_array($this->_method, ['options', 'Options', 'OPTIONS'])) {
+ echo true;
+ exit;
}
//获取param
$this->_param = $this->request->param();
//获取body参数
- $this->_input = json_decode( $this->request->getInput(), true );
+ $this->_input = json_decode($this->request->getInput(), true);
//获取头部信息
$this->_header = $this->request->header();
- $this->is_app = !empty($this->_header['isapp'])?$this->_header['isapp']:0;
-
- if ( defined( 'IS_WEIQIN' ) )
- {
- global $_GPC, $_W;
- $this->_uniacid = $_W[ 'uniacid' ];
+ if (is_dev()) {
+ // 调试代码
+ $debugUid = $this->_param['debug_uid'] ?? ($this->_input['debug_uid'] ?? null);
+ if ($debugUid !== null) {
+ $this->_user_id = $debugUid;
+ $this->_user = [
+ 'id' => $this->_user_id,
+ 'uniacid' => $this->_uniacid,
+ 'nickname' => 'debug',
+ ];
+ $this->noNeedLogin[] = $this->request->action();
+ if (isset($this->_param['debug_uniacid'])) {
+ $this->_uniacid = $this->_param['debug_uniacid'];
+ } elseif (isset($this->_input['debug_uniacid'])) {
+ $this->_uniacid = $this->_input['debug_uniacid'];
+ }
+ }
}
- else
- {
- if(isset($this->_param[ 'i' ]))
- {
- $this->_uniacid = $this->_param[ 'i' ];
+
+ $this->is_app = !empty($this->_header['isapp']) ? $this->_header['isapp'] : 0;
+
+ if (defined('IS_WEIQIN')) {
+ global $_GPC, $_W;
+ $this->_uniacid = $_W['uniacid'];
+ } else {
+ if (isset($this->_param['i'])) {
+ $this->_uniacid = $this->_param['i'];
}
}
- if ( defined( 'LONGBING_CARD_UNIACID' ) )
- {
+ if (defined('LONGBING_CARD_UNIACID')) {
- define( 'LONGBING_CARD_UNIACID', $this->_uniacid );
+ define('LONGBING_CARD_UNIACID', $this->_uniacid);
}
- $this->shareChangeData($this->_param);
+ $this->shareChangeData($this->_param);
//获取autograph 小程序用户唯一标示
- if ( isset( $this->_header[ 'autograph' ] ) && $this->_header[ 'autograph' ])
- {
+ if (isset($this->_header['autograph']) && $this->_header['autograph']) {
$this->autograph = $this->_header['autograph'];
- }
- else
- {
- if(!$this->match($this->noNeedLogin)){
+ } else {
+ if (!$this->match($this->noNeedLogin)) {
- $this->errorMsg('need login',401);
+ $this->errorMsg('need login', 401);
}
}
//获取配置信息
$this->_config = longbingGetAppConfig($this->_uniacid);
//语言
- if ( isset( $this->_header[ 'lang' ] ) ) $this->_token = $this->_header[ 'lang' ];
+ if (isset($this->_header['lang'])) $this->_token = $this->_header['lang'];
- if(!empty($this->autograph)&&!$this->match($this->noNeedLogin)){
+ if (!empty($this->autograph) && !$this->match($this->noNeedLogin)) {
$this->_user_id = $this->getUserId();
- $this->_user = $this->getUserInfo();
+ $this->_user = $this->getUserInfo();
}
landNotice($this->_uniacid);
-
}
@@ -161,7 +163,8 @@ abstract class ApiRest extends BaseController
* @DataTime: 2020-08-21 17:43
* @功能说明:
*/
- public function shareChangeData($input){
+ public function shareChangeData($input)
+ {
$arr = [
@@ -200,11 +203,13 @@ abstract class ApiRest extends BaseController
'farm/app/IndexUser/farmerInfo',
'farm/app/Index/configInfo',
+
+ 'farm/app/Index/indexStoreList',
];
- if(!empty($input['s'])&&in_array($input['s'],$arr)){
+ if (!empty($input['s']) && in_array($input['s'], $arr)) {
- $input['s'] = trim(strrchr($input['s'], '/'),'/');
+ $input['s'] = trim(strrchr($input['s'], '/'), '/');
$this->noNeedLogin[] = $input['s'];
}
@@ -218,18 +223,17 @@ abstract class ApiRest extends BaseController
* @DataTime: 2020-07-09 12:00
* @功能说明:检测方法传递
*/
- public function match($arr){
+ public function match($arr)
+ {
$arr = is_array($arr) ? $arr : explode(',', $arr);
- if (!$arr)
- {
+ if (!$arr) {
return FALSE;
}
$arr = array_map('strtolower', $arr);
// 是否存在
- if (in_array(strtolower($this->request->action()), $arr) || in_array('*', $arr))
- {
+ if (in_array(strtolower($this->request->action()), $arr) || in_array('*', $arr)) {
return TRUE;
}
@@ -238,35 +242,36 @@ abstract class ApiRest extends BaseController
}
//返回请求成功的数据
- public function success ( $data, $code = 200 )
+ public function success($data, $code = 200)
{
- $result[ 'data' ] = LongbingGetWxApiReturnData($data);
- $result[ 'code' ] = $code;
- $result[ 'sign' ] = null;
+ $result['data'] = LongbingGetWxApiReturnData($data);
+ $result['code'] = $code;
+ $result['sign'] = null;
//复杂的签名
// if(isset($this->_user['keys'])){
// $result['sign'] = rsa2CreateSign($this->_user['keys'] ,json_encode($data));
// }
//简单的签名
- if ( !empty( $this->_token ) ) $result[ 'sign' ] = createSimpleSign( $this->_token, is_string( $data ) ? $data : json_encode( $data ) );
- return $this->response( $result, 'json', $code );
+ if (!empty($this->_token)) $result['sign'] = createSimpleSign($this->_token, is_string($data) ? $data : json_encode($data));
+ return $this->response($result, 'json', $code);
}
//返回错误数据
- public function error ( $msg, $code = 400 )
+ public function error($msg, $code = 400)
{
// $result[ 'error' ] = Lang::get($msg);
// $result[ 'code' ] = $code;
$result = $this->getErrorData($msg, $code);
- return $this->response( $result, 'json', 200 );
+ return $this->response($result, 'json', 200);
}
public function getErrorData($msg, $code = 400)
{
- $result[ 'error' ] = Lang::get($msg);
- $result[ 'code' ] = $code;
+ $result['error'] = Lang::get($msg);
+ $result['code'] = $code;
return $result;
}
+
/**
* 输出返回数据
* @access protected
@@ -275,9 +280,9 @@ abstract class ApiRest extends BaseController
* @param integer $code HTTP状态码
* @return Response
*/
- protected function response ( $data, $type = 'json', $code = 200 )
+ protected function response($data, $type = 'json', $code = 200)
{
- return Response::create( $data, $type )->code( $code );
+ return Response::create($data, $type)->code($code);
}
/**
@@ -287,30 +292,22 @@ abstract class ApiRest extends BaseController
* @return mixed
* @throws \Exception
*/
- public function _empty ( $method )
+ public function _empty($method)
{
- if ( method_exists( $this, $method . '_' . $this->method . '_' . $this->type ) )
- {
+ if (method_exists($this, $method . '_' . $this->method . '_' . $this->type)) {
// RESTFul方法支持
$fun = $method . '_' . $this->method . '_' . $this->type;
- }
- elseif ( $this->method == $this->restDefaultMethod && method_exists( $this, $method . '_' . $this->type ) )
- {
+ } elseif ($this->method == $this->restDefaultMethod && method_exists($this, $method . '_' . $this->type)) {
$fun = $method . '_' . $this->type;
- }
- elseif ( $this->type == $this->restDefaultType && method_exists( $this, $method . '_' . $this->method ) )
- {
+ } elseif ($this->type == $this->restDefaultType && method_exists($this, $method . '_' . $this->method)) {
$fun = $method . '_' . $this->method;
}
- if ( isset( $fun ) )
- {
- return App::invokeMethod( [ $this, $fun ]
+ if (isset($fun)) {
+ return App::invokeMethod([$this, $fun]
);
- }
- else
- {
+ } else {
// 抛出异常
- throw new \Exception( 'error action :' . $method );
+ throw new \Exception('error action :' . $method);
}
}
@@ -321,25 +318,25 @@ abstract class ApiRest extends BaseController
*
* @Return: mixed 查询返回值(结果集对象)
*/
- protected function getUserInfo ()
+ protected function getUserInfo()
{
$value = getCache($this->autograph, $this->_uniacid);
- if(empty($value)){
+ if (empty($value)) {
- $this->errorMsg('need login',401);
+ $this->errorMsg('need login', 401);
}
- if(empty($value['phone'])){
+ if (empty($value['phone'])) {
- // $this->errorMsg('need phone',403);
+ // $this->errorMsg('need phone',403);
}
$user_model = new \app\farm\model\User();
- $value['balance'] = $user_model->where(['id'=>$value['id']])->value('balance');
+ $value['balance'] = $user_model->where(['id' => $value['id']])->value('balance');
return $value;
}
@@ -350,37 +347,38 @@ abstract class ApiRest extends BaseController
* @DataTime: 2021-03-19 15:22
* @功能说明:获取当前的门店信息
*/
- public function getStoreInfo($err=1){
+ public function getStoreInfo($err = 1)
+ {
$user_id = $this->getUserId();
$user_model = new \app\farm\model\User();
- $cap_id = $user_model->where(['id'=>$user_id])->value('last_store_id');
+ $cap_id = $user_model->where(['id' => $user_id])->value('last_store_id');
$cap_info = [];
- if(!empty($cap_id)){
+ if (!empty($cap_id)) {
$cap_model = new Farmer();
$dis = [
- 'id' => $cap_id,
+ 'id' => $cap_id,
- 'status' => 2,
+ 'status' => 2,
'business_status' => 1,
- 'type' => 2,
+ 'type' => 2,
];
$cap_info = $cap_model->dataInfo($dis);
}
- if(empty($cap_info)&&$err==1){
+ if (empty($cap_info) && $err == 1) {
- // $this->errorMsg('请选择店铺',-407);
+ // $this->errorMsg('请选择店铺',-407);
}
@@ -389,7 +387,6 @@ abstract class ApiRest extends BaseController
}
-
/**
* @Purpose: 通过小程序端的用户标示获取用户id
*
@@ -397,25 +394,24 @@ abstract class ApiRest extends BaseController
*
* @Return: mixed 查询返回值(结果集对象)
*/
- protected function getUserId ()
+ protected function getUserId()
{
- $value = getCache( $this->autograph, $this->_uniacid );
+ $value = getCache($this->autograph, $this->_uniacid);
- if($this->is_app==1){
+ if ($this->is_app == 1) {
$user_model = new \app\farm\model\User();
- $id = $user_model->where(['check'=>1])->value('id');
+ $id = $user_model->where(['check' => 1])->value('id');
return $id;
}
- if ( ($value === false &&!$this->match($this->noNeedLogin)))
- {
+ if (($value === false && !$this->match($this->noNeedLogin))) {
- $this->errorMsg('need login',401);
+ $this->errorMsg('need login', 401);
}
@@ -437,68 +433,69 @@ abstract class ApiRest extends BaseController
// }
- return !empty($value[ 'id' ])?$value[ 'id' ]:0;
+ return !empty($value['id']) ? $value['id'] : 0;
}
+
/**
*
* 获取支付信息
*/
+ public function payConfig($uniacid = '1', $is_app = 7)
+ {
- public function payConfig ($uniacid = '1',$is_app=7){
-
- if($is_app==7){
+ if ($is_app == 7) {
$is_app = $this->is_app;
}
- $uniacid_id = !empty($uniacid)?$uniacid:$this->_uniacid;
+ $uniacid_id = !empty($uniacid) ? $uniacid : $this->_uniacid;
- $pay = Db::name('lbfarm_pay_config')->where(['uniacid'=>$uniacid_id])->find();
+ $pay = Db::name('lbfarm_pay_config')->where(['uniacid' => $uniacid_id])->find();
- $config = Db::name( 'lbfarm_config')->where(['uniacid' => $uniacid_id])->find();
+ $config = Db::name('lbfarm_config')->where(['uniacid' => $uniacid_id])->find();
- if(empty($pay[ 'mch_id' ])||empty($pay[ 'pay_key' ])){
+ if (empty($pay['mch_id']) || empty($pay['pay_key'])) {
- // $this->errorMsg('未配置支付信息');
+ // $this->errorMsg('未配置支付信息');
}
- $setting[ 'payment' ][ 'merchant_id' ] = $pay[ 'mch_id' ];
+ $setting['payment']['merchant_id'] = $pay['mch_id'];
- $setting[ 'payment' ][ 'key' ] = $pay[ 'pay_key' ];
+ $setting['payment']['key'] = $pay['pay_key'];
- $setting[ 'payment' ][ 'cert_path' ] = $pay[ 'cert_path' ];
+ $setting['payment']['cert_path'] = $pay['cert_path'];
- $setting[ 'payment' ][ 'key_path' ] = $pay[ 'key_path' ];
+ $setting['payment']['key_path'] = $pay['key_path'];
- $setting[ 'payment' ][ 'ali_appid' ] = $pay[ 'ali_appid' ];
+ $setting['payment']['ali_appid'] = $pay['ali_appid'];
- $setting[ 'payment' ][ 'ali_privatekey' ] = $pay[ 'ali_privatekey' ];
+ $setting['payment']['ali_privatekey'] = $pay['ali_privatekey'];
- $setting[ 'payment' ][ 'ali_publickey' ] = $pay[ 'ali_publickey' ];
+ $setting['payment']['ali_publickey'] = $pay['ali_publickey'];
- if($is_app==0){
+ if ($is_app == 0) {
- $setting[ 'app_id' ] = $config['appid'];
+ $setting['app_id'] = $config['appid'];
- $setting[ 'secret' ] = $config['appsecret'];
+ $setting['secret'] = $config['appsecret'];
- }elseif($is_app==1){
+ } elseif ($is_app == 1) {
- $setting[ 'app_id' ] = $config['app_app_id'];
+ $setting['app_id'] = $config['app_app_id'];
- $setting[ 'secret' ] = $config['app_app_secret'];
+ $setting['secret'] = $config['app_app_secret'];
- }else{
+ } else {
- $setting[ 'app_id' ] = $config['web_app_id'];
+ $setting['app_id'] = $config['web_app_id'];
- $setting[ 'secret' ] = $config['web_app_secret'];
+ $setting['secret'] = $config['web_app_secret'];
}
- $setting[ 'is_app' ]= $is_app;
+ $setting['is_app'] = $is_app;
return $setting;
}
@@ -511,35 +508,32 @@ abstract class ApiRest extends BaseController
* @Return: mixed 查询返回值(结果集对象)
*/
- public function getFormId ( $to_uid )
+ public function getFormId($to_uid)
{
return [];
// 七天前开始的的时间戳
// $beginTime = mktime( 0, 0, 0, date( 'm' ), date( 'd' ) - 6, date( 'Y' ) );
- $beginTime = strtotime(date('Y-m-d',time()))-86400*6;
- $formId = Db::name( 'longbing_card_formId' )
- ->where( [ 'user_id' => $to_uid ] )
- ->order( 'id desc' )
+ $beginTime = strtotime(date('Y-m-d', time())) - 86400 * 6;
+ $formId = Db::name('longbing_card_formId')
+ ->where(['user_id' => $to_uid])
+ ->order('id desc')
->select();
- if ( empty( $formId ) )
- {
+ if (empty($formId)) {
return false;
}
- if ( $formId[ 0 ][ 'create_time' ] < $beginTime )
- {
- Db::name( 'longbing_card_formId' )
- ->where( [ 'id' => $formId[ 0 ][ 'id' ] ] )
+ if ($formId[0]['create_time'] < $beginTime) {
+ Db::name('longbing_card_formId')
+ ->where(['id' => $formId[0]['id']])
->delete();
- $this->getFormId( $to_uid );
- }
- else
- {
- Db::name( 'longbing_card_formId' )
- ->where( [ 'id' => $formId[ 0 ][ 'id' ] ] )
+ $this->getFormId($to_uid);
+ } else {
+ Db::name('longbing_card_formId')
+ ->where(['id' => $formId[0]['id']])
->delete();
- return $formId[ 0 ][ 'formId' ];
+ return $formId[0]['formId'];
}
}
+
/**
* User: chenniang
* Date: 2019-09-12 20:37
@@ -547,9 +541,10 @@ abstract class ApiRest extends BaseController
* @return void
* descption:直接抛出异常
*/
- protected function errorMsg($msg = '',$code = 400){
+ protected function errorMsg($msg = '', $code = 400)
+ {
$msg = Lang::get($msg);
- $this->results($msg,$code);
+ $this->results($msg, $code);
}
/**
@@ -563,7 +558,7 @@ abstract class ApiRest extends BaseController
*/
protected function results($msg, $code, array $header = [])
{
- $result = [
+ $result = [
'error' => $msg,
'code' => $code,
];
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/Index.php b/app/farm/controller/Index.php
index 5274b1b..bcc46ba 100644
--- a/app/farm/controller/Index.php
+++ b/app/farm/controller/Index.php
@@ -1,5 +1,7 @@
$this->_uniacid,
+
+ 'status' => 2,
+
+ 'type' => 2,
+
+ 'business_status' => 1
+ ];
+
+ $farmer_model = new \app\farm\model\Farmer();
+
+ $lat = !empty($input['lat']) ? $input['lat'] : 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';
+ //门店列表
+ $store = $farmer_model->where($dis)->field(['*', $alh])->order('distance,id desc')->limit(10)->select()->toArray();
+
+ if (!empty($store)) {
+
+ foreach ($store as &$v) {
+
+ $v['distance'] = getDistances($v['lng'], $v['lat'], $lng, $lat);
+
+ $v['distance'] = $farmer_model->getDistanceAttr($v['distance']);
+
+ }
+
+ }
+
+ return $this->success($store);
+ }
+
/**
* @author chenniang
* @DataTime: 2022-03-02 16:58
* @功能说明:首页
*/
- public function index(){
+ public function index()
+ {
$input = $this->_param;
@@ -72,13 +123,13 @@ class Index extends ApiRest
$banner_model = new Banner();
- foreach ($arr as $k=>$v){
+ foreach ($arr as $k => $v) {
$dis = [
- 'type' => $k,
+ 'type' => $k,
- 'status' => 1,
+ 'status' => 1,
'uniacid' => $this->_uniacid
];
@@ -86,44 +137,44 @@ class Index extends ApiRest
$data['banner'][$v] = $banner_model->where($dis)->order('top desc,id desc')->select()->toArray();
}
- $where[] = ['uniacid','=',$this->_uniacid];
+ $where[] = ['uniacid', '=', $this->_uniacid];
- $where[] = ['status','=',1];
+ $where[] = ['status', '=', 1];
- $where[] = ['type','=',0];
+ $where[] = ['type', '=', 0];
$us_model = new AboutUs();
$about = $us_model->dataInfo($where);
//收否有关于我们
- $data['about_us'] = !empty($about)?1:0;
+ $data['about_us'] = !empty($about) ? 1 : 0;
$dis = [
'uniacid' => $this->_uniacid,
- 'status' => 2,
+ 'status' => 2,
- 'type' => 2,
+ 'type' => 2,
'business_status' => 1
];
$farmer_model = new \app\farm\model\Farmer();
- $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';
//门店列表
- $store = $farmer_model->where($dis)->field(['*',$alh])->order('distance,id desc')->limit(3)->select()->toArray();
+ $store = $farmer_model->where($dis)->field(['*', $alh])->order('distance,id desc')->limit(3)->select()->toArray();
- if(!empty($store)){
+ if (!empty($store)) {
- foreach ($store as &$v){
+ foreach ($store as &$v) {
- $v['distance'] = getDistances($v['lng'],$v['lat'],$lng,$lat);
+ $v['distance'] = getDistances($v['lng'], $v['lat'], $lng, $lat);
$v['distance'] = $farmer_model->getDistanceAttr($v['distance']);
@@ -142,15 +193,15 @@ class Index extends ApiRest
$welfare_model = new WelfareColumn();
- foreach ($arr as $k=>$value){
+ foreach ($arr as $k => $value) {
$dis = [
'uniacid' => $this->_uniacid,
- 'status' => 1,
+ 'status' => 1,
- 'type' => $k
+ 'type' => $k
];
$data[$value] = $welfare_model->where($dis)->order('top desc,id desc')->limit(5)->select()->toArray();
@@ -165,7 +216,7 @@ class Index extends ApiRest
'index_show' => 1,
- 'status' => 1
+ 'status' => 1
];
$data['hot_goods'] = $goods_model->where($dis)->order('top desc,id desc')->limit(3)->select()->toArray();
@@ -174,23 +225,15 @@ class Index extends ApiRest
}
-
-
-
-
-
-
-
/**
* @author chenniang
* @DataTime: 2022-02-18 16:41
* @功能说明:获取天气
*/
- public function weather(){
-
+ public function weather()
+ {
$input = $this->_param;
-
- $dis = [
+ $dis = [
'uniacid' => $this->_uniacid
];
@@ -199,33 +242,33 @@ class Index extends ApiRest
$config = $config_model->dataInfo($dis);
- $url = 'https://apis.map.qq.com/ws/geocoder/v1/?location='.$input['lat'].','.$input['lng'];
+ $url = 'https://apis.map.qq.com/ws/geocoder/v1/?location=' . $input['lat'] . ',' . $input['lng'];
- $url = $url.'&key='.$config['map_secret'];
+ $url = $url . '&key=' . $config['map_secret'];
- $location = longbingCurl($url,[]);
+ $location = longbingCurl($url, []);
- $location = json_decode($location,true);
+ $location = json_decode($location, true);
$data['weather'] = [];
- if(!empty($location['result']['address_component'])){
+ if (!empty($location['result']['address_component'])) {
$location = $location['result']['address_component'];
- if(!empty($location['province'])){
+ if (!empty($location['province'])) {
$province = $location['province'];
- $city = $location['city'];
+ $city = $location['city'];
- $county = $location['district'];
+ $county = $location['district'];
- $url = 'https://wis.qq.com/weather/common?source=pc&weather_type=observe|forecast_24h|air&province='.$province.'&city='.$city.'&county='.$county;
+ $url = 'https://wis.qq.com/weather/common?source=pc&weather_type=observe|forecast_24h|air&province=' . $province . '&city=' . $city . '&county=' . $county;
$weather = file_get_contents($url);
- $weather = @json_decode($weather,true);
+ $weather = @json_decode($weather, true);
//天气
$data['weather'] = $weather;
}
@@ -242,10 +285,9 @@ class Index extends ApiRest
* @DataTime: 2021-03-23 14:16
* @功能说明:获取配置信息
*/
- public function configInfo(){
-
+ public function configInfo()
+ {
$dis = [
-
'uniacid' => $this->_uniacid
];
@@ -258,21 +300,21 @@ class Index extends ApiRest
}
-
/**
* @author chenniang
* @DataTime: 2021-12-30 15:21
* @功能说明:
*/
- public function farmerSelectList(){
+ public function farmerSelectList()
+ {
$dis = [
'uniacid' => $this->_uniacid,
- 'status' => 2,
+ 'status' => 2,
- 'type' => 1
+ 'type' => 1
];
$farmer_model = new \app\farm\model\Farmer();
@@ -289,34 +331,35 @@ class Index extends ApiRest
* @DataTime: 2022-01-07 14:35
* @功能说明:农场列表
*/
- public function farmerList(){
+ public function farmerList()
+ {
$input = $this->_param;
- $dis[] = ['uniacid','=',$this->_uniacid];
+ $dis[] = ['uniacid', '=', $this->_uniacid];
- $dis[] = ['status','=',2];
+ $dis[] = ['status', '=', 2];
- $dis[] = ['type','=',1];
+ $dis[] = ['type', '=', 1];
- if(!empty($input['title'])){
+ if (!empty($input['title'])) {
- $dis[] = ['title','like','%'.$input['title'].'%'];
+ $dis[] = ['title', 'like', '%' . $input['title'] . '%'];
}
- $sort = !empty($input['sort'])?$input['sort']:2;
+ $sort = !empty($input['sort']) ? $input['sort'] : 2;
$farmer_model = new \app\farm\model\Farmer();
- $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';
- switch ($sort){
+ switch ($sort) {
case 1:
@@ -337,15 +380,15 @@ class Index extends ApiRest
break;
}
- $data = $farmer_model->where($dis)->field(['*',$alh])->order($top)->paginate(10)->toArray();
+ $data = $farmer_model->where($dis)->field(['*', $alh])->order($top)->paginate(10)->toArray();
- if(!empty($data['data'])){
+ if (!empty($data['data'])) {
- foreach ($data['data'] as &$v){
+ foreach ($data['data'] as &$v) {
$dis = [
- 'type' => 2,
+ 'type' => 2,
'user_id' => $v['user_id'],
@@ -368,7 +411,8 @@ class Index extends ApiRest
* @功能说明:农场详情
*
*/
- public function farmerInfo(){
+ public function farmerInfo()
+ {
$input = $this->_param;
@@ -381,11 +425,11 @@ class Index extends ApiRest
$data = $farmer_model->dataInfo($dis);
- $farmer_model->dataUpdate($dis,['iv'=>$data['iv']+1]);
+ $farmer_model->dataUpdate($dis, ['iv' => $data['iv'] + 1]);
$dis = [
- 'type' => 2,
+ 'type' => 2,
'user_id' => $data['user_id'],
@@ -404,15 +448,16 @@ class Index extends ApiRest
* @DataTime: 2022-01-06 15:21
* @功能说明:文章详情
*/
- public function articleInfo(){
+ public function articleInfo()
+ {
$input = $this->_param;
$article_model = new Article();
- $data = $article_model->dataInfo(['id'=>$input['article_id']]);
+ $data = $article_model->dataInfo(['id' => $input['article_id']]);
- $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']);
return $this->success($data);
@@ -425,19 +470,20 @@ class Index extends ApiRest
* @DataTime: 2021-12-30 11:51
* @功能说明:关于我们列表
*/
- public function aboutUsList(){
+ public function aboutUsList()
+ {
$input = $this->_param;
- $dis[] = ['uniacid','=',$this->_uniacid];
+ $dis[] = ['uniacid', '=', $this->_uniacid];
- $dis[] = ['status','=',1];
+ $dis[] = ['status', '=', 1];
- $dis[] = ['type','=',0];
+ $dis[] = ['type', '=', 0];
- if(!empty($input['title'])){
+ if (!empty($input['title'])) {
- $dis[] = ['title','like','%'.$input['title'].'%'];
+ $dis[] = ['title', 'like', '%' . $input['title'] . '%'];
}
$us_model = new AboutUs();
@@ -454,15 +500,16 @@ class Index extends ApiRest
* @DataTime: 2021-11-08 13:23
* @功能说明:我们列表详情
*/
- public function aboutUsInfoType(){
+ public function aboutUsInfoType()
+ {
$input = $this->_param;
- $input['type'] = !empty($input['type'])?$input['type']:0;
+ $input['type'] = !empty($input['type']) ? $input['type'] : 0;
$dis = [
- 'type'=> $input['type'],
+ 'type' => $input['type'],
'uniacid' => $this->_uniacid
];
@@ -471,9 +518,9 @@ class Index extends ApiRest
$res = $us_model->dataInfo($dis);
- if(!empty($input['type'])&&empty($res)){
+ if (!empty($input['type']) && empty($res)) {
- $title = $input['type']==1?'动物认养协议':'土地租赁协议';
+ $title = $input['type'] == 1 ? '动物认养协议' : '土地租赁协议';
$dis['title'] = $title;
@@ -491,7 +538,8 @@ class Index extends ApiRest
* @DataTime: 2022-02-09 17:07
* @功能说明:添加评价
*/
- public function evaluateAdd(){
+ public function evaluateAdd()
+ {
$input = $this->_input;
@@ -501,12 +549,12 @@ class Index extends ApiRest
'order_id' => $input['order_id'],
- 'type' => $input['type']
+ 'type' => $input['type']
];
- $find = $eva_model->where($dis)->where('status','>',-1)->find();
+ $find = $eva_model->where($dis)->where('status', '>', -1)->find();
- if(!empty($find)){
+ if (!empty($find)) {
$this->errorMsg('你已经评价过该订单了');
}
@@ -517,19 +565,19 @@ class Index extends ApiRest
'user_id' => $this->getUserId(),
- 'order_id'=> $input['order_id'],
+ 'order_id' => $input['order_id'],
- 'star' => $input['star'],
+ 'star' => $input['star'],
- 'type' => $input['type'],
+ 'type' => $input['type'],
- 'order_code'=> $input['order_code'],
+ 'order_code' => $input['order_code'],
- 'text' => $input['text'],
+ 'text' => $input['text'],
- 'imgs' => !empty($input['imgs'])?implode(',',$input['imgs']):'',
+ 'imgs' => !empty($input['imgs']) ? implode(',', $input['imgs']) : '',
- 'farmer_id' => !empty($input['farmer_id'])?$input['farmer_id']:0,
+ 'farmer_id' => !empty($input['farmer_id']) ? $input['farmer_id'] : 0,
];
@@ -547,33 +595,34 @@ class Index extends ApiRest
* @DataTime: 2022-02-09 17:17
* @功能说明:用户评列表
*/
- public function userEvaluateList(){
+ public function userEvaluateList()
+ {
$input = $this->_param;
$eva_model = new Evaluate();
- $dis[] = ['user_id','=',$this->getUserId()];
+ $dis[] = ['user_id', '=', $this->getUserId()];
- $dis[] = ['status','>',-1];
+ $dis[] = ['status', '>', -1];
- if(!empty($input['type'])){
+ if (!empty($input['type'])) {
- $dis[] = ['type','=',$input['type']];
+ $dis[] = ['type', '=', $input['type']];
}
$data = $eva_model->dataList($dis);
- 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']);
- if(!empty($v['order_info']['end_time'])){
+ if (!empty($v['order_info']['end_time'])) {
- $v['order_info']['end_time'] = date('Y-m-d H:i:s',$v['order_info']['end_time']);
+ $v['order_info']['end_time'] = date('Y-m-d H:i:s', $v['order_info']['end_time']);
}
@@ -591,13 +640,14 @@ class Index extends ApiRest
* @DataTime: 2022-02-09 17:21
* @功能说明:评价详情
*/
- public function evaluateInfo(){
+ public function evaluateInfo()
+ {
$input = $this->_param;
$eva_model = new Evaluate();
- $dis =[
+ $dis = [
'id' => $input['id']
];
@@ -614,22 +664,23 @@ class Index extends ApiRest
* @DataTime: 2022-02-09 17:21
* @功能说明:评价详情
*/
- public function evaluateUpdate(){
+ public function evaluateUpdate()
+ {
$input = $this->_input;
$eva_model = new Evaluate();
- $dis =[
+ $dis = [
'id' => $input['id']
];
$info = $eva_model->dataInfo($dis);
- $data = $eva_model->dataUpdate($dis,$input);
+ $data = $eva_model->dataUpdate($dis, $input);
- if(!empty($input['status'])&&$input['status']==-1){
+ if (!empty($input['status']) && $input['status'] == -1) {
//修改农场主的评分
$res = $eva_model->updateFarmerStar($info['farmer_id']);
}
@@ -644,7 +695,8 @@ class Index extends ApiRest
* @DataTime: 2022-02-10 17:23
* @功能说明:待评价订单
*/
- public function noEvaluateOrderList(){
+ public function noEvaluateOrderList()
+ {
$input = $this->_param;
@@ -656,39 +708,39 @@ class Index extends ApiRest
'user_id' => $this->getUserId(),
- 'type' => $input['type']
+ 'type' => $input['type']
];
- $order_id = $eva_model->where($where)->where('status','>',-1)->column('order_id');
+ $order_id = $eva_model->where($where)->where('status', '>', -1)->column('order_id');
- $dis[] = ['user_id','=',$this->getUserId()];
+ $dis[] = ['user_id', '=', $this->getUserId()];
- if($input['type']==2){
+ if ($input['type'] == 2) {
- $dis[] = ['pay_type','>',1];
+ $dis[] = ['pay_type', '>', 1];
- }else{
+ } else {
- $dis[] = ['pay_type','=',7];
+ $dis[] = ['pay_type', '=', 7];
}
- $dis[] = ['id','not in',$order_id];
+ $dis[] = ['id', 'not in', $order_id];
- $data = $model->dataList($dis,10);
+ $data = $model->dataList($dis, 10);
- if(!empty($data['data'])){
+ if (!empty($data['data'])) {
$farmer_model = new \app\farm\model\Farmer();
- foreach ($data['data'] as &$v){
+ foreach ($data['data'] as &$v) {
- $farmer_id = !empty($v['farmer_id'])?$v['farmer_id']:0;
+ $farmer_id = !empty($v['farmer_id']) ? $v['farmer_id'] : 0;
- $v['farmer_info'] = $farmer_model->dataInfo(['id'=>$farmer_id],'title');
+ $v['farmer_info'] = $farmer_model->dataInfo(['id' => $farmer_id], 'title');
- if(!empty($v['end_time'])){
+ if (!empty($v['end_time'])) {
- $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']);
}
}
@@ -705,16 +757,16 @@ class Index extends ApiRest
* @DataTime: 2022-02-11 10:11
* @功能说明:根据type获取对应物品的评价
*/
- public function goodsEvaluateList(){
+ public function goodsEvaluateList()
+ {
$input = $this->_param;
$eva_model = new Evaluate();
- $data = $eva_model->goodsEvaluateList($input['goods_id'],$input['type'],$input['is_goods']);
+ $data = $eva_model->goodsEvaluateList($input['goods_id'], $input['type'], $input['is_goods']);
return $this->success($data);
-
}
@@ -723,14 +775,14 @@ class Index extends ApiRest
* @DataTime: 2022-03-09 16:50
* @功能说明:模版列表
*/
- public function tmpList(){
+ public function tmpList()
+ {
//模版消息model
$tmpl_model = new TmplConfig();
//获取模版
- $tmpl = $tmpl_model->where(['uniacid'=>$this->_uniacid])->select()->toArray();
+ $tmpl = $tmpl_model->where(['uniacid' => $this->_uniacid])->select()->toArray();
return $this->success($tmpl);
-
}
@@ -739,45 +791,46 @@ class Index extends ApiRest
* @DataTime: 2022-04-11 15:56
* @功能说明:监控列表
*/
- public function monitorList(){
+ public function monitorList()
+ {
$input = $this->_param;
- $dis[] = ['a.uniacid','=',$this->_uniacid];
+ $dis[] = ['a.uniacid', '=', $this->_uniacid];
- 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 {
//我的菜地
$land_model = new LandOrder();
- $claim_model= new ClaimOrder();
+ $claim_model = new ClaimOrder();
$monitor_text_model = new MonitorText();
$land_text_model = new LandText();
- $land_id = $land_model->where(['user_id'=>$this->getUserId()])->where('pay_type','>',1)->column('land_id');
+ $land_id = $land_model->where(['user_id' => $this->getUserId()])->where('pay_type', '>', 1)->column('land_id');
- $obj_id = $land_text_model->where('land_id','in',$land_id)->where(['type'=>4])->column('obj_id');
+ $obj_id = $land_text_model->where('land_id', 'in', $land_id)->where(['type' => 4])->column('obj_id');
- $claim_id= $claim_model->where(['user_id'=>$this->getUserId()])->where('pay_type','>',1)->column('goods_id');
+ $claim_id = $claim_model->where(['user_id' => $this->getUserId()])->where('pay_type', '>', 1)->column('goods_id');
- $obj_id_v2 = $monitor_text_model->where('obj_id','in',$claim_id)->where(['type'=>2])->column('monitor_id');
+ $obj_id_v2 = $monitor_text_model->where('obj_id', 'in', $claim_id)->where(['type' => 2])->column('monitor_id');
- $monitor_id = array_merge($obj_id,$obj_id_v2);
+ $monitor_id = array_merge($obj_id, $obj_id_v2);
- $dis[] = ['a.id','in',$monitor_id];
+ $dis[] = ['a.id', 'in', $monitor_id];
}
- $dis[] = ['a.status','=',1];
+ $dis[] = ['a.status', '=', 1];
- if(!empty($input['title'])){
+ if (!empty($input['title'])) {
- $dis[] = ['a.title','like','%'.$input['title'].'%'];
+ $dis[] = ['a.title', 'like', '%' . $input['title'] . '%'];
}
@@ -795,7 +848,8 @@ class Index extends ApiRest
* @DataTime: 2022-04-11 16:31
* @功能说明:获取监控地址
*/
- public function getMonitorInfo(){
+ public function getMonitorInfo()
+ {
$input = $this->_param;
@@ -817,7 +871,8 @@ class Index extends ApiRest
* @DataTime: 2022-04-12 11:01
* @功能说明:获取萤石云token
*/
- public function getYsToken(){
+ public function getYsToken()
+ {
$api = new YsCloudApi($this->_uniacid);
@@ -833,7 +888,8 @@ class Index extends ApiRest
* @DataTime: 2022-04-12 11:02
* @功能说明:旋转摄像头
*/
- public function ysStartTurn(){
+ public function ysStartTurn()
+ {
$input = $this->_param;
@@ -841,22 +897,22 @@ class Index extends ApiRest
$api = new YsCloudApi($this->_uniacid);
- $monitor = $monitor_model->dataInfo(['id'=>$input['id']]);
+ $monitor = $monitor_model->dataInfo(['id' => $input['id']]);
- $res = $api->startTurn($monitor['deviceSerial'],$input['direction'],$monitor['channelNo']);
+ $res = $api->startTurn($monitor['deviceSerial'], $input['direction'], $monitor['channelNo']);
return $this->success($res);
}
-
/**
* @author chenniang
* @DataTime: 2022-04-12 11:02
* @功能说明:停止旋转摄像头
*/
- public function ysStopTurn(){
+ public function ysStopTurn()
+ {
$input = $this->_param;
@@ -864,25 +920,24 @@ class Index extends ApiRest
$api = new YsCloudApi($this->_uniacid);
- $monitor = $monitor_model->dataInfo(['id'=>$input['id']]);
+ $monitor = $monitor_model->dataInfo(['id' => $input['id']]);
- $direction = !empty($input['direction'])?$input['direction']:0;
+ $direction = !empty($input['direction']) ? $input['direction'] : 0;
- $res = $api->stopTurn($monitor['deviceSerial'],$direction,$monitor['channelNo']);
+ $res = $api->stopTurn($monitor['deviceSerial'], $direction, $monitor['channelNo']);
return $this->success($res);
}
-
public function haveStore()
{
$data = $this->getStoreInfo(2);
- $res = !empty($data)?true:false;
+ $res = !empty($data) ? true : false;
return $this->success($res);
@@ -895,27 +950,28 @@ class Index extends ApiRest
* @DataTime: 2022-07-22 17:34
* @功能说明:公益列表
*/
- public function welfareColumnList(){
+ public function welfareColumnList()
+ {
$input = $this->_param;
- $dis[] = ['uniacid','=',$this->_uniacid];
+ $dis[] = ['uniacid', '=', $this->_uniacid];
- $dis[] = ['status','=',1];
+ $dis[] = ['status', '=', 1];
- $type = !empty($input['type'])?$input['type']:1;
+ $type = !empty($input['type']) ? $input['type'] : 1;
- $dis[] = ['type','=',$type];
+ $dis[] = ['type', '=', $type];
$model = new WelfareColumn();
- if(!empty($input['title'])){
+ if (!empty($input['title'])) {
- $dis[] = ['title','like','%'.$input['title'].'%'];
+ $dis[] = ['title', 'like', '%' . $input['title'] . '%'];
}
- $data = $model->dataList($dis,10,'id,title,cover,create_time');
+ $data = $model->dataList($dis, 10, 'id,title,cover,create_time');
return $this->success($data);
@@ -926,13 +982,14 @@ class Index extends ApiRest
* @DataTime: 2022-07-22 17:34
* @功能说明:公益列表
*/
- public function welfareColumnInfo(){
+ public function welfareColumnInfo()
+ {
$input = $this->_param;
$dis = [
- 'id' => $input['id'],
+ 'id' => $input['id'],
'status' => 1
];
@@ -946,52 +1003,51 @@ class Index extends ApiRest
}
-
-
/**
* @author chenniang
* @DataTime: 2022-06-15 16:29
* @功能说明:优惠券
*/
- public function couponList(){
+ public function couponList()
+ {
$coupon_record_model = new CouponRecord();
$coupon_model = new Coupon();
- if(empty($this->getUserId())){
+ if (empty($this->getUserId())) {
return $this->success([]);
}
- $have_get = $coupon_record_model->where(['user_id'=>$this->getUserId()])->column('coupon_id');
+ $have_get = $coupon_record_model->where(['user_id' => $this->getUserId()])->column('coupon_id');
- $dis[] = ['uniacid','=',$this->_uniacid];
+ $dis[] = ['uniacid', '=', $this->_uniacid];
- $dis[] = ['send_type','=',2];
+ $dis[] = ['send_type', '=', 2];
- $dis[] = ['status','=',1];
+ $dis[] = ['status', '=', 1];
- $dis[] = ['stock','>',0];
+ $dis[] = ['stock', '>', 0];
- $dis[] = ['id','not in',$have_get];
+ $dis[] = ['id', 'not in', $have_get];
$where = [];
- $where[] = ['time_limit','=',2];
+ $where[] = ['time_limit', '=', 2];
- $where[] = ['end_time','>',time()];
+ $where[] = ['end_time', '>', time()];
- $data = $coupon_model->where($dis)->where(function ($query) use ($where){
+ $data = $coupon_model->where($dis)->where(function ($query) use ($where) {
$query->whereOr($where);
})->paginate(10)->toArray();
- if(!empty($coupon['data'])){
+ if (!empty($coupon['data'])) {
- foreach ($coupon['data'] as &$v){
+ foreach ($coupon['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']);
}
@@ -1007,15 +1063,16 @@ class Index extends ApiRest
* @DataTime: 2022-06-15 22:49
* @功能说明:用户获取卡券
*/
- public function userGetCoupon(){
+ public function userGetCoupon()
+ {
$input = $this->_input;
$coupon_record_model = new CouponRecord();
- $res = $coupon_record_model->recordAdd($input['coupon_id'],$this->getUserId(),1,1);
+ $res = $coupon_record_model->recordAdd($input['coupon_id'], $this->getUserId(), 1, 1);
- if(!empty($res['code'])){
+ if (!empty($res['code'])) {
$this->errorMsg($res['msg']);
}
@@ -1024,6 +1081,4 @@ class Index extends ApiRest
}
-
-
}
diff --git a/app/farm/controller/IndexClaim.php b/app/farm/controller/IndexClaim.php
index 21550a2..924ff54 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']