You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
zhishifufei_php/application/institution/controller/official/Official.php

53 lines
2.2 KiB

<?php
// 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
// +----------------------------------------------------------------------
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
// +----------------------------------------------------------------------
namespace app\institution\controller\official;
use app\institution\controller\AuthController;
use service\WechatService;
use think\Cache;
use think\Db;
use think\Request;
/**
* 微信菜单
* Class StoreOrder
*/
class Official extends AuthController
{
public function index()
{
$menus = Db::name('cache_merchant')->where('mer_id', $this->merchantId)->value('result');
$menus = $menus ?: '[]';
$this->assign('menus', $menus);
return $this->fetch();
}
public function save(Request $request)
{
$buttons = $request->post('button/a', []);
if (!count($buttons)) return $this->failed('请添加至少一个按钮');
try {
$menus = Db::name('cache_merchant')->where(array('mer_id'=> $this->merchantId,'type' => 1))->find();
if($menus){
WechatService::menuService()->add($buttons);
Db::name('cache_merchant')->where('mer_id',$this->merchantId)->update(['key' => 'wechat_menus', 'result' => json_encode($buttons), 'add_time' => time()], true);
}else{
Db::name('cache_merchant')->insert(['mer_id'=>$this->merchantId,'type' => 1,'key' => 'wechat_menus', 'result' => json_encode($buttons), 'add_time' => time()], true);
}
return $this->successful('修改成功!');
} catch (\Exception $e) {
return $this->failed($e->getMessage());
}
}
}