105 lines
2.7 KiB
PHP
105 lines
2.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2020-12-2
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
|
|
namespace app\modules\api\models;
|
|
|
|
use function AlibabaCloud\Client\value;
|
|
use app\components\FlashStorage;
|
|
use app\components\SiteHelper;
|
|
use app\components\SysConst;
|
|
use app\models\Box;
|
|
use app\models\Coach;
|
|
use app\models\Goods;
|
|
use app\models\GoodsHub;
|
|
use app\models\Order;
|
|
use app\models\OrderDetail;
|
|
use app\models\Store;
|
|
use app\models\StoreBj;
|
|
use app\models\User;
|
|
use app\components\auth\AToken;
|
|
use app\components\EncryptHelper;
|
|
use app\modules\api\components\ApiHelper;
|
|
use app\modules\api\components\DateHelp;
|
|
use app\modules\api\components\GetDistance;
|
|
use yii\data\Pagination;
|
|
|
|
|
|
class BoxForm extends ApiModel
|
|
{
|
|
|
|
public $limit;//条数
|
|
public $page; //页数
|
|
public $pageCount; // 总页数
|
|
|
|
public $bj_id;
|
|
public $keywords;
|
|
|
|
|
|
public function rules()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* 包厢列表
|
|
*/
|
|
public function search()
|
|
{
|
|
|
|
$query = Box::find()->alias('b')
|
|
->leftJoin(['goods' => Goods::tableName()], 'b.goods_id=goods.id')
|
|
->leftJoin(['goodHub' => GoodsHub::tableName()], 'goods.goods_hub_id=goodHub.id')
|
|
->leftJoin(['storeBj' => StoreBj::tableName()], 'b.bj_id=storeBj.id')
|
|
->select('b.id,b.notice,b.created_at,b.cover_pic,b.status,goodHub.name as goods_name,storeBj.name as bj_name')
|
|
->where([
|
|
'b.status' => 1,
|
|
'b.is_delete' => 0
|
|
])
|
|
->andFilterWhere(['b.bj_id' => $this->bj_id])
|
|
->andFilterWhere(['OR',
|
|
['like', 'goodHub.name', $this->keywords]]);
|
|
|
|
$count = $query->count();
|
|
$pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]);
|
|
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['b.sort'=>SORT_DESC,'b.id' => SORT_DESC])->asArray()->all();
|
|
foreach ($list as $index => $item) {
|
|
// $item['business'] = $item['begin_time'] . '-' . $item['end_time'];
|
|
$list[$index]['created_at_cn'] = date("Y-m-d H:i", $item['created_at']);
|
|
if ($item['cover_pic'] != null) {
|
|
$pic_arr = json_decode($item['cover_pic'], true);
|
|
|
|
$list[$index]['cover_pic_arr'] = $pic_arr;
|
|
|
|
}
|
|
|
|
}
|
|
$data = [];
|
|
$data['code'] = 0;
|
|
$data['msg'] = 'ok';
|
|
$data['data'] = $list;
|
|
$data['count'] = $count;
|
|
return $data;
|
|
}
|
|
|
|
|
|
public function lists()
|
|
{
|
|
$store = StoreBj::find()->where(['is_delete' => 0, 'status' => 1])->asArray()->all();
|
|
$data = [];
|
|
$data['code'] = 0;
|
|
$data['msg'] = 'ok';
|
|
$data['data'] = $store;
|
|
return $data;
|
|
}
|
|
|
|
} |