public static function getSalesOrderBy($categoryId = '') { $where = ''; if ($categoryId) { $items = Tree::find()->where(['tree_id' => $categoryId])->all(); $itemIds = ArrayHelper::getColumn($items, 'item_id'); $where = ' where item_id in (' . implode(',', $itemIds) . ') '; } $sql = 'SELECT name, count(item_id) as count FROM `order_item` ' . $where . ' group by item_id order by count desc'; return Yii::$app->db->createCommand($sql)->queryAll(); }
public static function getTreesById($id) { /** @var \common\models\Tree|\creocoder\nestedsets\NestedSetsBehavior $root */ $root = static::find()->where(['id' => $id])->one(); if ($root) { $categories = Tree::find()->where('lft >= ' . $root->lft . ' and rgt <= ' . $root->rgt . ' and root = ' . $root->root . ' order by id desc')->indexBy('id')->all(); return array_map(function ($cate) use($root) { return $cate->name; }, $categories); } else { return false; } }
$form = ActiveForm::begin(); $fieldGroups = []; $fields = []; $stations = \core\models\Station::findAll(['enabled' => 1]); $stationArray = ArrayHelper::map($stations, 'id', 'name'); $fields[] = $form->field($model, 'star_id')->dropDownList($stationArray); $fields[] = $form->field($model, 'total')->textInput(['maxlength' => true]); $fields[] = $form->field($model, 'desc')->textarea(['maxlength' => true]); $fields[] = $form->field($model, 'status')->dropDownList([1 => '是', 0 => '否']); $fields[] = $form->field($model, 'start_at')->widget(DateTimePicker::className(), ['options' => ['value' => $start_at], 'pluginOptions' => ['language' => 'zh-CN', 'autoclose' => true]]); $fields[] = $form->field($model, 'end_at')->widget(DateTimePicker::className(), ['options' => ['value' => $end_at], 'pluginOptions' => ['language' => 'zh-CN', 'autoclose' => true]]); $fieldGroups[] = ['label' => Yii::t('marketing', 'Coupon Info'), 'content' => implode('', $fields)]; $fields = []; $fields[] = $form->field($model, 'total_price')->textInput(['maxlength' => true]); $fields[] = $form->field($model, 'qty')->textInput(['maxlength' => true]); $root = \common\models\Tree::find()->where(['name' => '商品分类'])->one(); $categories = $root->children(1)->all(); $categories = ArrayHelper::map($categories, 'id', 'name'); $fields[] = $form->field($model, 'category_id')->widget(Select2::classname(), ['data' => $categories, 'language' => 'en', 'pluginOptions' => ['placeholder' => 'Select a state ...'], 'options' => ['multiple' => true]]); $fieldGroups[] = ['label' => Yii::t('marketing', 'Coupon Conditions'), 'content' => implode('', $fields)]; $fields = []; $fields[] = $form->field($model, 'type')->dropDownList([0 => '满减', 1 => '打折']); $fields[] = $form->field($model, 'number')->textInput(['maxlength' => true]); $fields[] = $form->field($model, 'shipping')->dropDownList([0 => '邮费不变', 1 => '减邮费', 2 => '包邮']); $fields[] = $form->field($model, 'shippingFee')->textInput(['maxlength' => true]); $fieldGroups[] = ['label' => Yii::t('marketing', 'Coupon Result'), 'content' => implode('', $fields)]; echo Tabs::widget(['items' => $fieldGroups]); ?> <div class="form-group"> <?php
</fieldset> <button type="reset" class="color_dark bg_tr text_cs_hover tr_all_hover"><i class="fa fa-refresh lh_inherit m_right_10"></i>Reset </button> </form> </div> </figure> <figure class="widget shadow r_corners wrapper m_bottom_30"> <figcaption> <h3 class="color_light">Categories</h3> </figcaption> <div class="widget_content"> <!--Categories list--> <ul class="categories_list"> <?php $tree = Tree::find()->where(['name' => '商品分类'])->one(); $childrenTags = $tree->children('1')->all(); foreach ($childrenTags as $childrenTag) { $secondChildren = $childrenTag->children('1')->all(); ?> <li> <a href="<?php echo Url::to(['/catalog/home/item/list', 'catalog' => $childrenTag->id]); ?> " class="f_size_large color_dark d_block relative"> <b><?php echo $childrenTag->name; ?> </b> <span class="bg_light_color_1 r_corners f_right color_dark talign_c"></span> </a>