974 lines
32 KiB
PHP
974 lines
32 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2022年6月1日
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
|
|
namespace app\modules\admin\controllers\mall;
|
|
|
|
use app\models\Cat1;
|
|
use app\models\Cat2;
|
|
use app\models\Cat3;
|
|
use app\models\Cat4;
|
|
use app\models\common\CommonCat1ActionForm;
|
|
use app\models\common\CommonCat1EditForm;
|
|
use app\models\common\CommonCat1ListForm;
|
|
use app\models\common\CommonCat2ActionForm;
|
|
use app\models\common\CommonCat2EditForm;
|
|
use app\models\common\CommonCat2ListForm;
|
|
use app\models\common\CommonCat3ActionForm;
|
|
use app\models\common\CommonCat3EditForm;
|
|
use app\models\common\CommonCat3ListForm;
|
|
use app\models\common\CommonCat4ActionForm;
|
|
use app\models\common\CommonCat4EditForm;
|
|
use app\models\common\CommonCat4ListForm;
|
|
use app\models\Model;
|
|
use yii\helpers\VarDumper;
|
|
use app\modules\admin\controllers\Controller;
|
|
use app\modules\admin\behaviors\LoginBehavior;
|
|
use app\models\common\CommonGoodsActionForm;
|
|
use app\models\common\CommonGoodsListForm;
|
|
use app\models\common\CommonGoodsEditForm;
|
|
use app\models\common\CommonCatActionForm;
|
|
use app\models\common\CommonCatListForm;
|
|
use app\models\common\CommonCatEditForm;
|
|
use app\components\SysConst;
|
|
use app\models\Cat;
|
|
use app\models\Goods;
|
|
use app\models\GoodsAttr;
|
|
use app\models\GoodsCat;
|
|
|
|
|
|
class GoodsController extends Controller
|
|
{
|
|
public function behaviors()
|
|
{
|
|
return array_merge(parent::behaviors(), [
|
|
'login' => [
|
|
'class' => LoginBehavior::className(),
|
|
],
|
|
]);
|
|
}
|
|
|
|
|
|
public function actionIndex()
|
|
{
|
|
if (\Yii::$app->request->isAjax) {
|
|
$form = new CommonGoodsListForm();
|
|
$form->attributes = \Yii::$app->request->get();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
// $form->plugin_sign = SysConst::$cxPluginSceneMall;
|
|
$form->setFields('g.id,g.goods_hub_id,g.date,g.status,g.price,g.goods_stock,g.virtual_sales,g.sort,g.created_at,g.payment_people,g.payment_amount,g.payment_num,g.payment_order,g.sales,g.viewed_count,gh.name,gh.cover_pic,gh.unit,gh.type');
|
|
$data = $form->search();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$cat_list = Cat::find()
|
|
->where([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'is_delete' => 0,
|
|
'type' => Cat::TYPE_GOODS,
|
|
])
|
|
->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC])
|
|
->select('id,name')->asArray()->all();
|
|
|
|
$cat_list1 = Cat1::find()
|
|
->where([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'is_delete' => 0,
|
|
'type' => Cat::TYPE_GOODS,
|
|
])
|
|
->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC])
|
|
->select('id,name')->asArray()->all();
|
|
|
|
$cat_list2 = Cat2::find()
|
|
->where([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'is_delete' => 0,
|
|
'type' => Cat::TYPE_GOODS,
|
|
])
|
|
->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC])
|
|
->select('id,name')->asArray()->all();
|
|
|
|
|
|
$cat_list3 = Cat3::find()
|
|
->where([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'is_delete' => 0,
|
|
'type' => Cat::TYPE_GOODS,
|
|
])
|
|
->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC])
|
|
->select('id,name')->asArray()->all();
|
|
|
|
|
|
$cat_list4 = Cat4::find()
|
|
->where([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'is_delete' => 0,
|
|
'type' => Cat::TYPE_GOODS,
|
|
])
|
|
->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC])
|
|
->select('id,name')->asArray()->all();
|
|
return $this->render('index', [
|
|
'cat_list' => $cat_list,
|
|
'cat1_list' => $cat_list1,
|
|
'cat2_list' => $cat_list2,
|
|
'cat3_list' => $cat_list3,
|
|
'cat4_list' => $cat_list4,
|
|
|
|
]);
|
|
}
|
|
|
|
public function actionEdit($id = 0)
|
|
{
|
|
$model = Goods::findOne([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
// 'is_delete' => 0,
|
|
'id' => $id,
|
|
]);
|
|
|
|
if ($model == null)
|
|
$model = new Goods();
|
|
if (\Yii::$app->request->isPost) {
|
|
$form = new CommonGoodsEditForm();
|
|
$post = \Yii::$app->request->post();
|
|
$form->attributes = $post;
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->model = $model;
|
|
$form->type = 0;//默认实体商品
|
|
$data = $form->save();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$cat_list = Cat::find()
|
|
->where([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'is_delete' => 0,
|
|
'type' => Cat::TYPE_GOODS,
|
|
])
|
|
->orderBy(['sort' => SORT_ASC, 'id' => SORT_DESC])
|
|
->select('id,name')->asArray()->all();
|
|
|
|
$cat_list1 = Cat1::find()
|
|
->where([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'is_delete' => 0,
|
|
'type' => Cat::TYPE_GOODS,
|
|
])
|
|
->orderBy(['sort' => SORT_ASC, 'id' => SORT_DESC])
|
|
->select('id,name')->asArray()->all();
|
|
|
|
$cat_list2 = Cat2::find()
|
|
->where([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'is_delete' => 0,
|
|
'type' => Cat::TYPE_GOODS,
|
|
])
|
|
->orderBy(['sort' => SORT_ASC, 'id' => SORT_DESC])
|
|
->select('id,name')->asArray()->all();
|
|
|
|
$cat_list3 = Cat3::find()
|
|
->where([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'is_delete' => 0,
|
|
'type' => Cat::TYPE_GOODS,
|
|
])
|
|
->orderBy(['sort' => SORT_ASC, 'id' => SORT_DESC])
|
|
->select('id,name')->asArray()->all();
|
|
|
|
$cat_list4 = Cat4::find()
|
|
->where([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'is_delete' => 0,
|
|
'type' => Cat::TYPE_GOODS,
|
|
])
|
|
->orderBy(['sort' => SORT_ASC, 'id' => SORT_DESC])
|
|
->select('id,name')->asArray()->all();
|
|
|
|
|
|
$return_url = \Yii::$app->request->referrer;
|
|
|
|
$model->date = date('Y', $model->date);
|
|
|
|
|
|
|
|
$attr = [];
|
|
$attr_groups = [];
|
|
if ($model->use_attr == 1) {
|
|
$attr_groups = !empty($model->attr_groups) ? json_decode($model->attr_groups, true) : [];
|
|
$attr = GoodsAttr::find()->alias('ga')
|
|
->where([
|
|
'ga.goods_id' => $model->id,
|
|
'ga.is_delete' => 0
|
|
])
|
|
->select('ga.id,ga.price,ga.stock,ga.serial_no,ga.weight,ga.cover_pic,ga.sign_id')
|
|
->asArray()->all();
|
|
foreach ($attr as $index => $item) {
|
|
$item['attr_list'] = [];
|
|
$sign_ids = explode(':', $item['sign_id']);
|
|
foreach ($sign_ids as $attr_id) {
|
|
$attr_info = $this->getAttrInfo($attr_id, $attr_groups);
|
|
if (!empty($attr_info)) {
|
|
$item['attr_list'][] = $attr_info;
|
|
}
|
|
}
|
|
$attr[$index] = $item;
|
|
}
|
|
}
|
|
$video_url_data_url = "";
|
|
$video_url_data_title = "";
|
|
$video_url_data_img = "";
|
|
if(!empty($model->goodsHub->video_url_data)){
|
|
$json_decode = json_decode($model->goodsHub->video_url_data,true);
|
|
$video_url_data_url = $json_decode[0]['url'];
|
|
$video_url_data_title = $json_decode[0]['title'];
|
|
$video_url_data_img = $json_decode[0]['img'];
|
|
|
|
}
|
|
|
|
return $this->render('edit', [
|
|
'cat_list' => $cat_list,
|
|
'cat_list1' => $cat_list1,
|
|
'cat_list2' => $cat_list2,
|
|
'cat_list3' => $cat_list3,
|
|
'cat_list4' => $cat_list4,
|
|
'attr' => $attr,
|
|
'attr_groups' => $attr_groups,
|
|
'model' => $model,
|
|
'return_url' => $return_url,
|
|
'video_url_data_url' => $video_url_data_url,
|
|
'video_url_data_title' => $video_url_data_title,
|
|
'video_url_data_img' => $video_url_data_img,
|
|
]);
|
|
}
|
|
|
|
private function getAttrInfo($attr_id, $attr_groups)
|
|
{
|
|
$attr_info = [];
|
|
foreach ($attr_groups as $index => $attr_group) {
|
|
foreach ($attr_group['attr_list'] as $j => $attr) {
|
|
if ($attr['attr_id'] == $attr_id) {
|
|
$attr_info['attr_group_id'] = $attr_group['attr_group_id'];
|
|
$attr_info['attr_group_name'] = $attr_group['attr_group_name'];
|
|
$attr_info['attr_id'] = $attr['attr_id'];
|
|
$attr_info['attr_name'] = $attr['attr_name'];
|
|
return $attr_info;
|
|
}
|
|
}
|
|
}
|
|
return $attr_info;
|
|
|
|
}
|
|
|
|
|
|
public function actionDelete()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonGoodsActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->plugin_sign = SysConst::$cxPluginSceneMall;
|
|
$data = $form->delete();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionOnline()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonGoodsActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
// $form->plugin_sign = SysConst::$cxPluginSceneMall;
|
|
$data = $form->online();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionOffline()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonGoodsActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->plugin_sign = SysConst::$cxPluginSceneMall;
|
|
$data = $form->offline();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
|
|
public function actionCat()
|
|
{
|
|
if (\Yii::$app->request->isAjax) {
|
|
$form = new CommonCatListForm();
|
|
$form->attributes = \Yii::$app->request->get();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->search();
|
|
return $this->responseHandler($data);
|
|
}
|
|
return $this->render('cat');
|
|
}
|
|
|
|
public function actionCatEdit($id = 0)
|
|
{
|
|
$model = Cat::findOne([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'is_delete' => 0,
|
|
'id' => $id,
|
|
'type' => Cat::TYPE_GOODS,
|
|
]);
|
|
if ($model == null) {
|
|
$model = new Cat();
|
|
$model->status = 1;
|
|
}
|
|
if (\Yii::$app->request->isPost) {
|
|
$form = new CommonCatEditForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->model = $model;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->save();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$cat_ids = [];
|
|
$cat_ids[] = $model->isNewRecord ? 0 : $model->id;
|
|
$parent_list = Cat::find()
|
|
->where([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'is_delete' => 0,
|
|
'type' => Cat::TYPE_GOODS,
|
|
])
|
|
->andWhere([
|
|
'NOT IN',
|
|
'id',
|
|
$cat_ids
|
|
])
|
|
->select('id,name')->asArray()->all();
|
|
|
|
$is_has_parent = false;//开启是否有父节点
|
|
$parent_list = $is_has_parent ? $parent_list : [];
|
|
array_unshift($parent_list, ['id' => 0, 'name' => '无上级分类']);
|
|
$return_url = \Yii::$app->request->referrer;
|
|
return $this->render('cat-edit', [
|
|
'model' => $model,
|
|
'return_url' => $return_url,
|
|
'parent_list' => $parent_list
|
|
]);
|
|
}
|
|
|
|
public function actionCatDelete()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCatActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->delete();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionCatShow()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCatActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->show();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionCatHide()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCatActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->hide();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionCatOpen()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCatActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->open();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionCatClose()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCatActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->close();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
//-----------------------------冠军分类-----------------
|
|
|
|
public function actionCat1()
|
|
{
|
|
if (\Yii::$app->request->isAjax) {
|
|
$form = new CommonCat1ListForm();
|
|
$form->attributes = \Yii::$app->request->get();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->search();
|
|
return $this->responseHandler($data);
|
|
}
|
|
return $this->render('cat1');
|
|
}
|
|
|
|
public function actionCat1Edit($id = 0)
|
|
{
|
|
$model = Cat1::findOne([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'is_delete' => 0,
|
|
'id' => $id,
|
|
'type' => Cat::TYPE_GOODS,
|
|
]);
|
|
if ($model == null) {
|
|
$model = new Cat1();
|
|
$model->status = 1;
|
|
}
|
|
if (\Yii::$app->request->isPost) {
|
|
$form = new CommonCat1EditForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->model = $model;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->save();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$cat_ids = [];
|
|
$cat_ids[] = $model->isNewRecord ? 0 : $model->id;
|
|
$parent_list = Cat1::find()
|
|
->where([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'is_delete' => 0,
|
|
'type' => Cat::TYPE_GOODS,
|
|
])
|
|
->andWhere([
|
|
'NOT IN',
|
|
'id',
|
|
$cat_ids
|
|
])
|
|
->select('id,name')->asArray()->all();
|
|
|
|
$is_has_parent = false;//开启是否有父节点
|
|
$parent_list = $is_has_parent ? $parent_list : [];
|
|
array_unshift($parent_list, ['id' => 0, 'name' => '无上级分类']);
|
|
$return_url = \Yii::$app->request->referrer;
|
|
return $this->render('cat-edit1', [
|
|
'model' => $model,
|
|
'return_url' => $return_url,
|
|
'parent_list' => $parent_list
|
|
]);
|
|
}
|
|
|
|
public function actionCat1Delete()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCat1ActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->delete();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionCat1Show()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCat1ActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->show();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionCat1Hide()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCat1ActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->hide();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionCat1Open()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCat1ActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->open();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionCat1Close()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCat1ActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->close();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
//-----------------------------签约价格-----------------
|
|
|
|
|
|
public function actionCat2()
|
|
{
|
|
if (\Yii::$app->request->isAjax) {
|
|
$form = new CommonCat2ListForm();
|
|
$form->attributes = \Yii::$app->request->get();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->search();
|
|
return $this->responseHandler($data);
|
|
}
|
|
return $this->render('cat2');
|
|
}
|
|
|
|
public function actionCat2Edit($id = 0)
|
|
{
|
|
$model = Cat2::findOne([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'is_delete' => 0,
|
|
'id' => $id,
|
|
'type' => Cat::TYPE_GOODS,
|
|
]);
|
|
if ($model == null) {
|
|
$model = new Cat2();
|
|
$model->status = 1;
|
|
}
|
|
if (\Yii::$app->request->isPost) {
|
|
$form = new CommonCat2EditForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->model = $model;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->save();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$cat_ids = [];
|
|
$cat_ids[] = $model->isNewRecord ? 0 : $model->id;
|
|
$parent_list = Cat2::find()
|
|
->where([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'is_delete' => 0,
|
|
'type' => Cat::TYPE_GOODS,
|
|
])
|
|
->andWhere([
|
|
'NOT IN',
|
|
'id',
|
|
$cat_ids
|
|
])
|
|
->select('id,name')->asArray()->all();
|
|
|
|
$is_has_parent = false;//开启是否有父节点
|
|
$parent_list = $is_has_parent ? $parent_list : [];
|
|
array_unshift($parent_list, ['id' => 0, 'name' => '无上级分类']);
|
|
$return_url = \Yii::$app->request->referrer;
|
|
return $this->render('cat-edit2', [
|
|
'model' => $model,
|
|
'return_url' => $return_url,
|
|
'parent_list' => $parent_list
|
|
]);
|
|
}
|
|
|
|
public function actionCat2Delete()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCat2ActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->delete();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionCat2Show()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCat2ActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->show();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionCat2Hide()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCat2ActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->hide();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionCat2Open()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCat2ActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->open();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionCat2Close()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCat2ActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->close();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
|
|
//-----------------------------冠军性别-----------------
|
|
|
|
public function actionCat3()
|
|
{
|
|
if (\Yii::$app->request->isAjax) {
|
|
$form = new CommonCat3ListForm();
|
|
$form->attributes = \Yii::$app->request->get();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->search();
|
|
return $this->responseHandler($data);
|
|
}
|
|
return $this->render('cat3');
|
|
}
|
|
|
|
public function actionCat3Edit($id = 0)
|
|
{
|
|
$model = Cat3::findOne([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'is_delete' => 0,
|
|
'id' => $id,
|
|
'type' => Cat::TYPE_GOODS,
|
|
]);
|
|
if ($model == null) {
|
|
$model = new Cat3();
|
|
$model->status = 1;
|
|
}
|
|
if (\Yii::$app->request->isPost) {
|
|
$form = new CommonCat3EditForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->model = $model;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->save();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$cat_ids = [];
|
|
$cat_ids[] = $model->isNewRecord ? 0 : $model->id;
|
|
$parent_list = Cat3::find()
|
|
->where([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'is_delete' => 0,
|
|
'type' => Cat::TYPE_GOODS,
|
|
])
|
|
->andWhere([
|
|
'NOT IN',
|
|
'id',
|
|
$cat_ids
|
|
])
|
|
->select('id,name')->asArray()->all();
|
|
|
|
$is_has_parent = false;//开启是否有父节点
|
|
$parent_list = $is_has_parent ? $parent_list : [];
|
|
array_unshift($parent_list, ['id' => 0, 'name' => '无上级分类']);
|
|
$return_url = \Yii::$app->request->referrer;
|
|
return $this->render('cat-edit3', [
|
|
'model' => $model,
|
|
'return_url' => $return_url,
|
|
'parent_list' => $parent_list
|
|
]);
|
|
}
|
|
|
|
public function actionCat3Delete()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCat3ActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->delete();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionCat3Show()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCat3ActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->show();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionCat3Hide()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCat3ActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->hide();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionCat3Open()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCat3ActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->open();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionCat3Close()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCat3ActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->close();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
|
|
//-----------------------------业务类型-----------------
|
|
|
|
public function actionCat4()
|
|
{
|
|
if (\Yii::$app->request->isAjax) {
|
|
$form = new CommonCat4ListForm();
|
|
$form->attributes = \Yii::$app->request->get();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->search();
|
|
return $this->responseHandler($data);
|
|
}
|
|
return $this->render('cat4');
|
|
}
|
|
|
|
public function actionCat4Edit($id = 0)
|
|
{
|
|
$model = Cat4::findOne([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'is_delete' => 0,
|
|
'id' => $id,
|
|
'type' => Cat::TYPE_GOODS,
|
|
]);
|
|
if ($model == null) {
|
|
$model = new Cat4();
|
|
$model->status = 1;
|
|
}
|
|
if (\Yii::$app->request->isPost) {
|
|
$form = new CommonCat4EditForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->model = $model;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->save();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$cat_ids = [];
|
|
$cat_ids[] = $model->isNewRecord ? 0 : $model->id;
|
|
$parent_list = Cat4::find()
|
|
->where([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'is_delete' => 0,
|
|
'type' => Cat::TYPE_GOODS,
|
|
])
|
|
->andWhere([
|
|
'NOT IN',
|
|
'id',
|
|
$cat_ids
|
|
])
|
|
->select('id,name')->asArray()->all();
|
|
|
|
$is_has_parent = false;//开启是否有父节点
|
|
$parent_list = $is_has_parent ? $parent_list : [];
|
|
array_unshift($parent_list, ['id' => 0, 'name' => '无上级分类']);
|
|
$return_url = \Yii::$app->request->referrer;
|
|
return $this->render('cat-edit4', [
|
|
'model' => $model,
|
|
'return_url' => $return_url,
|
|
'parent_list' => $parent_list
|
|
]);
|
|
}
|
|
|
|
public function actionCat4Delete()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCat4ActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->delete();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionCat4Show()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCat4ActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->show();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionCat4Hide()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCat4ActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->hide();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionCat4Open()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCat4ActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->open();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionCat4Close()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonCat4ActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = Cat::TYPE_GOODS;
|
|
$data = $form->close();
|
|
return $this->responseHandler($data);
|
|
}
|
|
}
|
|
|
|
|