예제 #1
0
 public function store(Request $request, Account $account)
 {
     $keys = 'title,author,description,content,cover_aid,cover_in_content,redirect,url';
     $data = $this->autoValidate($request, 'wechat-news.store', $keys);
     $news = WechatDepotNews::create($data + ['waid' => $account->getAccountID()]);
     return $this->success('', url('admin/wechat/depot-news'), $news->toArray());
 }
예제 #2
0
 public function store(Request $request, Account $account)
 {
     $keys = 'openid,nickname,gender,avatar_aid,country,province,city,language,unionid,remark,is_subscribed,subscribed_at,uid';
     $data = $this->autoValidate($request, 'wechat-user.store', $keys);
     WechatUser::create($data + ['waid' => $account->getAccountID()]);
     return $this->success('', url('admin/wechat/user'));
 }
예제 #3
0
 public function store(Request $request, Account $account)
 {
     $keys = 'name,description,appid,appsecret,token,encodingaeskey,qr_aid';
     $data = $this->autoValidate($request, 'wechat-replay.store', $keys);
     WechatReply::create($data + ['waid' => $account->getAccountID()]);
     return $this->success('', url('admin/wechat/replay'));
 }
예제 #4
0
 public function store(Request $request, Account $account)
 {
     $keys = 'type';
     $data = $this->autoValidate($request, 'wechat-depot.store', $keys);
     $depot = WechatDepot::create($data + ['waid' => $account->getAccountID()]);
     if ($data['type'] == 'news') {
         $this->storeNews($request, $depot, $data['type']);
     } else {
         $this->storeOther($request, $depot, $data['type'], true);
     }
     return $this->success('', FALSE, ['isCreated' => true, 'type' => $depot->type]);
 }
예제 #5
0
 public function export(Request $request, Account $account)
 {
     $message = new WechatMessage();
     $builder = $message->newQuery()->with(['account', 'user', 'depot', 'link', 'location', 'text', 'media'])->where('waid', $account->getAccountID());
     $page = $request->input('page') ?: 0;
     $pagesize = $request->input('pagesize') ?: config('site.pagesize.export', 1000);
     $total = $this->_getCount($request, $builder);
     if (empty($page)) {
         $this->_of = $request->input('of');
         $this->_table = $message->getTable();
         $this->_total = $total;
         $this->_pagesize = $pagesize > $total ? $total : $pagesize;
         return $this->view('wechat::admin.wechat.message.export');
     }
     $data = $this->_getExport($request, $builder);
     return $this->success('', FALSE, $data);
 }
예제 #6
0
 public function takeEffect(Account $account)
 {
     // 	    $menu_data = array (
     // 	        'button' => array (
     // 	            0 => array (
     // 	                'name' => '新品特惠',
     // 	                'sub_button' => array (
     // 	                    0 => array (
     // 	                        'type' => 'view',
     // 	                        'name' => '优惠列表',
     // 	                        'url' => 'http://www.hanpaimall.com/m/classify',
     // 	                    ),
     // 	                ),
     // 	            ),
     // 	            1 => array (
     // 	                'type' => 'view',
     // 	                'name' => '汉派商城',
     // 	                'url' => 'http://www.hanpaimall.com/m',
     // 	            ),
     // 	            2 => array (
     // 	                'name' => '我的中心',
     // 	                'sub_button' => array (
     // 	                    0 => array (
     // 	                        'type' => 'view',
     // 	                        'name' => '管理中心',
     // 	                        'url' => 'http://www.hanpaimall.com/auth',
     // 	                    ),
     // 	                    1 => array (
     // 	                        'type' => 'view',
     // 	                        'name' => '个人中心',
     // 	                        'url' => 'http://www.hanpaimall.com/m/ucenter',
     // 	                    )
     // 	                )
     // 	            )
     // 	        )
     // 	    );
     $menu_data = ['button' => []];
     $menulist = WechatMenu::with('children')->newQuery()->where('waid', $account->getAccountID())->where('pid', 0)->orderBy('order', 'asc')->get();
     foreach ($menulist as $menu) {
         $menu_item_data = [];
         if ($menu->children->count() > 0) {
             $menu_item_data['name'] = $menu->title;
             foreach ($menu->children as $sub_menu) {
                 $menu_item_data['sub_button'][] = ['type' => 'view', 'name' => $sub_menu->title, 'url' => $sub_menu->url];
             }
         } else {
             $menu_item_data = ['type' => 'view', 'name' => $menu->title, 'url' => $menu->url];
         }
         $menu_data['button'][] = $menu_item_data;
     }
     //           var_export($menu_data);exit;
     $account = WechatAccount::findOrFail($account->getAccountID());
     $api = new API($account->toArray(), $account->getKey());
     if ($api->createMenu($menu_data)) {
         return $this->success('wechat::wechat.menu_create_succerss', url('admin/wechat/menu'));
     } else {
         return $this->failure('wechat::wechat.menu_create_failure', url('admin/wechat/menu'));
     }
 }