Пример #1
0
 public static function bindAction($controller, $con, $appid, $openid, $params)
 {
     $re = array("returncode" => "0000");
     try {
         $bindinfo = $params->get("auth");
         $bindinfo = explode(",", $bindinfo);
         $bind_uid = $bindinfo[0];
         $authkey = count($bindinfo) == 1 ? "" : $bindinfo[1];
         $sql = "select appkey from we_appcenter_apps where appid=?";
         $ds = $con->GetData("t", $sql, array((string) $appid));
         if (count($ds["t"]["rows"]) == 0) {
             $re = array("returncode" => "9999", "msg" => "appid is not found");
         } else {
             //$appkey = $ds["t"]["rows"][0]["appkey"];
             $sql = "delete from we_staff_account_bind where bind_account=? and bind_type=? and appid=?";
             $con->ExecSQL($sql, array((string) $openid, self::$bind_type, $appid));
             //$authkey=$authcode;//DES::encrypt2($authcode,$appkey);
             //$bind_uid=$authkey;
             $sql = "insert into we_staff_account_bind(bind_account,appid,bind_uid,authkey,bind_type,bind_created)values(?,?,?,?,?,now())";
             $con->ExecSQL($sql, array((string) $openid, (string) $appid, (string) $bind_uid, (string) $authkey, (string) self::$bind_type));
             $app = new \Justsy\BaseBundle\Management\App($controller->container);
             $app->refreshappbind(array("appid" => $appid, "openid" => $openid));
         }
     } catch (\Exception $e) {
         return array("returncode" => "9999", "msg" => $e->getMessage());
     }
     return self::responseJson(json_encode($re));
 }