| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\alliance\controllers;
- use app\models\NewIntegralCat;
- use app\models\NewIntegralSetting;
- use app\models\Goods;
- use app\models\GoodsCat;
- use app\models\User;
- class IntegralController extends BaseController
- {
- //积分商城信息
- public function actionIndex(){
- $store_id = get_store_id();
- if ($store_id <= 0) {
- $store_id = 0;
- }
- $settingInfo = NewIntegralSetting::find()->where(['store_id' => $store_id])->asArray()->one();
- $catInfo = NewIntegralCat::find()->where(['store_id' => $store_id,'is_enable'=>1,'is_delete'=>0])->select('id,name')->orderBy('sort')->asArray()->all();
- $data = [];
- $data['polling'] = (isset($settingInfo['polling_img']) && $settingInfo['polling_img']) ? json_decode($settingInfo['polling_img'],true) : null;
- $data['explain'] = (isset($settingInfo['explain']) && $settingInfo['explain']) ? $settingInfo['explain'] : null;
- $data['catInfo'] = $catInfo;
- if ($store_id <= 0) {
- $data['integral'] = get_saas_user()->integral;
- } else {
- $data['integral'] = get_user()->integral;
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data
- ]);
- }
- //商品列表
- public function actionGoodsInfo(){
- $store_id = get_store_id();
- if ($store_id <= 0) {
- $store_id = 0;
- }
- $level = get_params('level',0);
- $catId = get_params('cat_id',0);
- $keyword = get_params('keyword');
- $query = Goods::find()->alias('g')->where(['g.store_id' => $store_id, 'g.product_type'=>Goods::GOODS_TYPE_INTEGRAL, 'g.status' => 1, 'g.is_delete' => 0]);
- if($level == 1){
- $query->andWhere(['<=','g.integral_price',100]);
- }
- if($level == 2){
- $query->andWhere(['>','g.integral_price',100]);
- $query->andWhere(['<=','g.integral_price',500]);
- }
- if($level == 3){
- $query->andWhere(['>','g.integral_price',500]);
- $query->andWhere(['<=','g.integral_price',1000]);
- }
- if($level == 4){
- $query->andWhere(['>','g.integral_price',1000]);
- }
- if($catId){
- $query->leftJoin(['gc' => GoodsCat::tableName()], 'gc.goods_id=g.id')->andWhere(['gc.cat_id' => $catId]);
- }
- if ($keyword) {
- $query->andWhere([
- 'or',
- ['like', 'g.name', $this->keyword],
- ['like', 'g.key_word', $this->keyword],
- ]);
- }
- $query->select('g.id,g.name,g.price,g.original_price,g.integral_price,g.cover_pic,g.virtual_sales');
- $list = pagination_make($query);
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'data' => $list['list'],
- 'pageNo' => $list['pageNo'],
- 'totalCount' => $list['totalCount'],
- ]
- ]);
- }
- }
|