getUserInfo([ [ 'uid', '=', $this->user_info[ 'uid' ] ] ], 'uid,app_module,site_id,group_id,group_name,username,status,is_admin,password')[ 'data' ]; if ($userinfo[ 'is_admin' ]) { $store_info = ( new Store() )->getDefaultStore($userinfo[ 'site_id' ])[ 'data' ] ?? []; if (empty($user_info[ 'user_group_list' ])) { $userinfo[ 'user_group_list' ] = [ $store_info ]; } else { $store_list = array_column($userinfo[ 'user_group_list' ], null, 'store_id'); if (!isset($store_list[ $store_info[ 'store_id' ] ])) array_push($userinfo[ 'user_group_list' ], $store_info); } } if (!$store_id && isset($userinfo[ 'user_group_list' ][ 0 ])) $store_id = $userinfo[ 'user_group_list' ][ 0 ][ 'store_id' ]; $store_ids = array_column($userinfo[ 'user_group_list' ], 'store_id'); $token = $this->createToken($userinfo, ( 86400 * 7 )); $this->assign('store_id', in_array($store_id, $store_ids) ? $store_id : 0); $this->assign('token', $token); $this->assign('url', ROOT_URL . '/cashregister'); return $this->fetch("index/cashier"); } /** * 创建token * @param $user_info * @return string */ private function createToken($user_info) { $api_config = ( new Api() )->getApiConfig()[ 'data' ]; $data = [ 'user_info' => $user_info, 'expire_time' => $api_config[ 'value' ][ 'long_time' ] * 3600 ]; if ($api_config[ 'is_use' ] && isset($api_config[ 'value' ][ 'private_key' ]) && !empty($api_config[ 'value' ][ 'private_key' ])) { $token = encrypt(json_encode($data), $api_config[ 'value' ][ 'private_key' ]); } else { $token = encrypt(json_encode($data)); } return $token; } /** * 收银端部署 * @return mixed */ public function deploy() { return $this->fetch("addon/cashier/shop/view/index/deploy.html"); } /** * 刷新收银端 */ public function refreshCashier() { return ( new Cashier() )->refreshCashier(); } /** * 下载收银端uniapp源码 */ public function downloadCashier() { $res = ( new Cashier() )->downloadOs(); echo $res[ 'message' ]; } }