From 53639f6506abaa6f31d6e931523df413bd34d5b9 Mon Sep 17 00:00:00 2001 From: liangyuyan <1103300295@qq.com> Date: Thu, 10 Sep 2020 20:20:15 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=B1=95=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E8=BF=9B=E8=A1=8C=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Forms/CategoryTieForm.php | 25 +++++++++++++------- app/Console/Commands/MigrateStoreAccount.php | 12 ---------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/app/Admin/Forms/CategoryTieForm.php b/app/Admin/Forms/CategoryTieForm.php index 8eb222c..adecb33 100644 --- a/app/Admin/Forms/CategoryTieForm.php +++ b/app/Admin/Forms/CategoryTieForm.php @@ -26,23 +26,30 @@ class CategoryTieForm extends Form $data = []; if(!empty($category)){ foreach ($category as $key => $value){ - $data[$value->id] = json_encode([ + $data[$value->sort] = json_encode([ 'icon' => $value->cover_img, 'name' => $value->title, - 'sort' => $value->sort + 'sort' => $value->sort, + 'id' => $value->id ]); } + if(count($data) > 0){ + // 根据sort排序 + krsort($data); + $save = array_column($data,null,'id'); + $this->ssdb->client()->hclear('applet_index_category'); - } - } - $category = $this->ssdb->client()->multi_hset('applet_index_category',$data); - if($category === false){ - return $this->error('修改失败'); - } + $category = $this->ssdb->client()->multi_hset('applet_index_category',$save); - return $this->success('修改成功', '/category'); + if($category === false){ + return $this->error('修改失败'); + } + return $this->success('修改成功', '/category'); + } + } + return $this->success('未进行修改或者查询不到分类', '/category'); } /** diff --git a/app/Console/Commands/MigrateStoreAccount.php b/app/Console/Commands/MigrateStoreAccount.php index 76ab4c6..5e4debd 100644 --- a/app/Console/Commands/MigrateStoreAccount.php +++ b/app/Console/Commands/MigrateStoreAccount.php @@ -39,18 +39,6 @@ class MigrateStoreAccount extends Command */ public function handle() { - $m = ['120'=>['sort'=>'12'],'12'=>['sort'=>'3'],'112'=>['sort'=>'2'],'110'=>['sort'=>'120']]; - - $arr = []; - foreach ($m as $key=>$value){ - $arr[$value['sort']] = $value; - $arr[$value['sort']]['id'] = $key; - } - krsort($arr); - $b = array_column($arr,null,'id'); - // array_multisort($sort,SORT_DESC,SORT_NUMERIC,$m); - var_dump($b); - return 0; $oldTableName = 'ims_cjdc_store_account'; $newTableName = 'lanzu_financial_record'; // 判断表是否存在